There are two type of it:
1- Mean Squared Error (MSE):
find the between predict and actual value then square it and divided by the number of samples;
The Code
from sklearn.metrics import mean_squared_error
mean_squared_error(df['price'], Y_predict_simple_fit)
2-R-squared(R^2): [0,1]
It measure how close the data to the fitted regression line and it is the percentage of variation of the target variable (Y) that is explain by the linear model.
\[R^{2} = (1-\frac{MSE of regressionline}{MSE of teh average of the data})\]
The Code:
X = df[['highway-mpg']]
Y = df['price']
lm.fit(X, Y) // if the result is negative so there are overfitting must be solve
0 Comments:
Post a Comment