我正在尝试训练我的X_train和y_train但有一些数组问题


from sklearn.linear_model import LogisticRegression
model = LogisticRegression()
model = model.fit(X_train, y_train)

我试图在3号线上训练(X_train和y_train(,但它给了我错误

ValueError: Expected 2D array, got 1D array instead: array=[56. 55. 45. 22. 49. 46. 23. 55. 21. 28. 62. 61. 54. 25. 47. 18. 27. 60. 50. 19. 26. 25. 52. 18.]. 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 LogisticRegression
X_train = np.reshape(X_train,(-1,1))
y_train = np.reshape(y_train,(-1,1))
model = LogisticRegression()
model = model.fit(X_train, y_train)

最新更新