机器学习~分类与回归异同

机器学习 --- 1. 线性回归与分类, 解决与区别 机器学习可以解决很多问题,其中最为重要的两个是 回归与分类。 这两个问题怎么解决, 它们之间又有什么区别呢? 以下举几个简单的例子,以给大家一个概念 1. 线性回归 回归分析常用于分析两个变量X和Y 之间的关系。 比如 X=房子大小 和 Y=房价 之间的关系, X=(公园人流量,公园门票票价) 与 Y=(公园收入) 之间的关系等等。 那么你的数据点在图上可以这么看 现在你想找到 房 阅读详情

一篇来着外文网站的关于分类与回归异同的解释。

Difference Between Classification and Regression in Machine Learning

Fundamentally, classification is about predicting a label and regression is about predicting a quantity.

I often see questions such as:

How do I calculate accuracy for my regression problem?

Questions like this are a symptom of not truly understanding the difference between classification and regression and what accuracy is trying to measure.

In this tutorial, you will discover the differences between classification and regression.

After completing this tutorial, you will know:

  • That predictive modeling is about the problem of learning a mapping function from inputs to outputs called function approximation.
  • That classification is the problem of predicting a discrete class label output for an example.
  • That regression is the problem of predicting a continuous quantity output for an example.

Let’s get started.

Tutorial Overview

This tutorial is divided into 5 parts; they are:

  1. Function Approximation
  2. Classification
  3. Regression
  4. Classification vs Regression
  5. Converting Between Classification and Regression Problems

Function Approximation

Predictive modeling is the problem of developing a model using historical data to make a prediction on new data where we do not have the answer.

For more on predictive modeling, see the post:

Predictive modeling can be described as the mathematical problem of approximating a mapping function (f) from input variables (X) to output variables (y). This is called the problem of function approximation.

The job of the modeling algorithm is to find the best mapping function we can given the time and resources available.

For more on approximating functions in applied machine learning, see the post:

Generally, we can divide all function approximation tasks into classification tasks and regression tasks.

Classification Predictive Modeling

Classification predictive modeling is the task of approximating a mapping function (f) from input variables (X) to discrete output variables (y).

The output variables are often called labels or categories. The mapping function predicts the class or category for a given observation.

For example, an email of text can be classified as belonging to one of two classes: “spam“and “not spam“.

  • A classification problem requires that examples be classified into one of two or more classes.
  • A classification can have real-valued or discrete input variables.
  • A problem with two classes is often called a two-class or binary classification problem.
  • A problem with more than two classes is often called a multi-class classification problem.
  • A problem where an example is assigned multiple classes is called a multi-label classification problem.

It is common for classification models to predict a continuous value as the probability of a given example belonging to each output class. The probabilities can be interpreted as the likelihood or confidence of a given example belonging to each class. A predicted probability can be converted into a class value by selecting the class label that has the highest probability.

For example, a specific email of text may be assigned the probabilities of 0.1 as being “spam” and 0.9 as being “not spam”. We can convert these probabilities to a class label by selecting the “not spam” label as it has the highest predicted likelihood.

There are many ways to estimate the skill of a classification predictive model, but perhaps the most common is to calculate the classification accuracy.

The classification accuracy is the percentage of correctly classified examples out of all predictions made.

For example, if a classification predictive model made 5 predictions and 3 of them were correct and 2 of them were incorrect, then the classification accuracy of the model based on just these predictions would be:

1

2

3

accuracy = correct predictions / total predictions * 100

accuracy = 3 / 5 * 100

accuracy = 60%

An algorithm that is capable of learning a classification predictive model is called a classification algorithm.

Regression Predictive Modeling

Regression predictive modeling is the task of approximating a mapping function (f) from input variables (X) to a continuous output variable (y).

A continuous output variable is a real-value, such as an integer or floating point value. These are often quantities, such as amounts and sizes.

For example, a house may be predicted to sell for a specific dollar value, perhaps in the range of $100,000 to $200,000.

  • A regression problem requires the prediction of a quantity.
  • A regression can have real valued or discrete input variables.
  • A problem with multiple input variables is often called a multivariate regression problem.
  • A regression problem where input variables are ordered by time is called a time series forecasting problem.

