import statsmodels.api as sm
# 添加截距项
# x_train.insert(0, 'constant', 1)
model = sm.OLS(y_train, x_train)
result = model.fit()
result.summary()
y_pre = result.predict(x) # 做预测
statsmodels包做回归报错ValueError: shapes (354,37) and (152,37) not aligned: 37 (dim 1) != 152 (dim 0)
预测时,不要用model.predict(x)
,而是要用result.predict(x)