Linear models that can be used in sklearn are: LinearRegression, Ridge, Lasso
1 Ridge
Ridge is a model with L2 regularization added
In the fitting process, it is usually inclined to make the weights as small as possible, and finally construct a model with all parameters relatively small.
Because it is generally believed that the model with small parameter values is simpler, can adapt to different data sets, and also avoids overfitting to a certain extent.
It can be imagined that for a linear regression equation, if the parameters are very large, as long as the data shifts a little, it will have a great impact on the results; but if the parameters are small enough, the data shifts too much will not affect the results at all. What is the impact, a professional term is "strong anti-disturbance ability"
Plot the coefficients
model = Ridge().fit(train_X, train_y_ln)
print('intercept:'+ str(model.intercept_))
sns.barplot(abs(model.coef_), continuous_feature_names)
2 Lasso
Lasso is a model with L1 regularization added
L1 regularization helps to generate a sparse weight matrix, which can then be usedFeature selection。
Reference: https://tianchi.aliyun.com/notebook-ai/detail?spm=5176.12586969.1002.24.1cd8593aLNK3uJ&postId=95460