bias and variance calculation for linear regression
In real life, we cannot calculate bias & variance. Recap: Bias measures how much the estimator (can be any machine learning algorithm) is wrong with respect to varying samples, and similarly variance measures how much the estimator fluctuate around the expected value of the estimator. To calculate the bias & variance, we need to generate a number of datasets from some known function by adding noise and train a separate model (estimator) using each dataset. Since we don't know neither the above mentioned known function nor the added noise, we cannot do it. In practise, we can only calculate the overall error. In order to combat with bias/variance dilemma, we do cross-validation.
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.