【发布时间】:2018-12-11 11:01:38
【问题描述】:
所以我从 CSV 文件中读取并尝试使用获取每一行的系数
df = pd.read_csv(os.path.join(path))
X = df['param_a']
y= df['param_b']
X_train, X_test, y_train, y_test= train_test_split(X,y)
reg = linear_model.LinearRegression()
reg.fit(X_train, y_train)
print('Coefficients: \n', reg.coef_)
这会返回一个错误:
"Expected 2D array, got 1D array instead:\narray=[-100 0 0 100 -20 250 200 -125 -250 0 20 -250 -200 125 -10].\nReshape 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."
我正在尝试获取每个对应行的系数到我的网格。
任何人,请帮忙?谢谢
【问题讨论】:
标签: python python-2.7 extjs scikit-learn linear-regression