#建模预测
x=data4.iloc[:,2].values.astype(float)
y=data4.iloc[:,3:6].values.astype(float)
from sklearn import model_selection
x_train,x_test,y_train,y_test=model_selection.train_test_split(x,y,test_size=0.35,random_state=1)
x_train=np.array(x).reshape(-1,1)
x_test=np.array(x_train).reshape(-1,1)
y_train=np.array(x).reshape(-1,1)
from sklearn.linear_model import LinearRegression
linregTr=LinearRegression()
linregTr.fit(x_train,y_train)
print('线性回归模型的回归系数:',linregTr.coef_)
print('线性回归模型的截距:',linregTr.intercept_)
from sklearn import metrics
y_train_pred=linregTr.predict(x_train)
y_test_pred=linregTr.predict(x_test)
train_err=metrics.mean_squared_error(y_train,y_train_pred)
test_err=metrics.mean_squared_error(y_test,y_test_pred)
print('在训练集上的均方根误差是:',train_err)
print('在测试集上的均方根误差是:',test_err)
到这里之后就开报错,说找到样本数不一致的输入变量
Python,在分析建模的过程中出现报错显示,找到样本数不一致的输入变量,有人能解释一下并解决这个问题吗?
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
悬赏问题
- ¥30 VMware 云桌面水印如何添加
- ¥15 用ns3仿真出5G核心网网元
- ¥15 matlab答疑 关于海上风电的爬坡事件检测
- ¥88 python部署量化回测异常问题
- ¥30 酬劳2w元求合作写文章
- ¥15 在现有系统基础上增加功能
- ¥15 远程桌面文档内容复制粘贴,格式会变化
- ¥15 这种微信登录授权 谁可以做啊
- ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
- ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”