データに対して線形回帰を実行しようとしています。しかし、データの再形成に問題があります。このエラーが発生しました:
array=[1547977519 1547977513].
Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.
これは私のコードです:
from sklearn.linear_model import LinearRegression
X=[1547977519, 1547977513]
Y=[1, 1]
#X = X.reshape(-1, 1)
print(X)
#Y = Y.reshape(-1, 1)
print(Y)
reg = LinearRegression().fit(X, X)
print(reg.score(X, Y))
.reshapeを追加しようとしましたが、正しく機能しません。それは私にこのエラーを与えます:
X = X.reshape(-1, 1)
AttributeError: 'list' object has no attribute 'reshape'
あなたが探しているのは、numpy.array
どの方法があるかですreshape
from numpy import array
>>> x = array([1547977519, 1547977513])
>>> x.reshape(-1,1)
array([[1547977519],
[1547977513]])
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加