Because a regression predictive model predicts a quantity, the skill of the model must be reported as an error in those predictions.

There are many ways to estimate the skill of a regression predictive model, but perhaps the most common is to calculate the root mean squared error, abbreviated by the acronym RMSE.

For example, if a regression predictive model made 2 predictions, one of 1.5 where the expected value is 1.0 and another of 3.3 and the expected value is 3.0, then the RMSE would be:

1

2

3

4

5

RMSE = sqrt(average(error^2))

RMSE = sqrt(((1.0 - 1.5)^2 + (3.0 - 3.3)^2) / 2)

RMSE = sqrt((0.25 + 0.09) / 2)

RMSE = sqrt(0.17)

RMSE = 0.412

A benefit of RMSE is that the units of the error score are in the same units as the predicted value.

An algorithm that is capable of learning a regression predictive model is called a regression algorithm.

Some algorithms have the word “regression” in their name, such as linear regression and logistic regression, which can make things confusing because linear regression is a regression algorithm whereas logistic regression is a classification algorithm.

Classification vs Regression

Classification predictive modeling problems are different from regression predictive modeling problems.

  • Classification is the task of predicting a discrete class label.
  • Regression is the task of predicting a continuous quantity.

There is some overlap between the algorithms for classification and regression; for example:

  • A classification algorithm may predict a continuous value, but the continuous value is in the form of a probability for a class label.
  • A regression algorithm may predict a discrete value, but the discrete value in the form of an integer quantity.

Some algorithms can be used for both classification and regression with small modifications, such as decision trees and artificial neural networks. Some algorithms cannot, or cannot easily be used for both problem types, such as linear regression for regression predictive modeling and logistic regression for classification predictive modeling.

Importantly, the way that we evaluate classification and regression predictions varies and does not overlap, for example:

  • Classification predictions can be evaluated using accuracy, whereas regression predictions cannot.
  • Regression predictions can be evaluated using root mean squared error, whereas classification predictions cannot.

Convert Between Classification and Regression Problems

In some cases, it is possible to convert a regression problem to a classification problem. For example, the quantity to be predicted could be converted into discrete buckets.

For example, amounts in a continuous range between $0 and $100 could be converted into 2 buckets:

  • Class 0: $0 to $49
  • Class 1: $50 to $100

This is often called discretization and the resulting output variable is a classification where the labels have an ordered relationship (called ordinal).

In some cases, a classification problem can be converted to a regression problem. For example, a label can be converted into a continuous range.

Some algorithms do this already by predicting a probability for each class that in turn could be scaled to a specific range:

1

quantity = min + probability * range

Alternately, class values can be ordered and mapped to a continuous range:

  • $0 to $49 for Class 1
  • $50 to $100 for Class 2

If the class labels in the classification problem do not have a natural ordinal relationship, the conversion from classification to regression may result in surprising or poor performance as the model may learn a false or non-existent mapping from inputs to the continuous output range.

Further Reading

This section provides more resources on the topic if you are looking to go deeper.

Summary

In this tutorial, you discovered the difference between classification and regression problems.

Specifically, you learned:

  • That predictive modeling is about the problem of learning a mapping function from inputs to outputs called function approximation.
  • That classification is the problem of predicting a discrete class label output for an example.
  • That regression is the problem of predicting a continuous quantity output for an example.

 

参考:

https://machinelearningmastery.com/classification-versus-regression-in-machine-learning/

机器学习常用算法总结 常见的机器学习算法总结,LR、SVM、NB、DT、PCA... 阅读详情

相关推荐

【机器学习】【逻辑回归】最大似然估计的推导和求解步骤和梯度上升算法求解

伯努利分布如果随机变量X∈{0, 1},并且相应的概率满足:    P(X=1) = p,0<p<1    P(X=0) = 1 - p则称随机变量X服从参数为p的伯努利分布。则随机变量X的概率密度函数为:逻辑回归    逻辑回归却不是回归算法而是一个分类算法~,线性回归是一个回归算法。逻辑回归的样本数据集是一个离散分布的样本集,逻辑回归的模型值不再是连续值,而是{0, 1}这样的离散...

