python - 线性回归 (python) - 使用多个特征的错误
问题描述
对 ML 和 python 来说很新,所以这可能是一个基本问题,但希望有人能给我指导。
拥有一个天气数据集,并希望开发一个模型来根据集合中的其他特征(表观温度、湿度、能见度等)预测温度。
我有一个使用 1 个功能的模型,它似乎运行良好:
predictors1 = train[['apparent_temperature']]
response = train['temperature']
lr1 = LinearRegression(normalize=True)
lr1.fit(predictors1, response)
y_pred = lr1.predict(response)
当我使用超过 1 个功能制作另一个模型时,出现错误:
predictors2 = train[['apparent_temperature', 'humidity', 'visibility']]
response = train['temperature']
lr2 = LinearRegression(normalize=True)
lr2.fit(predictors2, response)
y_pred2 = lr2.predict(response)
我得到的错误信息是:
ValueError: matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 3 is different from 1)
不确定我是否正确阅读,但这看起来像矩阵乘法问题 - 关于我做错了什么的任何想法,或者如何扩展模型以包含多个功能?
解决方案
推荐阅读
- c# - 请求路径与支持的文件类型不匹配
- sql-server - 如何按用户汇总设备工单小时数
- google-chrome - 在谷歌浏览器中将 --user-data-dir 设置为空字符串时会发生什么?
- python - 在python中将数字存储在多维(稀疏)数组中的最佳方法
- vue.js - 如何为 Vue Apollo 导入 Apollo Client 3?
- c# - 以相反的顺序显示二维数组的行
- flutter - 在颤动中将二进制数据转换为音频
- azure - 如何在 Azure 中将 pdf 转换为 base64
- android - 从表单中提取数据以登录 Android 应用程序
- javascript - useEffect 持续触发 GET 请求