MACHINE LEARNING LOGISTIC REGRESSION
One of the best known models and one of the simplest in the world of Machine Learning is the Simple Linear Regression Model, linear regression is a statistical model which models a correlation between a dependent or output variable (y) with one or many input variables (x), in this case we will talk about simple linear regression, which means that we will only have a single dependent variable, there is the case in which there is more than one input variable, that is called multiple linear regression.
This regression model returns continuous values, not a label or classification, so we do not need to label our data.
The linear regression model results in a linear function ( is the correlation between the two variables, this linear function, as we know, is a straight line and this line extrapolates and interpolates future or internal values.
To arrive at this linear function, the linear regression model uses statistics as an input and more specifically uses the least squares method.
Where m is my slope, x is each independent value, y is each dependent value, ȳ is the average of my dependent variable andis the average of my independent variables.
Our model must pass through the points therefore, these points are the ones we are going to use to calculate our independent term of the linear function ( ).
Knowing the above, I will show a code example which I made in Python with our Jupyter Notebook environment provided by Anaconda Distribution.
Now we will quickly perform the same exercise in Sklearn, a Python library which is focused on Machine Learning.
You can install this library with the following command in your CMD: pip install scikit-learn.
We can see that both in the mathematical way and using the sklearn library we arrive to the same terms of our linear function, so we can use both methods, for questions of writing the code faster and clarity, I recommend using the Sklean library which does not require as much prior knowledge in statistics and mathematics but it is always advisable to know what happens behind our Machine Learning models.
Posted by
Felipe Gonzales – Mechatronic Engineer