Git Product home page Git Product logo

regression-outlier-effect's Introduction

regression-outlier-effect

This repository shows how outliers affect best fit linear regression line and how we can overcome this outlier problem with regularization.

What is Linear Regression

image
Linear Regression is a machine learning algorithm based on supervised learning. It is used to predict the value of a variable based on the value of another variable. The variable you want to predict is called the dependent variable. The variable you are using to predict the other variable's value is called the independent variable. A best fit line is drawn and the errors can be calculated for it. Here, squared error/squared loss is calculated for all the datapoints. It is nothing but the squared error between the actual datapoint and predicted datapoint.

What is an outlier

image
An outlier is an individual point of data that is distant from other points in the dataset. It is an anomaly in the dataset that may be caused by a range of errors in capturing, processing or manipulating data. There can be multiple outliers in the dataset. Also an outlier can be informative sometimes. So we shouldn't remove the outliers before analyzing them.

Effect of outliers on linear regression best fit line

image
In the above given diagram, we can see that after increasing the number of outliers, the best fit regression line tends to bend towards the outlier datapoints. So this is the adverse effect of the outliers in the dataset.

Overcoming the outliers effect

To overcome the effect of outliers on the best fit regression line, there can be many methods. One of the method is to use regularization during training the data. Different regularizer (here alpha) values can be used and then the algorithm can be trained on these different regularizer values. Below are the results after using regularization.

image

Observation :-


When alpha = 0.0001
As alpha value is very small, the regression line tends to outliers as number of outliers increases. For 1 or 2 outliers, the line is far away from them. But as the number of outliers increase, the line shifts towards them, considering them non-outlier points.

When alpha = 1
Even after increasing alpha from 0.0001 to 1, exact same observation is seen for the line which is seen for alpha = 0.0001.

When alpha = 100
As the alpha is set to 100, the regression line becomes more robust to outliers(line remains far away from outliers). As the outliers increase, it still affects the line but comparably less (compared to less values of alpha).

regression-outlier-effect's People

Contributors

sachelsout avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.