我想建立Logistic迴歸模型,data.Exam1是重塑列表(-1,1),並返回持股量數據類型
reg = linear_model.LogisticRegression()
X = list(data.Exam1.values.reshape(-1,1)).........(1)
我已執行此操作
type(X[0]) returns numpy.ndarray
第一列
reg.fit接受它包含列表中的所有項目浮動參數,所以我做了,因爲這個例外ValueError: Unknown label type: 'continuous'
newX = []
for item in X:
type(float(item))
newX.append(float(item))
這
所以當我試圖做
reg.fit(newX,newY,A)
它將引發我此異常
Reshape your data either using X.reshape(-1, 1) if your data has a single feature or X.reshape(1, -1) if it contains a single sample.
,我已經做了(1),當我嘗試再次重塑其ndarray再次返回,怎麼能我已經重塑和轉換項目同時浮動?? (:布爾型)作爲考試分數的功能(Exam1:浮動,Exam2:浮動)
你試過'.reshape(-1,1).astype(float)'嗎?參見參考[這裏](https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.astype.html) – wflynny
@wflynny試過這個'X = list(data.Exam1.values.reshape( -1,1).astype(float))'剛纔,仍然返回ndarray – MrRobot9
@wflynny它返回(100,) – MrRobot9