Day two
LOGISTIC REGRESSION
Linear regression & Logistic regression
- The purpose of linear regression is to predict a continuous variable with input .
- Logistic regression mainly means to classify different categories with input .
The principle of logistic regression
LIke linear regression, there is also a predictive function (called classification function, linear or non-linear function) in logistic regression.
-
first, compute the predictive function
-
second, call the sigmoid function
-
finally, get the loss function and optimize parameters
loss function
optimization
-
batch gradient descent
(repeat until convergence) -
stochastic gradient descent
for i to N:
(repeat until convergence)
-
Regularization
Model evaluation index
-
receiver operating characteristic curve(roc)
the horizontal axis: false positive rate(fpr)
the vertical axis: true positive rate(tpr)
every point corresponds to a thresthold -
area under curve(auc)
auc is related to roc
Advantages
- easy to compute, understand and implement
- efficient in time and memory
- robustness is good for small noise in data
Disadvantages
- underfitting happens easily
- classification accuracy is not high
- not work well for a big feature space
Sample imbalance issue
The logistic regression model ignores the feature of small sample category.
- solutions
- oversampling, undersampling and combined sampling
- weight adjustment
- kernel function correction
- model correction
sklearn parameters
sklearn.linear_model.LogisticRegression(penalty='l2', dual=False, tol=0.0001, C=1.0, fit_intercept=True, intercept_scaling=1, class_weight=None, random_state=None, solver='liblinear', max_iter=100, multi_class='ovr', verbose=0, warm_start=False, n_jobs=1)
- regularization parameter: penalty(‘l1’ or ‘l2’)
- optimization: solver(‘liblinear’ ‘lbfgs’ ‘newton-cg’ ‘sag’)
- classification: multi_class(‘ovr’ or ‘multinomial’)
- class weight: class_weight
- sample weight: sample_weight
REFERENCE
[1] https://blog.csdn.net/touch_dream/article/details/79371462
[2] https://yoyoyohamapi.gitbooks.io/mit-ml/content/逻辑回归/articles/利用正规化解决过拟合问题.html
[3] https://www.cnblogs.com/dlml/p/4403482.html
[4] https://blog.csdn.net/u011088579/article/details/80654165
[5] https://blog.csdn.net/sun_shengyun/article/details/53811483