python - 获取多变量模型中单个样本的分数?

标签 python machine-learning scikit-learn

我正在尝试使一个简单的 scikit-learn 示例正常工作,但我不断收到错误:不支持多类多输出

我的代码的第一部分遵循任何基本教程,按预期工作:

>>> from sklearn import ensemble
>>> from sklearn import datasets
>>> dataset = datasets.load_linnerud()
>>> X, y = dataset.data, dataset.target
>>> clf = ensemble.RandomForestClassifier(n_estimators=500)
>>> clf.fit(X, y)
>>> clf.predict([X[0]])
array([[ 191.,   36.,   50.]])

但是,当我尝试获取预测分数时,出现以下错误:

>>> clf.score([X[0]], [y[0]])
(...)
ValueError: multiclass-multioutput is not supported

使用datasets.load_iris()时,一切正常。我究竟做错了什么?如何获得多变量模型中单个样本的得分?

最佳答案

尝试将 RandomForestRegressor 替换为 RandomForestClassifierload_linnerud() 的文档显示这是一个回归问题。这样做使代码对我有用。

关于python - 获取多变量模型中单个样本的分数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24875562/

相关文章:

打印不同的python基本代码

python - 使用 python 上传文件返回 Request failed with status code', 403, 'Expected one of' , <HTTPStatus.OK : 200>

machine-learning - 训练暗网立即结束

python - 引发 ValueError ("bad input shape {0}".format(shape)) ValueError : bad input shape (10, 90)

python - 属性错误 : module 'keras.backend' has no attribute 'image_dim_ordering'

python - 如何使用 Django 和 jQuery 设置文件下载对话框?

python - 值错误 : Data is not binary and pos_label is not specified for roc_curve

hadoop - Hadoop与Mahout和机器学习有关系吗?

python - 将 classification_report 的准确度返回到列表中

python - 科学数据包 : calculate precision and recall using cross_val_score function