蔚蓝的天空Tom 1万+

机器学习算法比较:回归与分类

1.背景介绍 机器学习(Machine Learning)是人工智能(Artificial Intelligence)的一个分支,它涉及到计算机程序自动学习和改进其自身的能力。机器学习的主要目标是让计算机程序能够从数据中自主地学习出某些模式,从而实现对新数据的有效处理和分析。 机器学习主要包括两个主要的任务:回归(Regression)和分类(Classification)。回归是一种预测问题...

AI天才研究院 2653

分类算法有哪些? 回归与分类有什么区别?

分类算法有哪些? 回归与分类有什么区别?

m0_51339444的博客 1013

【机器学习小常识】“分类” 与 “回归”的概念及区别详解

目录 1、分类与回归是干嘛的? 2、二者有什么区别 1.输出不同 2.目的不同 3.本质不同 4.结果不同 3、场景应用 1.分类应用 2.回归应用 学过机器学习的人都听过两个概念:分类与回归,特别的,在YOLO v1中,作者也提到了 YOLO之前的物体检测方法通常都转变为了一个分类问题,如 R-CNN、Fast R-CNN 等等。而YOLO将检测变为一个 回归问题。 那么...

水亦心的博客 6万+

【进阶版】机器学习之线性模型介绍及过拟合欠拟合解决方法岭回归、loss回归、elasticnet回归(05)

机器学习算法知识、数据预处理、特征工程、模型评估——原理+案例+代码实战机器学习之Python开源教程——专栏介绍及理论知识概述机器学习框架及评估指标详解Python监督学习之分类算法的概述数据预处理之数据清理,数据集成,数据规约,数据变化和离散化特征工程之One-Hot编码、label-encoding、自定义编码卡方分箱、KS分箱、最优IV分箱、树结构分箱、自定义分箱特征选取之单变量统计、基于模型选择、迭代选择机器学习八大经典分类万能算法——代码+案例项目开源、可直接应用于毕设+科研项目。

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

吴恩达机器学习课程05——Logistic回归

目录分类假设模型代价函数多分类总结感谢大家的支持,如有不妥之处,还请不吝指正~ 分类 需要注意的是,虽然它叫做Logistic回归,但是其实这是一个分类算法。我们首先以二分类来引入这个算法。下面是吴恩达老师在课程中提到的一个例子。 既然是分类,我们就要有分类标准。如上图所示,我们对训练数据使用我们学过的线性回归(用回归算法来做分类任务),那么就会得到上图的拟合直线,由直线可得,我们的标准就是0.5,y>=0.5就预测为1类,否则就预测为0类。从图中所给的数据来看,这么分是很合理的。这是否表示用回

lyy的博客 334

【机器学习】分类与回归

机器学习模型接受一定的输入并生成一个输出。根据输出值的类型可将机器学习模型进一步划分为分类(classification)和回归(regression)。 如果机器学习模型的输出是离散值(discrete values),例如布尔值,那么我们将其称为分类模型。如果输出是连续值(continuous values),那么我们将其称为回归模型。 分类和回归同属于监督学习需要完成的任务。 二者区别 浅层: 两者的的预测目标变量类型不同,连续变量的预测叫回归,离散变量的预测是分类。 中层: 回归问

FDA_sq的博客 3289

逻辑回归与广义线性模型:R语言实现与理解

本文深入探讨了逻辑回归的理论基础和在R语言中的实现方法。我们了解到逻辑回归是一种广义线性模型,用于处理二分类问题,并且需要特殊的统计方法来拟合方程。通过R语言的glm函数,结合个人贷款数据案例,文章展示了如何构建逻辑回归模型,并解释了模型中的系数和几率比。此外,文章还对比了线性回归与逻辑回归的相似之处与不同,并强调了理解模型系数的重要性。

weixin_36178216的博客 388

