The Prediction Power of Machine Learning




The first subcategory of supervised machine learning is regression. This model only uses a simple best fit line for the dataset so that the ordinary least squares value is minimum. Ordinary Least Square value indicate the sum of squared value of difference between actual and the predicted value.

                                                       OLS = ∑ ( Yactual – Ypredicted )2

Each regression line has a unique slope and intercept and one and only one line can fit a dataset. These type of models are used to predict the future outcomes on the basis of unique correlation between independent variables also called as regressors and dependent variable. The major categories of Regression are as follows :
  • Simple Linear Regression
  • Multiple Linear Regression
  • Polynomial Regression
  • Decision Tree Regression
  • Random Forest Regression
The easiest of them all is the Simple Linear Regression. This model can be implemented best when the independent variable depends only on one regressor. It is called a linear regression as the relation between the dependent variable and regressors can be expressed as a linear equation containing only one coefficient and a constant. We calculate the value of these coefficient and constant so that there is only one equation which fits the business problem.

                                                            y0 = b0 + b1x1

This equation denotes a line of slope b1 and intercept equal to y0 which is the locus of all the predicted values and the Ordinary Least Square value is min. for this line.


The problem arises when there are a number of regressors in the business problem. This problem is solved by our second regression model i.e. Multiple Linear Regression. This model can consume a large number of regressors and hence is widely used. The equation for this model contains a large number of terms and one constant term.

                                    y0 = b0 + b1x1 + b2x2 + b3x3 + ……..bnxn

If in the these regressors it contains a categorical variable we have to use LabelEncoder and OneHotEncoder to encode it into dummy variables. Now here comes the trap also known as Dummy Variable Trap. After encoding the category variable into dummy variable we have to omit one variable to escape from the dummy variable trap.

 The default case is when the equation contains the constant term and the all the dummy variables except one. The constant term compensates the missing variable. In actual practice if a categorical variable is divided into two dummy variables D1 and D2 then D2 = D1 – 1.

This fact is is due to the reason as when D1 is unity the second one is zero and vice versa and this property when a variable or regressor determines other it is known as Multicollinearity. The constant, the first coefficient and the second coefficient cannot coexist because it records for redundancy of information.

The compiler cannot understand clearly the effect of first dummy variable and second variable distinctively. Therefore it is inappropriate to use all of them at once.
There are multiple methods to build a model if the number of regressors are more than one. The various methods to build a model are :
  • All In
  • Backward Elimination
  • Forward Elimination
  • Bidirectional Elimination
  • Score Comparison 
The most used of them all is Backward Elimination Method. In this method first of all, all the regressors are thrown into the model but be careful more garbage in is equal to more garbage outcome. Therefore a Significance Level (SL) is choosen which is appropriate and then the component with the highest P level is compared with SL. If it comes out to be greater than SL then it is removed from the model and the process is repeated until all the remaining components P levels are under the chosen SL. As soon as this condition is satisfied the model is ready to be used and is optimum model in statistical view.

PRO TIP : In Multiple Linear Regression we have to take care of the constant term explicitly because the Statsmodel class used for building the model does not contain constant term by default. So we have to explicitly add a column of ones which is treated as a constant in the equation.


If the observation points are non linear and follows a parabolic nature then we use Polynomial Regression. The Polynomial Regression is Linear Regression Model fitted on the polynomial terms of the dataset. It is a special case of Multiple Regression where each higher degree term is a polynomial term of only one regressor. The polynomial regression equation looks something like this

                                           y0 = b0 + b1x1 + b2x12 + b3x13 + ……… bnxn

The polynomial regression curve looks like a parabolic curve and fits the non linear data well.
The important aspect of all the models discussed so far is that they all are linear and continuous machine learning models. 


Now we will discuss two most important non – linear and Non continuous Models. The first one of them is Decision Tree Regression and the second one and most powerful of them all Random Forest Regression.

The Decision Tree Regression model is used when the dataset is too messy to handle and none of the learnt models can provide a solution. It works on the principle of splitting the dataset into leaves on the basis of Information Entropy i.e. the splits will increase the information content in the dataset. The final splits are called terminal leaves and the new incoming data point is assigned the average value of the split in which it lies.

This type of tree is basically a Decision Tree where to assign the value of the new data point we have to traverse through all the conditional statements to arrive at a value to be assigned.

The next and the last model is Random Forest Regression which is an Ensemble Learning model which means combining multiple machine learning models of same or different types to enhance the prediction power. We will later learn other Ensemble model like XGBoost in which we combine different models together. The advantage of using Ensemble modelling is that if one model is affected by any outlier or any error it doesn’t have a negative effect on total outcome.

Random Forest Regression arbitrarily chooses K data points from dataset and implement decision tree on it and then repeat the process N times to obtain N decision trees. The value of oncoming data point is calculated as the average across all the decision trees and hence a good predicted value is seen as outcome.


So that’s it for this post, I know the post was so long but it deserved to be as it covered all the concepts of Regression. In the next post we will see some Regression Models Evaluation Parameters which help us to optimize our model statistically.

I am overwhelmed by your response towards the blog and from now onwards I will post regularly and you can expect new posts on every Tuesday and Friday. There are some upcoming posts on advanced toolbox like TensorFlow etc.
So Stay Tuned……

Comments

Popular posts from this blog

An Informal Introduction to the Beast

Machine Learning Treasure

Preparing for the Long Journey

Evaluating the Regression Models