The text provides a comprehensive overview of linear models, non-linearity handling, and regularization in machine learning using scikit-learn. It covers concepts like linear regression, logistic regression, feature engineering for non-linear problems, and the application of regularization techniques to control model complexity. Multiple code examples and visualizations are included to illustrate the various concepts.
“`html
Linear models, handling non-linearity, and regularization
This is the fourth post in my scikit-learn tutorial series. If you didn’t catch them, I strongly recommend my first two posts — it’ll be way easier to follow along:
Sklearn tutorial
This 4th module introduces the concept of linear models, using the infamous linear regression and logistic regression models as working examples.
Linear models
Linear models are models that “fit” or “learn” by setting coefficients such that they eventually only rely on a linear combination of the input features. In the case of regression problems, one of the simplest and well known linear model is the linear regression. In the case of classification problem, the simplest and well known linear model is the logistic regression.
Linear model for regression: linear regression
Linear regression is the most well known linear regression model. The idea is to approximate as best as possible the output y from a linear combination of the inputs f_i.
Linear model for classification: logistic regression
The equivalent of linear regression for classification problem is logistic regression.
Handling non-linear data
In addition to using natively non-linear models, we can still use our linear models by creating new features in the input data that hold some non-linearity. A good simple example is a polynomial regression as introduced above.
Regularization
Regularization consists in changing or tweaking the way models learn, usually in changing the objective/cost function, in order to keep their complexity not too high. Mathematically, it is often implemented by adding a term in the cost function of the problem.
Wrapup
In this 4th post, we saw the most important linear models namely linear regression and logistic regression, how we can handle non-linear problems while using such linear models by creating new features, and how regularization can help control the complexity of models by adding a regularization term in the objective function.
If you want to evolve your company with AI, stay competitive, use for your advantage Sklearn Tutorial: Module 4.
“`