逻辑回归模型
By Neeta Ganamukhi
Neeta Ganamukhi着
Department of Business and Economics
商业与经济系
Abstract: The main aim of this term paper is to describe the Logistic Regression Algorithm, a supervised model used for classification. The paper describes Logistic Regression for Machine Learning, types of Logistic Regression and hypothesis, multinomial and ordinal are not covered in this paper. The paper also covers Sigmoid function, Decision Boundary Data Preparation, Cost function, Gradient descent, Difference between linear and logistic regression, and Pros and cons of Logistic Regression.
摘要:本学期论文的主要目的是描述Logistic回归算法,这是一种用于分类的监督模型。 本文描述了机器学习的Logistic回归,本文不涉及Logistic回归和假设的类型,多项式和序数。 本文还介绍了Sigmoid函数,决策边界数据准备,成本函数,梯度下降,线性和逻辑回归之间的差异以及Logistic回归的优缺点。
Keywords — Logistic Regression, Sigmoid function,Cost function, Gradient descent etc.,
关键字— Logistic回归,Sigmoid函数,Cost函数,梯度下降等,
Introduction
介绍
Every machine learning algorithm performs best under a given set of conditions. To ensure good performance, we must know which algorithm to use depending on the problem at hand. We cannot just use one algorithm for all problems. For example: Linear regression algorithm cannot be applied on a categorical dependent variable. This is where Logistic Regression comes in. Logistic regression is a supervised learning classification algorithm used to predict the probability of a target variable. It extends the idea of linear regression to situation where outcome variable is categorical. In simple words, the dependent variable is binary in nature having data coded as either 1 (stands for success/yes) or 0 (stands for failure/no).
在给定的条件下,每种机器学习算法都表现最佳。 为了确保良好的性能,我们必须根据手头的问题知道使用哪种算法。 我们不能仅对所有问题使用一种算法。 例如:线性回归算法不能应用于分类因变量。 这就是Logistic回归的用处。Logistic回归是一种监督学习分类算法,用于预测目标变量的概率。 它将线性回归的概念扩展到结果变量是分类的情况。 简而言之,因变量本质上是二进制的,其数据编码为1(代表成功/是)或0(代表失败/否)。
I. WHAT IS LOGISTIC REGRESSION IN MACHINE LEARNING?
I.机器学习中的逻辑回归是什么?
Logistic Regression is the alternative to regression analysis to conduct when the dependent variable has a binary solution. Mathematically, a logistic regression model predicts P(Y=1) as a function of X. Instead of Y as outcome variable (like in regression), we use function of Y called the Logit a.k.a. log odds = log (P(positive)/P(negative)). Logit can be modeled as a linear function of the predictors. It can also be mapped back to a probability, which, in turn, can be mapped to a class. Logit is one of the simplest Machine Learning function that can be used for various classification problems such as spam detection, Diabetes prediction, cancer detection, Online transactions Fraud or not Fraud, Tumor Malignant or Benign etc.
当因变量具有二进制解时,逻辑回归是进行回归分析的替代方法。 数学上,逻辑回归模型将P(Y = 1)预测为X的函数。我们使用Y的函数(称为Logit aka log赔率= log(P(正)/ P(负))。 Logit可以建模为预测变量的线性函数。 也可以将其映射回概率,然后将其映射到一个类别。 Logit是最简单的机器学习功能之一,可用于各种分类问题,例如垃圾邮件检测,糖尿病预测,癌症检测,在线交易欺诈或不欺诈,肿瘤恶性或良性等。
II. TYPES OF LOGISTIC REGRESSION
二。 逻辑回归的类型
Generally, logistic regression means binary logistic regression having binary target variables, but there can be two more categories of target variables that can be predicted by it. Based on those number of categories, Logistic regression can be divided into following types:
通常,逻辑回归是指具有二进制目标变量的二进制逻辑回归,但是可以通过它预测两类以上的目标变量。 根据这些类别的数量,逻辑回归可以分为以下几种类型:
A. Binary or Binomial
A.二元或二项式
B. Multinomial
B.多项式
C. Ordinal
C.序数
A. Binary or Binomial Regression : In such a kind of classification, a dependent variable will have only two possible outcomes either 1 and 0. For example, these variables may represent success or failure, yes or no, win or loss etc. For detailed information, see reference[1]
A. 二元或二项回归:在这种分类中,因变量将只有两个可能的结果1和0。例如,这些变量可能表示成功或失败,是或否,赢或输等。有关详细信息信息,请参阅参考文献[1]
B. Multinomial Regression : In such a kind of classification, dependent variable can have 3 or more possible unordered outcomes or the outcome having no quantitative significance. For example, these variables may represent “Type A” or “Type B” or “Type C”. For detailed information, see reference[2]
B. 多项式回归:在这种分类中,因变量可以具有3个或更多可能的无序结果,或者结果没有定量意义。 例如,这些变量可以表示“类型A”或“类型B”或“类型C”。 有关详细信息,请参见参考文献[2]。
C. Ordinal Regression : In such a kind of classification, dependent variable can have 3 or more possible ordered outcomes or the outcomes having a quantitative significance. For example, these variables may represent “poor” or “good”, “very good”, “Excellent” and each category can have the scores like 0,1,2,3.For detailed information, see reference[3]
C. 有序回归:在这种分类中,因变量可以具有3个或更多可能的有序结果或具有定量意义的结果。 例如,这些变量可以表示“差”或“好”,“非常好”,“优秀”,并且每个类别的得分都可以为0、1、2、3。有关详细信息,请参见参考文献[3]。
III. LOGISTIC FUNCTION
三, 物流功能
Logistic regression is named for the function used at the core of the method, the logistic function. The logistic function, also called the sigmoid function was developed by statisticians to describe properties of population growth in ecology, rising quickly and maxing out at the carrying capacity of the environment. It’s an S-shaped curve that can take any real-valued number and map it into a value between 0 and 1, but never exactly at those limits.
Logistic回归是为方法核心使用的函数Logistic函数而命名的。 统计学家开发了逻辑函数 ,也称为乙状结肠函数,以描述生态中人口增长的特性,该特性Swift上升并在环境的承载能力最大化。 这是一条S形曲线,可以采用任何实数值并将其映射为0到1之间的一个值,但永远不能精确地位于这些极限处。
IV. WHAT IS SIGMOID FUNCTION?
IV。 什么是SIGMOID功能?
In order to map predicted values to probabilities, we use the Sigmoid function. The function maps any real value into another value between 0 and 1. In machine learning, we use sigmoid to map predictions to probabilities. The sigmoid curve can be represented with the help of following graph. We can see the values of y-axis lie between 0 and 1 and crosses the axis at 0.5.
为了将预测值映射到概率,我们使用Sigmoid函数。 该函数将任何实际值映射到0到1之间的另一个值。在机器学习中,我们使用Sigmoid将预测映射到概率。 可以通过下图来表示S型曲线。 我们可以看到y轴的值介于0和1之间,并且与该轴的交点为0.5。
The following equation is used to presents Sigmoid function: 1/1+e^-z .The classes can be divided into positive or negative. The output is the probability of positive class if it lies between 0 and 1. For detailed information, see reference[4] Now, let us understand the application of sigmoid function in non-linear classification.
以下方程式用于表示Sigmoid函数: 1/1 + e ^ -z 。可以将这些类分为正数或负数。 如果输出在0到1之间,则为正分类的概率。有关详细信息,请参见参考资料[4]。现在,让我们了解S型函数在非线性分类中的应用。
V. LOGISTIC REGRESSION HYPOTHESES
V.逻辑回归假设
When using Linear regression, we use a formula of the hypothesis i.e.
使用线性回归时,我们使用假设的公式,即
For Logistic Regression, there is a little modification in the equation i.e.
对于Logistic回归,方程中有一些修改,即
We have expected that hypothesis will give values between 0 and 1.
我们已经预期该假设将给出0到1之间的值。
Thus, hypothesis for Logistic Regression can be represented as,
因此,逻辑回归假设可以表示为:
We know that, the simplest form of logistic regression is binary or binomial logistic regression in which the target or dependent variable can have only 2 possible outcomes either 1 or 0. It allows us to model a relationship between multiple predictor variables and a binary/binomial target variable. Hence, the above equation can be represented as,
我们知道,逻辑回归的最简单形式是二进制或二项式逻辑回归,其中目标变量或因变量只能具有2个可能的结果,即1或0。这使我们可以对多个预测变量与二进制/二项式之间的关系进行建模。目标变量。 因此,以上等式可以表示为:
Here,g is the logistic or sigmoid function which can be given as follows:
在这里,g是逻辑或S型函数,可以给出如下:
We can call a Logistic Regression a Linear Regression model, but the Logistic Regression uses a complex cost function called Sigmoid function instead of a linear function. The hypothesis of logistic regression limits this sigmoid function between 0 and 1. Therefore linear functions fail to represent it as it can have a value greater than 1 or less than 0 which is not possible as per the hypothesis of logistic regression. In case of logistic regression, the linear function is basically used as an input to another function such as