7
我用numpy和scipy,還有一些函數真的關心數組的維數我有一個函數名CovexHull(point),它接受點作爲二維數組。用2個一維數組創建2維數組
船體=凸形輪廓(點)
In [1]: points.ndim
Out[1]: 2
In [2]: points.shape
Out[2]: (10, 2)
In [3]: points
Out[3]:
array([[ 0. , 0. ],
[ 1. , 0.8],
[ 0.9, 0.8],
[ 0.9, 0.7],
[ 0.9, 0.6],
[ 0.8, 0.5],
[ 0.8, 0.5],
[ 0.7, 0.5],
[ 0.1, 0. ],
[ 0. , 0. ]])
正如可以看到點之上與NDIM 2.
現在numpy的我有2個不同的陣列numpy的(TP和FP )像這樣(例如fp)
In [4]: fp.ndim
Out[4]: 1
In [5]: fp.shape
Out[5]: (10,)
In [6]: fp
Out[6]:
array([ 0. , 0.1, 0.2, 0.3, 0.4, 0.4,
0.5, 0.6, 0.9, 1. ])
我的問題是如何創建一個2維numpy陣列有效地像tp和fp點一樣
+1,但你可以得到正確的形狀直接與['np.column_stack'(http://docs.scipy.org/doc/numpy/reference/generated/numpy.column_stack.html) 。 – Jaime
這甚至更好! – ijmarshall