当我们必须预测分类(或离散)结果的值时,我们使用逻辑回归。我相信我们使用线性回归来预测给定输入值的结果值。
那么,这两种方法有什么不同呢?
当我们必须预测分类(或离散)结果的值时,我们使用逻辑回归。我相信我们使用线性回归来预测给定输入值的结果值。
那么,这两种方法有什么不同呢?
当前回答
简单地说,如果在线性回归模型中有更多的测试用例到达,这些测试用例远离预测y=1和y=0的阈值(例如=0.5)。在这种情况下,假设就会改变,变得更糟。因此,线性回归模型不适用于分类问题。
另一个问题是,如果分类是y=0和y=1, h(x)可以是> 1或< 0。因此,我们使用Logistic回归0<=h(x)<=1。
其他回答
基本区别:
线性回归基本上是一个回归模型,这意味着它将给出一个函数的非离散/连续输出。这个方法给出了值。例如,给定x, f(x)是多少
例如,给定一个由不同因素组成的训练集和训练后的房地产价格,我们可以提供所需的因素来确定房地产价格。
逻辑回归基本上是一种二元分类算法,这意味着这里函数的输出值是离散的。例如:对于给定的x,如果f(x)>阈值将其分类为1,否则将其分类为0。
例如,给定一组脑瘤大小作为训练数据,我们可以使用大小作为输入来确定它是良性肿瘤还是恶性肿瘤。因此这里的输出不是0就是1。
这里的函数基本上是假设函数
简单地说,线性回归是一种回归算法,它输出一个可能连续和无限的值;逻辑回归被认为是一种二进制分类器算法,它输出输入属于标签(0或1)的“概率”。
Linear regression output as probabilities It's tempting to use the linear regression output as probabilities but it's a mistake because the output can be negative, and greater than 1 whereas probability can not. As regression might actually produce probabilities that could be less than 0, or even bigger than 1, logistic regression was introduced. Source: http://gerardnico.com/wiki/data_mining/simple_logistic_regression Outcome In linear regression, the outcome (dependent variable) is continuous. It can have any one of an infinite number of possible values. In logistic regression, the outcome (dependent variable) has only a limited number of possible values. The dependent variable Logistic regression is used when the response variable is categorical in nature. For instance, yes/no, true/false, red/green/blue, 1st/2nd/3rd/4th, etc. Linear regression is used when your response variable is continuous. For instance, weight, height, number of hours, etc. Equation Linear regression gives an equation which is of the form Y = mX + C, means equation with degree 1. However, logistic regression gives an equation which is of the form Y = eX + e-X Coefficient interpretation In linear regression, the coefficient interpretation of independent variables are quite straightforward (i.e. holding all other variables constant, with a unit increase in this variable, the dependent variable is expected to increase/decrease by xxx). However, in logistic regression, depends on the family (binomial, Poisson, etc.) and link (log, logit, inverse-log, etc.) you use, the interpretation is different. Error minimization technique Linear regression uses ordinary least squares method to minimise the errors and arrive at a best possible fit, while logistic regression uses maximum likelihood method to arrive at the solution. Linear regression is usually solved by minimizing the least squares error of the model to the data, therefore large errors are penalized quadratically. Logistic regression is just the opposite. Using the logistic loss function causes large errors to be penalized to an asymptotically constant. Consider linear regression on categorical {0, 1} outcomes to see why this is a problem. If your model predicts the outcome is 38, when the truth is 1, you've lost nothing. Linear regression would try to reduce that 38, logistic wouldn't (as much)2.
Regression means continuous variable, Linear means there is linear relation between y and x. Ex= You are trying to predict salary from no of years of experience. So here salary is independent variable(y) and yrs of experience is dependent variable(x). y=b0+ b1*x1 We are trying to find optimum value of constant b0 and b1 which will give us best fitting line for your observation data. It is a equation of line which gives continuous value from x=0 to very large value. This line is called Linear regression model.
逻辑回归是一种分类技术。不要被术语回归所误导。这里我们预测y=0还是1。
在这里,我们首先需要从下面的公式中找出给定x的p(y=1) (y=1的w概率)。
概率p通过下面的公式与y相关
Ex=我们可以将患癌几率超过50%的肿瘤分类为1,将患癌几率低于50%的肿瘤分类为0。
这里红点被预测为0,而绿点被预测为1。
在线性回归中,结果(因变量)是连续的。它可以有无限个可能值中的任意一个。在逻辑回归中,结果(因变量)只有有限数量的可能值。
例如,如果X包含以平方英尺为单位的房屋面积,而Y包含这些房屋的相应销售价格,您可以使用线性回归来预测销售价格作为房屋大小的函数。虽然可能的销售价格实际上可能没有任何值,但有很多可能的值,因此可以选择线性回归模型。
相反,如果你想根据房子的大小来预测房子是否会卖到20万美元以上,你会使用逻辑回归。可能的输出是Yes,房子将以超过20万美元的价格出售,或者No,房子不会。