回归预测评估指标

标注说明

ff表示预测值,yy表示实际值

评价指标

  • MAE(Mean Absolute Error) 平均绝对误差 
    MAE=1ni=1n|fiyi|MAE=1n∑i=1n|fi−yi|
  • MSE(Mean Square Error) 平均平方差/均方误差是回归任务最常用的性能度量。 
    MSE=1ni=1n(fiyi)2MSE=1n∑i=1n(fi−yi)2
  • RMSE(Root Mean Square Error) 方均根差 

    RMSE=MSERMSE=MSE

    缺点:因为它使用的是平均误差,而平均误差对异常点较敏感,如果回归器对某个点的回归值很不合理,那么它的误差则比较大,从而会对RMSE的值有较大影响,即平均值是非鲁棒的。

  • MAPE 
    全称是Mean Absolute Percentage Error(WikiPedia), 也叫mean absolute percentage deviation (MAPD),在统计领域是一个预测准确性的衡量指标。 

    MAPE=100nt=1n|yifiyi|MAPE=100n∑t=1n|yi−fiyi|

  • R平方 
    y¯表示观测数据的平均值 
    残差平方和 

    SSres=(yifi)2SSres=∑(yi−fi)2

    总平均值 
    SStot=(yiy¯)2SStot=∑(yi−y¯)2

    R平方 
    r2=1SSresSStot=1(yifi)2(yiy¯)2r2=1−SSresSStot=1−∑(yi−fi)2∑(yi−y¯)2

    R平方是多元回归中的回归平方和占总平方和的比例,它是度量多元回归方程中拟合程度的一个统计量,反映了在因变量yy的变差中被估计的回归方程所解释的比例。 
    R平方越接近1,表明回归平方和占总平方和的比例越大,回归线与各观测点越接近,用xx的变化来解释yy值变差的部分就越多,回归的拟合程度就越好。

  • 校正R平方 
    http://www.statisticshowto.com/adjusted-r2/ 
    这里写图片描述

    where: N is the number of points in your data sample. 
    K is the number of independent regressors, i.e. the number of variables in your model, excluding the constant

  • RMSPE 

    RMSPE=1ni=1n(yiy^iyi)2RMSPE=1n∑i=1n(yi−y^iyi)2

    where yiyi denotes the sales of a single store on a single day and y^iy^i denotes the corresponding prediction.

https://www.kaggle.com/cast42/xgboost-in-python-with-rmspe-v2/code

def rmsle(predicted,real):
    sum=0.0
    for x in range(len(predicted)):
        p = np.log(predicted[x]+1)
        r = np.log(real[x]+1)
        sum = sum + (p - r)**2
    return (sum/len(predicted))**0.5
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
# https://www.kaggle.com/jpopham91/rmlse-vectorized
# vectorized error calc
def rmsle(y, y0):
    assert len(y) == len(y0)
    return np.sqrt(np.mean(np.power(np.log1p(y)-np.log1p(y0), 2)))

猜你喜欢

转载自blog.csdn.net/u011089523/article/details/79956975