zoukankan      html  css  js  c++  java
  • 机器学习笔记,使用metrics.classification_report显示精确率,召回率,f1指数

    sklearn中的classification_report函数用于显示主要分类指标的文本报告.在报告中显示每个类的精确度,召回率,F1值等信息。 
    主要参数: 
    y_true:1维数组,或标签指示器数组/稀疏矩阵,目标值。 
    y_pred:1维数组,或标签指示器数组/稀疏矩阵,分类器返回的估计值。 
    labels:array,shape = [n_labels],报表中包含的标签索引的可选列表。 
    target_names:字符串列表,与标签匹配的可选显示名称(相同顺序)。 
    sample_weight:类似于shape = [n_samples]的数组,可选项,样本权重。 
    digits:int,输出浮点值的位数.

        Parameters
        ----------
        y_true : 1d array-like, or label indicator array / sparse matrix
            Ground truth (correct) target values.
    
        y_pred : 1d array-like, or label indicator array / sparse matrix
            Estimated targets as returned by a classifier.
    
        labels : array, shape = [n_labels]
            Optional list of label indices to include in the report.
    
        target_names : list of strings
            Optional display names matching the labels (same order).
    
        sample_weight : array-like of shape = [n_samples], optional
            Sample weights.
    
        digits : int
            Number of digits for formatting output floating point values
    
        Returns
        -------
        report : string
            Text summary of the precision, recall, F1 score for each class.
    
            The reported averages are a prevalence-weighted macro-average across
            classes (equivalent to :func:`precision_recall_fscore_support` with
            ``average='weighted'``).
    
            Note that in binary classification, recall of the positive class
            is also known as "sensitivity"; recall of the negative class is
            "specificity".
    
        Examples
        --------
        >>> from sklearn.metrics import classification_report
        >>> y_true = [0, 1, 2, 2, 2]
        >>> y_pred = [0, 0, 2, 2, 1]
        >>> target_names = ['class 0', 'class 1', 'class 2']
        >>> print(classification_report(y_true, y_pred, target_names=target_names))
                     precision    recall  f1-score   support
        <BLANKLINE>
            class 0       0.50      1.00      0.67         1
            class 1       0.00      0.00      0.00         1
            class 2       1.00      0.67      0.80         3
        <BLANKLINE>
        avg / total       0.70      0.60      0.61         5
        <BLANKLINE>

    参考:

    https://www.programcreek.com/python/example/81623/sklearn.metrics.classification_report

    https://blog.csdn.net/akadiao/article/details/78788864

  • 相关阅读:
    数学是最好的语言
    人类的语言--自然语言--》逻辑语言
    为什么大脑喜欢看图?
    思考是调用大脑存储的上下文对输入信息进行处理的过程
    Redis的相关问题总结
    TP5 关联模型使用(嵌套关联、动态排序以及隐藏字段)
    array_column 函数, 以及在PHP5.5之下的替代方法
    thinkphp在app接口开发过程中的通讯安全认证
    PHP开发APP接口实现--基本篇
    分布式与集群的区别是什么?
  • 原文地址:https://www.cnblogs.com/bincoding/p/8911983.html
Copyright © 2011-2022 走看看