你不需要/想要使用地圖功能,因爲它在底層for loop
。
幾乎所有sklearn
方法是量化的,他們接受列表相似的對象(表,numpy的陣列等),這會比map(...)
方法
演示工作備受快得多:
In [121]: from sklearn.preprocessing import scale
In [122]: X = [1,2,3,4]
In [123]: scale(X)
Out[123]: array([-1.34164079, -0.4472136 , 0.4472136 , 1.34164079])
相同的演示使用numpy的數組:
In [39]: x = np.array(X)
In [40]: x
Out[40]: array([1, 2, 3, 4])
In [41]: scale(x)
DataConversionWarning: Data with input dtype int32 was converted to float64 by the scale function.
warnings.warn(msg, _DataConversionWarning)
Out[41]: array([-1.34164079, -0.4472136 , 0.4472136 , 1.34164079])
,預計浮D型細胞,所以我們可以很容易地轉換我們的numpy的陣列到FL在飛行燕麥D型:
In [42]: scale(x.astype('float64'))
Out[42]: array([-1.34164079, -0.4472136 , 0.4472136 , 1.34164079])
Python內置的map函數與map/reduce並行性無關。 –