多应用+插件架构,代码干净,支持一键云编译,码云点赞13K star,4.8-4.12 预售价格198元 广告
## 分类报告 > 用于计算主分类器度量的类:精度,召回,F1分数和支持。 ***** ### 报告 要生成报告,您必须提供以下参数: `$actualLabels` - (array)真实样本标签 `$predictLabels` - (array)预测标签(来自测试组的e.x.) ``` use Phpml\Metric\ClassificationReport; $actualLabels = ['cat', 'ant', 'bird', 'bird', 'bird']; $predictedLabels = ['cat', 'cat', 'bird', 'bird', 'ant']; $report = new ClassificationReport($actualLabels, $predictedLabels); ``` 您可以选择提供以下参数: $ average - (int)多类分类的平均方法 * ClassificationReport::MICRO_AVERAGE = 1 * ClassificationReport::MACRO_AVERAGE = 2 (默认) * ClassificationReport::WEIGHTED_AVERAGE = 3 ## 度量 创建报告后,您可以绘制其各自的指标: * precision (`getPrecision()`) - 检索到的相关实例的一部分 * recall (`getRecall()`) - 检索到的相关实例的一部分 * F1 score (`getF1score()`) - 测量测试的准确性 * support (`getSupport()`) - 测试样本数 ``` $precision = $report->getPrecision(); // $precision = ['cat' => 0.5, 'ant' => 0.0, 'bird' => 1.0]; ``` ***** ## 例 ``` use Phpml\Metric\ClassificationReport; $actualLabels = ['cat', 'ant', 'bird', 'bird', 'bird']; $predictedLabels = ['cat', 'cat', 'bird', 'bird', 'ant']; $report = new ClassificationReport($actualLabels, $predictedLabels); $report->getPrecision(); // ['cat' => 0.5, 'ant' => 0.0, 'bird' => 1.0] $report->getRecall(); // ['cat' => 1.0, 'ant' => 0.0, 'bird' => 0.67] $report->getF1score(); // ['cat' => 0.67, 'ant' => 0.0, 'bird' => 0.80] $report->getSupport(); // ['cat' => 1, 'ant' => 1, 'bird' => 3] $report->getAverage(); // ['precision' => 0.5, 'recall' => 0.56, 'f1score' => 0.49] ```