#建模预测
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条回答 默认 最新
悬赏问题
- ¥15 微信会员卡等级和折扣规则
- ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
- ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
- ¥15 gdf格式的脑电数据如何处理matlab
- ¥20 重新写的代码替换了之后运行hbuliderx就这样了
- ¥100 监控抖音用户作品更新可以微信公众号提醒
- ¥15 UE5 如何可以不渲染HDRIBackdrop背景
- ¥70 2048小游戏毕设项目
- ¥20 mysql架构,按照姓名分表
- ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分