bias and variance calculation for linear regression

0 votes
If we have 4 parameters of X_train, y_train, X_test, and y_test, how can we calculate the bias and variance of a machine learning algorithm like linear regression?

I have searched a lot but I could not find a single code for this.
Mar 2 in Machine Learning by Dev
• 6,000 points
80 views

1 answer to this question.

0 votes
Evaluation of Variance:

variance = np.var(prediction) # Where prediction is a variable obtained after  predict() function of any Classifier or algorithm

sse= np.mean((np.mean(prediction) - y)** 2) # Where y refers to dependent variable. # sse : Sum of squared errors.

bias = sse - variance

Bias and Variance are errors and need to be balanced. Bias leads to an underfit model that means it does not understand the patterns and fails to generalize, whereas

Variance leads to overfitting of the data, the model learns the data so well even the noises that does not generalize well on unseen data. Variance is the spread of the data, how far are the data points from the central points like mean or median
answered Mar 2 by Nandini
• 5,480 points

Related Questions In Machine Learning

0 votes
1 answer
0 votes
1 answer

Python script for linear regression on panda dataframe

Use the following code: from scipy import stats slope, ...READ MORE

answered May 23, 2019 in Machine Learning by Imran
1,209 views
0 votes
1 answer

Crawling after login in Python

You missed a few login data forms, ...READ MORE

answered Sep 7, 2018 in Python by Priyaj
• 58,080 points
1,064 views
0 votes
1 answer

Crawling after login in Python

You missed a few login data forms, ...READ MORE

answered Sep 14, 2018 in Python by Priyaj
• 58,080 points
319 views
0 votes
1 answer

“stub” __objclass__ in a Python class how to implement it?

You want to avoid interfering with this ...READ MORE

answered Sep 27, 2018 in Python by Priyaj
• 58,080 points
733 views
+1 vote
1 answer

How is raw_input() and input() in python3.x?

raw_input() was renamed to input() so now input() returns the exact string ...READ MORE

answered Oct 30, 2018 in Python by Priyaj
• 58,080 points
384 views
0 votes
1 answer
0 votes
1 answer

Assumptions of Naïve Bayes and Logistic Regression

There are very few difference between Naive ...READ MORE

answered Feb 7 in Machine Learning by Nandini
• 5,480 points
42 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP