如图。ax.scatter(xMat[:,1].flatten().A[0], yMat.flatten().A[0])语句中flatten()后面为何跟A[0],且xy后皆根A[0]
![图片说明](https://img-ask.csdn.net/upload/201811/22/1542848206_730479.png)
如图。ax.scatter(xMat[:,1].flatten().A[0], yMat.flatten().A[0])语句中flatten()后面为何跟A[0],且xy后皆根A[0]
![图片说明](https://img-ask.csdn.net/upload/201811/22/1542848206_730479.png)
flatten是numpy.ndarray.flatten的一个函数,即返回一个折叠成一维的数组。但是该函数只能适用于numpy对象,即array或者mat
你的xMat折叠成一维数组,而且是按A的方式,进行折叠,然后[0]是取第一个元素
Parameters:
ndarray.flatten(order='C')
Return a copy of the array collapsed into one dimension.
order : {‘C’, ‘F’, ‘A’, ‘K’}, optional
‘C’ means to flatten in row-major (C-style) order. ‘F’ means to flatten in column-major (Fortran- style) order. ‘A’ means to flatten in column-major order if a is Fortran contiguous in memory, row-major order otherwise. ‘K’ means to flatten a in the order the elements occur in memory. The default is ‘C’.
---------------------