机器学习——分类和回归的区别

引言   要先了解这两个机器学习最底层概念的名词解释,才能更加清楚知道他们的区别。 1、分类(Classification)   分类的概念比较容易懂,就字面意思,分类就是将某一事物归为某一类。比如,我们把家里的二哈归为狗这一类,我们用0或者1来表示,1表述属于狗,0不属于狗。 2、回归(Regression)   网上有很多的概念,但是窝觉得说的都很复杂。用最简单的话来说,回归,就是对某一件事情的预测。比如,我们通过经验得到,明天的温度可能是35℃。这里的35℃就是我们得到的一个回归值。 3、区别   其

qq_39443703的博客 3095

视频教程-SAP S4 HANA FICO COPA 获利能力分析-ERP

SAP S4 HANA FICO COPA 获利能力分析 从业超过8年的SA...

weixin_33456805的博客 1443

微信小程序反编译实战:用wxappUnpacker获取他人源码的完整流程(附常见报错解决方案)

本文详细解析了微信小程序反编译的完整流程,从缓存提取到源码重构,使用wxappUnpacker工具链实现逆向工程。涵盖环境配置、解密反编译、项目调试等关键步骤,并提供了常见报错解决方案,帮助开发者学习优秀实现方案或进行安全审计。

weixin_42706667的博客 469

【机器学习】逻辑回归

逻辑回归对一个回归或者分类问题,建立代价函数,然后通过优化方法迭代求解出最优的模型参数,然后测试验证我们这个求解的模型的好坏。Logistic回归虽然名字里带“回归”,但是它实际上是一种分类方法,主要用于两分类问题(即输出只有两种,分别代表两个类别)。回归模型中,y是一个定性变量,比如y=0或1,logistic方法主要应用于研究某些事件发生的概率。

Dong_ZH的博客 5192

从零开始STM32cubeide学习

使用的是正点原子的精英版,单片机是STM32F103ZET6,详细讲解完成跑马灯实验

weixin_44077208的博客 2284

机器学习-逻辑回归

该算法特别适合中小规模数据集的二分类问题,后续可以进一步探索其在推荐系统、风险评估等场景的应用。实现了数值稳定的Sigmoid函数,通过值裁剪(-500,500)有效防止了数值溢出问题。在y = 1下,损失要越小则​编辑越大,即​编辑 —>1。在y = 0下,损失要越小则​编辑越小,即​编辑 —>0。构建了完整的梯度上升优化流程,能够有效最大化对数似然函数。添加了自适应学习率机制和收敛判断,提高了训练效率。:添加输入值裁剪(-500,500):S型曲线,输出限定在(0,1):实现随时间衰减的自适应学习率。

2301_80218117的博客 353

Wincc7.5SP1 按钮操作记录(二次确认及语音播报)

Wincc 7.5 SP1 按钮操作记录生成(含二次确认及语音播报) 前面一篇文章已经介绍了“语音播报WINCC报警”,本文是之前功能的延伸,记录按钮操作记录并实现播报。 操作记录及语音播报效果 <创建消息文本> 1. 创建消息文本 消息编号100,消息等级“系统无确认”,消息类型“操作员输入消息”,消息文本“循环水泵启动操作”,其他参数默认。 消息编号101,消息等级“系

徐站的春天 1万+

Tailscale 自建 DERP 中继服务器

Tailscale自建DERP中继服务器

Accompagner的博客 4338

线性回归/逻辑回归/SVM

本文为本人另两篇博客机器学习/计算机视觉(cv)实习面试资料整理(附字节、阿里、腾讯、美团面经)以及机器学习知识点整理下的子内容,有需要的朋友按需自取~ 另:本文只是知识点的整理概括,更为详细的可以参考我每个部分给出的链接~ 目录极大似然估计最小二乘法线性回归概念公式逻辑回归概述优点代价函数总结线性回归和LR对比SVM概述参数核函数常用核函数类型核函数选择多分类lr svm对比相同点不同点 极大似然估计 极大似然估计,通俗理解来说,就是利用已知的样本结果信息,反推最具有可能(最大概率)导致这些样本结果出现

