一份非常全面的机器学习分类与回归算法的评估指标汇总

深度学习模型评价指标(RMSE、MSE、MAE、MAPE、SMAPE) MSE(均方误差Mean Square Error) 阅读详情

PS:文末附有练习题

读完机器学习算法尝试之后,你已经知道了什么是欠拟合和过拟合、偏差和方差以及贝叶斯误差。在这篇给大家介绍一些机器学习中离线评估模型性能的一些指标。

当我们训练得到了多个模型之后,如何衡量这几个模型的性能呢?也就是说我们需要一个能够衡量模型“好坏”的标准,我们称之为评估指标。在对比不同的模型效果时,使用不同的评估指标往往会导致不同的结论,这也就是说模型的效果好坏是相对的。

针对不同类型的学习任务,我们有不同的评估指标,这里我们来介绍最常见的分类与回归算法的一些评估指标。

分类指标

生活中大多数的分类问题都属于二分类问题,所以这里以二分类为例,来说明下分类相关的一些指标。

正式介绍指标之前,先来普及一些基本概念:有时候“阳性”、“真”、“正类”、“1” 指的是一回事,“阴性”、“假”、“负类”、“0”指的也是一回事。例如模型对这个样本的预测结果为 1,可以认为模型对这个样本的预测结果为真、或者为正类、或者为阳性,其实说的都是一个意思。

混淆矩阵

混淆矩阵(confusion matrix)是一个评估分类问题常用的工具,对于 k 元分类,其实它就是一个k x k的表格,用来记录分类器的预测结果。对于常见的二分类,它的混淆矩阵是 2x2 的。

在二分类中,可以将样本根据其真实结果和模型的预测结果的组合划分为真阳性(true positive,TP)、真阴性(true negative,TN)、假阳性(false positive,FP)、假阴性(false negative,FN)。根据 TP、TN、FP、FN 即可得到二分类的混淆矩阵。

准确度

准确率(accuracy)是指模型预测正确(包括预测为真正确和预测为假正确)的样本数量占总样本数量的比例,即

其中,表示模型正确分类的样本个数,表示所有的样本个数。

在二分类中,准确率可以通过下面的计算公式得到。

准确率是分类问题中的一个最简单也最直观的评估指标,但是准确率存在一些局限性。比如,在二分类中,当负样本占比 99 %时,如果模型把所有样本都预测为负样本也能获得 99% 的准确率。虽然准确率看起来很高,但是其实这个模型时没有用,因为它找不出一个正样本。

精确率

精确率(precision)是指模型预测为真,实际也为真的样本数量占模型预测所有为真的样本数量的比例,即

举例来说明,比如警察要抓小偷,抓了 10 个人,其中有 6 个人是小偷,那么精确率就是 6/10 = 0.6。

召回率

机器学习中的评价指标(分类指标评Accuracy、Precision、Recall、F1-score、ROC、AUC )(回归指标评价MSE、RMSE、MAE、MAPE、R Squared) 文章目录1.机器学习中的评价指标基础(一)分类指标评价1.Accuracy2.Precision、查准率3.Recall、查全率4.F1-score举个例子:5.ROC6.AUC(二)回归指标评价1.均方误差(MSE)2.均方根误差(RMSE)3.MAE(平均绝对误差)4.MAPE5.R Squared 1.机器学习中的评价指标 简要介绍精度、精确率、召回率、P-R曲线、F1 值、TPR、FPR、... 阅读详情

相关推荐

机器学习之分类与回归的常见评价指标

详细介绍了机器学习中分类和回归算法的常见评价指标,如分类问题的精确率、准确率、召回率、F1值及ROC曲线;回归问题的决定系数、均方误差、平均绝对误差等。利用python实现评价指标的计算。

m0_69435474的博客 3806

模型评估指标详解:分类与回归场景

不同的模型评估指标适用于不同的场景和任务。在分类问题中,我们需要综合考虑准确率、精确率、召回率、F1 值、ROC 曲线和 AUC 值等指标,以全面评估模型的性能;在回归问题中,均方误差、均方根误差、平均绝对误差和决定系数等指标可以帮助我们衡量模型的预测准确性和拟合优度。在实际应用中,我们应根据数据特性、业务需求选择合适的评估指标,并结合多指标进行综合评估,同时注意评估集的选择,以确保评估结果的可靠性。

ZhShy 1206

python使用numpy包编写自定义函数计算MAPE(平均绝对百分比误差)指标mean absolute percentage error (MAPE)、MAPE指标解读、MAPE指标使用的注意事项

python使用numpy包编写自定义函数计算MAPE(平均绝对百分比误差)指标mean absolute percentage error (MAPE)、MAPE指标解读、MAPE指标使用的注意事项

data+scenario+science+insight 3859

机器学习框架及评估指标详解

