【问题标题】:Python - predict a manual valuePython - 预测手动值
【发布时间】:2020-11-06 09:17:47
【问题描述】:

我有一个包含 21 列的数据集,而 N.11 是我要预测的列。

我的数据集采用这种模式构建:

X = dataset.iloc[:,[0,1,2,3,4,5,6,7,8,9,10,12,13,14,15,16,17,18,19,20]].values #Input features
y = dataset.iloc[:,11].values #Label to be predicted

以及来自数据集X[:1]的行示例

[2.0, 4, 7, 14, 16, 12, 4, 15, 12, 1, 2, '45', '55', 15, 19, 2, 1, 3, 4, 3];

当我要预测手动数据时:

data = [1,4,8,23,8,13,7,9,20,1,3,'50','50',15,16,0,2,4,8,3,1];
new_prediction = lin.predict(sc.transform(np.array([data]).reshape(-1, 1)))
print("Prediction score:" , new_prediction)

我得到了这个错误:

ValueError: 形状为 (21,1) 的不可广播输出操作数不会 匹配广播形状 (21,20)

因为缺少的列是我想要预测的值。
我该如何解决这个问题?

【问题讨论】:

    标签: python pandas numpy machine-learning dataset


    【解决方案1】:

    我错了。数据中的项目多于要求

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-07-20
      • 2016-06-06
      • 2021-07-11
      • 1970-01-01
      • 1970-01-01
      • 2019-11-07
      • 2020-12-05
      相关资源
      最近更新 更多