我有一些numpy数组(X_test,X_train,y_test,y_test),希望将它们放入分类器中,然后由得分函数进行测试。
我的代码是:
sample_data = pd.read_csv("includes\\csv.csv")
sample_datat = pd.read_csv("includes\\csvt.csv")
X_train= np.array(sample_data["day"])
y_train= np.array(sample_data["balance"])
X_test= np.array(sample_datat["day"])
y_test= np.array(sample_datat["balance"])
X_train = X_train.reshape(1, -1)
y_train = y_train.reshape(1, -1)
X_test = X_test.reshape(1, -1)
y_test = y_test.reshape(1, -1)
clf = LinearRegression()
clf.fit(X_train, y_train)
clf.score(X_test, y_test)
运行后错误为:
ValueError: shapes (1,1) and (3,3) not aligned: 1 (dim 1) != 3 (dim 0)
如何防止这种情况发生?