【问题标题】:How to access the amount of support for each class with scikit-learn, using multi-class classification?如何使用 scikit-learn 访问每个类的支持量,使用多类分类?
【发布时间】:2015-03-30 22:45:25
【问题描述】:

我可以使用 scikit-learn 使用以下代码打印分类报告:

def predict_and_report_test(self, prediction_model):
    print(prediction_model.algorithm + ' Test')
    prediction_model.model = prediction_model.model.fit(self.X_train,  self.y_train).predict(self.X_test)
    print(classification_report(self.y_test, prediction_model.model,  target_names=None))

这段代码给了我以下输出:

问题是分类报告以字符串形式返回此信息,所以我的问题是:scikit learn 是否提供了任何简单的方法来访问每个类的支持并可能将它们存储在一个数组中,这样它们就可以用来绘制每个类的支持度图?

【问题讨论】:

    标签: machine-learning scikit-learn


    【解决方案1】:

    【讨论】:

    • 在文档中它说如果平均参数不是无,此方法返回四个不同的东西:精度:浮点(如果平均值不是无)或浮点数组,形状 = [n_unique_labels]:召回:float(如果average不是None)或float数组,shape = [n_unique_labels]:fbeta_score:float(如果average不是None)或float数组,shape = [n_unique_labels]:支持:int(如果average不是无)或 int 数组,形状 = [n_unique_labels] :
    • 它没有说明如何实际获得支持,你知道怎么做吗?我认为它只是要返回每个类的准确性
    • 它确实解释了如何获得支持。我返回一个包含四件事的元组,最后一个是支持。
    • 顺便说一句,你也可以只做 np.bincount(y)
    猜你喜欢
    • 2012-05-18
    • 1970-01-01
    • 2012-08-23
    • 2016-05-11
    • 2015-06-03
    • 2012-11-11
    • 2013-06-12
    • 2019-06-05
    相关资源
    最近更新 更多