【发布时间】:2019-05-27 16:28:15
【问题描述】:
我的线性回归与单个特征完美配合。自从尝试使用两个以来,我收到以下错误:ValueError:找到样本数量不一致的输入变量:[2, 1]
第一个打印语句打印以下内容: (2, 6497) (1, 6497)
然后代码在 train_test_split 阶段崩溃。
有什么想法吗?
feat_scores = {}
X = df[['alcohol','density']].values.reshape(2,-1)
y = df['quality'].values.reshape(1,-1)
print (X.shape, y.shape)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)
print (X_train.shape, y_train.shape)
print (X_test.shape, y_test.shape)
reg = LinearRegression()
reg.fit(X_train, y_train)
reg.predict(y_train)
【问题讨论】:
标签: python scikit-learn linear-regression