boombung的博客 1593

EDA开源仿真工具verilator入门4:访问函数介绍

访问函数(Visitor Function)是verilator算法实现的主要工作方式之一,本节将介绍一下访问函数。

fangfanglovezhou的博客 1076

softmax回归

学习softmax回归

Timi-chao 1056

句向量(句嵌入)模型sent2vec的训练及应用

本文讨论NLP中的句向量模型(sent2vec),也就是将一个完整的句子映射成一个实数向量的技术。这方面已经发表的成果也是比较多的,本文中所涉及的技术主要源自NAACL 2018的一篇论文,其中提出的sent2vec模型可以理解为词嵌入技术中经典的CBOW方法的扩展,该所谓的扩展中一个重要改进就是引入了n-gram

白马负金羁 1万+

太阳敏感器:卫星姿态控制的“指南针

在卫星姿态控制系统中,太阳敏感器(Sun Sensor) 是至关重要的光学姿态敏感器之一。它通过探测太阳光的方向,为卫星提供关键的姿态参考信息,确保卫星能够正确调整自身方位,维持稳定的对日定向,保障能源供应和任务执行。

ScilogyHunter的博客 1732

线性回归、逻辑回归及SVM

1,回归(Linear Regression) 回归其实就是对已知公式的未知参数进行估计。可以简单的理解为:在给定训练样本点和已知的公式后,对于一个或多个未知参数,机器会自动枚举参数的所有可能取值(对于多个参数要枚举它们的不同组合),直到找到那个最符合样本点分布的参数(或参数组合)。当然,实际运算有一些优化算法,肯定不会去枚举的。注意,回归的前提是公式已知,否则回归无法进行。回归中的公式基本都是数...

qq_43660987的博客 2803

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

机器学习--------逻辑回归

文章目录逻辑回归引入为什么要用sigmoid函数如何求参?-----逻辑回归的损失函数:交叉熵(Cross - Entropy)如何找到损失函数的最小值?------逻辑回归梯度下降小案例:逻辑回归处理鸢尾花数据集小案例:逻辑回归实现验证码数字识别小案例:逻辑回归实现音乐分类器小案例:逻辑回归实现文本情感分析 逻辑回归引入 有监督学习: 线性回归:预测一个连续的值 逻辑回归:预测一个离散的值 举例: 有一家医院希望我们能开发出一款分类器,可以通过数据分析出一块肿瘤到底是良性的,还是恶性的。 1

qq_44241861的博客 551

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

SVM与LR的异同

最近面试很多会聊到SVM, LR(毕竟两个非常成熟的machine learning method)并比较异同。这里复习一下~ 以后慢慢补自己的感悟。。 参考:https://blog.csdn.net/b285795298/article/details/81977271 相同点: 都是分类算法,监督学习算法,判别模型。如果不考虑kernel 函数,两个都是线性分类算法,也就是他们的决策面都...

fukaiqi1010的博客 508

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

机器学习算法(十五):GBDT

关于树的几个ensemble模型的比较(GBDT、xgBoost、lightGBM、RF): https://blog.csdn.net/xwd18280820053/article/details/68927422 1 决策树 决策树详见:https://blog.csdn.net/weixin_39910711/article/details/79468798 ...

weixin_39910711的博客 8777

支持向量机原理(五)线性支持回归

我只是一名搬运工,以下内容来自:刘建平Pinard:https://www.cnblogs.com/pinard 1. 背景   在前四篇里面我们讲到了SVM的线性分类和非线性分类,以及在分类时用到的算法。这些都关注与SVM的分类问题。实际上SVM也可以用于回归模型,本篇就对如何将SVM用于回归模型做一个总结。重点关注SVM分类和SVM回归的相同点与不同点。 2. SVM回归模型的损失函数度量 ...

霖的博客 413
上一篇: C++学习笔记~对项目中缺少dll的简单粗暴解决方式
下一篇: Python学习笔记~临时添加环境变量
zlibo丶
博客等级 码龄10年 13粉丝 29原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值