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

  • 相关阅读:
    [转]How can I create a design netlist without including my source design files?
    [转]基于FPGA的以太网开发
    [转]GMII/RGMII/SGMII/TBI/RTBI接口信号及时序介绍
    [原]Altium画PCB时鼠标十字不能对准焊盘中心
    [转]Altera特殊管脚的使用(适用全系列Altera FPGA,MSEL区别除外)-来自altera论坛
    [转]STM32正交编码器驱动电机
    [转]使用D触发器制作正交编码器的鉴相电路
    [转]解决STM32开启定时器时立即进入一次中断程序问题
    [转]ISE iMPACT bit生成mcs
    [转]NiosII处理器软件代码优化方法
  • 原文地址:https://www.cnblogs.com/bincoding/p/8911983.html
Copyright © 2011-2022 走看看