目录 机器学习的步骤 train_test_split函数的详解 机器学习评估指标 分类模型评估指标 混淆矩阵 ROC曲线 利用ROC的其他评估标准 Python 绘制ROC曲线求解AUC模板代码 错误率 精度 查准率、查全率 P-R曲线 Python绘制P-R曲线模板代码 平衡点(BEP) F1度量 Python求解F1_score代码 回归模型评估指标 均方误差 MAE(平均绝对误差) MAPE(平均绝对百分比误差) RMSE(均方根误差) R Square(

迷茫与徘徊只会让你陷入绝境,欢迎私信博主,带你开始提升变现价值! 6740

几种MAPE的实现方式

目录方法一 (label 中有NaN值)方法二(label 中有零值)方法三 (限制过大过小值) 方法一 (label 中有NaN值) 这种方式是为了防止label里面有NaN值,但没考虑是否为零值。这里以pytorch进行举例。 def masked_mape(preds, labels, null_val=np.nan): if np.isnan(null_val): mask = ~torch.isnan(labels) else: mask = (labels!=null_val) mask = mask.float()

从“看不懂Sansen”到亲手搭建:一个Class AB输出级+浮动电压源的保姆级设计复盘

本文详细记录了从理论困惑到实践突破的Class AB输出级与浮动电压源设计全过程。通过电流镜调试、恒定跨导优化及版图匹配等关键步骤,作者实现了高性能运放设计,并分享了从仿真到实测的宝贵经验,为模拟电路初学者提供实用指导。

weixin_33737774的博客 888

工业金属表面缺陷检测:4种光学成像方案(明/暗/漫/背光)选型与实测对比

本文深入探讨工业金属表面缺陷检测中的4种光学成像方案(明/暗/漫/背光),详细解析其物理原理、适用场景及实测效果。通过对比不同照明方案在铝合金轮毂、不锈钢餐具等实际工业场景中的表现,提供科学的选型决策树,帮助提升缺陷检出率至99%以上,为计算机视觉在工业质检领域的应用提供实用指南。

weixin_33624741的博客 394

信息学奥赛一本通高手训练1680:序列

题目 代码 #include<cstdio> #include<iostream> #include<cmath> #define LL long long using namespace std; const LL N = 1400000+7; const LL mod = 1e9+7; int n, t; LL pos[N], sum[N], ans[N]; struct node{ LL ll, rr; }a[N]; int main(){ p

qingfeixueyue的博客 472

CH340以及CH系列USB转串口驱动下载

在之前使用USB转串口时,很多时候大家可能会不知道去哪下载驱动,然后百度随便下载一个,但往往鱼龙混杂且版本不一,所以今天特意整理一下CH340驱动以及CH系列的官方驱动下载地址,方便大家进行下载也方便自己后期查找,所有链接皆指向官方下载链接,每次下载都可获取官方当前最新驱动。 CH340/CH341 Windows驱动下载链接:CH341SER.EXE下载链接 Linux驱动下载链接:CH341SER_LINUX.ZIP下载链接 Andr...

OIDCAT的博客 4万+

Windows Server双机热备实战:用IIS+ARR+NLB搭建高可用Web服务(附避坑指南)

本文详细介绍了在Windows Server环境下,利用IIS、ARR(Application Request Routing)和NLB(Network Load Balancing)构建高可用Web服务的实战方案。通过双机热备架构,实现从网络层到应用层的全面冗余与智能流量分发,并提供了关键的配置步骤、常见避坑指南及性能调优建议,确保企业级Web服务的连续性与可靠性。

weixin_29210759的博客 394

PID控制算法实践应用(一):PID算法的离散化

由于计算机控制是一种采样控制,它只能根据采样时刻的偏差值计算控制量。因此,连续PID控制算法不能直接使用,需要采用离散化方法。

m0_72676510的博客 2603

Python爬虫实战:使用最新技术抓取采购网招标公告信息

本文将详细介绍如何使用Python最新爬虫技术构建一个高效的采购网招标公告信息抓取系统。我们将从爬虫基础概念讲起,逐步深入到高级技巧,包括异步处理、反爬虫对策、数据解析与存储等,并提供完整的代码实现。本文旨在为读者提供一套完整的网络数据采集解决方案,适用于各类政府采购平台和商业招标网站。网络爬虫(Web Crawler)是一种自动抓取互联网信息的程序或脚本,它们按照一定的规则,自动地浏览万维网并提取所需数据。在现代商业环境中,爬虫技术广泛应用于价格监控、竞争情报收集、市场研究等领域。

2201_76125261的博客 1626

手把手教你ensp仿真搭建校园网(含防火墙及无线网络)系列(一)校园网核心交换机配置

本系列博客将带你从零开始,使用 华为 eNSP(Enterprise Network Simulation Platform) 仿真搭建一个完整的校园网络,涵盖 核心层、汇聚层、接入层、防火墙安全策略、无线AC+AP组网 等实战场景。无论你是网络初学者还是希望深化实战经验的工程师,都能通过本教程掌握企业级网络的规划、配置与排错技巧。

echo的博客 3870

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

上一篇: 干货!程序员如何优雅的挣零花钱?
下一篇: 股票跌得猝不及防,是因为你还不懂这个技术!
AI女神
博客等级 码龄8年 78粉丝 71原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址