• ALINK(三十九):模型评估(四)多标签分类评估 (EvalMultiLabelBatchOp)


    多标签分类评估 (EvalMultiLabelBatchOp)

    Java 类名:com.alibaba.alink.operator.batch.evaluation.EvalMultiLabelBatchOp

    Python 类名:EvalMultiLabelBatchOp

    功能介绍

    多label分类评估是对多label分类算法的预测结果进行效果评估,支持下列评估指标。

     

    f1

    参数说明

    名称

    中文名称

    描述

    类型

    是否必须?

    默认值

    labelCol

    标签列名

    输入表中的标签列名

    String

     

    predictionCol

    预测结果列名

    预测结果列名

    String

     

    labelRankingInfo

    Object列列名

    Object列列名

    String

     

    "object"

    predictionRankingInfo

    Object列列名

    Object列列名

    String

     

    "object"

    代码示例

    Python 代码

    from pyalink.alink import *
    import pandas as pd
    useLocalEnv(1)
    df = pd.DataFrame([
        ["{"object":"[0.0, 1.0]"}", "{"object":"[0.0, 2.0]"}"],
        ["{"object":"[0.0, 2.0]"}", "{"object":"[0.0, 1.0]"}"],
        ["{"object":"[]"}", "{"object":"[0.0]"}"],
        ["{"object":"[2.0]"}", "{"object":"[2.0]"}"],
        ["{"object":"[2.0, 0.0]"}", "{"object":"[2.0, 0.0]"}"],
        ["{"object":"[0.0, 1.0, 2.0]"}", "{"object":"[0.0, 1.0]"}"],
        ["{"object":"[1.0]"}", "{"object":"[1.0, 2.0]"}"]
    ])
    source = BatchOperator.fromDataframe(df, "pred string, label string")
    evalMultiLabelBatchOp: EvalMultiLabelBatchOp = EvalMultiLabelBatchOp().setLabelCol("label").setPredictionCol("pred").linkFrom(source)
    metrics = evalMultiLabelBatchOp.collectMetrics()
    print(metrics)

    Java 代码

    import org.apache.flink.types.Row;
    import com.alibaba.alink.operator.batch.BatchOperator;
    import com.alibaba.alink.operator.batch.evaluation.EvalMultiLabelBatchOp;
    import com.alibaba.alink.operator.batch.source.MemSourceBatchOp;
    import com.alibaba.alink.operator.common.evaluation.MultiLabelMetrics;
    import org.junit.Test;
    import java.util.Arrays;
    import java.util.List;
    public class EvalMultiLabelBatchOpTest {
      @Test
      public void testEvalMultiLabelBatchOp() throws Exception {
        List <Row> df = Arrays.asList(
          Row.of("{"object":"[0.0, 1.0]"}", "{"object":"[0.0, 2.0]"}"),
          Row.of("{"object":"[0.0, 2.0]"}", "{"object":"[0.0, 1.0]"}"),
          Row.of("{"object":"[]"}", "{"object":"[0.0]"}"),
          Row.of("{"object":"[2.0]"}", "{"object":"[2.0]"}"),
          Row.of("{"object":"[2.0, 0.0]"}", "{"object":"[2.0, 0.0]"}"),
          Row.of("{"object":"[0.0, 1.0, 2.0]"}", "{"object":"[0.0, 1.0]"}"),
          Row.of("{"object":"[1.0]"}", "{"object":"[1.0, 2.0]"}")
        );
        BatchOperator <?> source = new MemSourceBatchOp(df, "pred string, label string");
        EvalMultiLabelBatchOp evalMultiLabelBatchOp =
          new EvalMultiLabelBatchOp().setLabelCol("label").setPredictionCol(
          "pred").linkFrom(source);
        MultiLabelMetrics metrics = evalMultiLabelBatchOp.collectMetrics();
        System.out.println(metrics.toString());
      }
    }
    -------------------------------- Metrics: --------------------------------
    microPrecision:0.7273
    microF1:0.6957
    subsetAccuracy:0.2857
    precision:0.6667
    recall:0.6429
    accuracy:0.5476
    f1:0.6381
    microRecall:0.6667
    hammingLoss:0.3333

     

     

  • 相关阅读:
    【转载】S5PV210 三星官方原理图(包含核心板和底板)
    关于飞凌技术支持更改通知
    【收集】几个gooogleman嵌入式联盟比较好的帖子
    分析我的OV3640 打开软件立即导致PDA死机的原因
    【喜讯】嘿嘿,Real6410/TE6410/OK6410 支持jlink V8+RVDS2.2 仿真调试了
    【转载】三星A8 S5pV210 硬件设计指南S5PV210_Hardware Design Guide_Rev1.0
    【爆料】公布一个经典6410 原理图(orcad)+PCB(candence)图—— real6410 PCB 大全(核心板+底板)
    【呜呼】大学生烧毕业证书谁的错?!
    【转载】三星A8 S5pV210 硬件设计指南S5PV210_Hardware Design Guide_Rev1.0
    【转载】2440的GPIO模拟IIC程序
  • 原文地址:https://www.cnblogs.com/qiu-hua/p/14902375.html
Copyright © 2020-2023  润新知