spiderChow
1/18/2018 - 9:01 AM

regression metics

"""
1. Explained variance score
    explained_variance(y,y_hat)=1-var(y-y_hat)/var(y)
    
    其实是预测与真实的差距,这个差距保持不变的时候,就说明模型对于真实数据可以解释。

>> The best possible score is 1.0, lower values are worse.

"""
from sklearn.metrics import explained_variance_score
y_true = [3, -0.5, 2, 7]
y_pred = [2.5, 0.0, 2, 8]
explained_variance_score(y_true, y_pred)  

"""
2.Mean absolute error
3.Mean Squared Error(MSE)

  less is better

"""
from sklearn.metrics import mean_absolute_error, mean_squared_error
y_true = [3, -0.5, 2, 7]
y_pred = [2.5, 0.0, 2, 8]
mean_absolute_error(y_true, y_pred)
mean_squared_error(y_true, y_pred)

"""
4.R² score, the coefficient of determination
how well future samples are likely to be predicted by the model.
Best possible score is 1.0 and it can be negative.

=1- sigma((y-y_hat)^2)/sigma((y-y_mean)^2)
"""