Search For any model to perform well the error needs to be reduced. The correct balance of bias and variance is important for building any machine-learning algorithms and to create accurate results from their models. Bias and variance are used in supervised machine learning, in which an algorithm learns from training data or a sample data set of known quantities. Bias and variance are components of reducible error.

## Bias

Bias is basically how far we have predicted a value than the actual value. We can say that the bias is too high if our prediction is far off from the actual prediction. In other words, Bias means error of the training data. A high bias can cause algorithm to miss the relationship between the input and output variables as a result it oversimplifies the model and can lead to underfitting.

Let’s take an example and see what bias is ...

Let’s say we wanted to predict the height of students using the linear regression In the above picture we can clearly see that the straight line doesn’t have the flexibility to build the true relationship, no matter how well we fit it in the training data. The inability for a machine learning method to find the true relationship is called bias.

## Variance

When model does not perform well as it does with the train data set there is a possibility that the model has a variance. In the other words, Variance means error of the test data. Its basically telling you how scattered the predicted values are from the actual value. A high variance in the data set means that the model as trained with lot of noise and irrelevant data thus leading to overfitting.

## How does Bias and Variance affect the model Image endtoend.ai

High Variance and High Bias: Model will be inconsistent and also inaccurate on average.

Low Variance and High Bias: Models are consistent but low on average.

High Variance and Low Bias: Somewhat accurate but inconsistent on average.

Low Variance and Low Bias: It is the ideal one where the model is consistent and accurate on average. Image from datarobot

It is a concept of finding the right balance between the Bias and the Variance so that our model isn’t overfitted nor underfitted. If the model is too simple and has a very few parameters it will suffer from high bias and low variance and on the other hand if the model has large number of parameters then it will have high variance and low bias. The trade off should result with perfectly balanced bias and variance.

## Concept of Bias and Variance Mathematically

Let the variance that we are predicting be Y and the other independent variables be X. Let us assume that there is a relationship between these two variables such that

Y=f(x)+e

Where e is the estimated error with the mean value 0 and then we make a classifier using the algorithm linear regression or Support vector machine etc... The expected squared error at a point X will be Y squared plus the variance plus the irreducible error.

Total Error = Bias²+Variance+Irreducible error

## Total error

To build any good model we need the right balance between Bias and Variance in a way that it minimizes total error. Image ResearchGate

Total Error = Bias²+Variance+Irreducible error

A perfect balance of Bias and Variance will never underfit or overfit. It is very essential for any data scientist to understand the concept of bias and variance to reduce the errors and build accurate models.
{"ft_lang_label":"__label__en","ft_lang_prob":0.91419464,"math_prob":0.9769956,"size":3451,"snap":"2022-27-2022-33","text_gpt3_token_len":714,"char_repetition_ratio":0.15433711,"word_repetition_ratio":0.0067340066,"special_character_ratio":0.1903796,"punctuation_ratio":0.06317411,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9950146,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12],"im_url_duplicate_count":[null,null,null,1,null,1,null,1,null,1,null,1,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-06-29T04:12:40Z\",\"WARC-Record-ID\":\"<urn:uuid:8bbe0b0c-e789-4159-8ce5-9dd795c6b491>\",\"Content-Length\":\"896807\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:788f482d-dd91-493a-b8a6-5f3ac4c0222e>\",\"WARC-Concurrent-To\":\"<urn:uuid:982f6468-dfd1-494b-8948-fb927502ed19>\",\"WARC-IP-Address\":\"146.75.37.84\",\"WARC-Target-URI\":\"https://www.numpyninja.com/post/bias-and-variance-trade-off\",\"WARC-Payload-Digest\":\"sha1:QE5OYLQOFHRITG7TFIC4KJQCEVDYJO3H\",\"WARC-Block-Digest\":\"sha1:GX4LUCHX5DN5QK5EWES35XE5NHN75PTN\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-27/CC-MAIN-2022-27_segments_1656103620968.33_warc_CC-MAIN-20220629024217-20220629054217-00415.warc.gz\"}"}