Understanding High Leverage Point using Turicreate
High Leverage Point: A data point is considered to be a High Leverage Point if it has extreme predictor input value. An extreme input value simply means extremely low or extremely high value as compared to other data points in the entire Data set. The reason it is such an import concept in machine learning because it may highly influence your model fit on a particular data.
In this tutorial we are going to use turicreate to understand the concept of a high leverage point, so make sure you have turicreate installed in your system in order to follow along with the tutorial. For more info on Turicreate you can check this nice article on Turicreate.
So let’s understand this concept step by step.
Step 1: We will start by importing all the required libraries that we will need in this tutorial.
- Turicreate for fitting our regression model.
- Matplotlib for visualizing data.
- random for generating random numbers.
Step 2: Next, we will generate some data to fit our model and visualize the data using matplotlib.
As you can see in the image that there is a point in (400,1000) coordinate which is very far along the x-axis as compared to other data. That point is called High Leverage Point.
Step 3: Now, we will fit a regression model on our data.
Step 4 : Now again fit the regression model but this time we will remove the high leverage data point.
Step 5: As of now you cannot determine the actual difference between the two models. So let’s visualize these two fits in the same picture to better understand the difference.
As you can clearly see in the plot that there is a little difference between the two plot that arises just by removing a single point.
Step 6: Now we will calculate the actual difference between these two fits. For this, we will calculate the regression coefficients of both the model.
As it is clearly visible from the picture that the difference between the coefficients of the two models is not that big, however in real-world projects where there is actual data and amount of data is really huge, it may highly influence the fit of the model but still, an analyst needs to find out whether a data point is actually high leverage or not without jumping to any conclusion.
In this case, we are using simple linear regression to fit our data, so we can just simply visualize the data in a 2-D plot, but we don’t have that luxury in the case of multiple linear regression. In that situation, we have to rely on various measures to help us determine whether a data point is a high leverage point or not.