精华内容
下载资源
问答
  • 2、cross_val_score()中的‘neg_mean_squared_error’使用的是metrics.mean_absolute_error,参考mse的计算公式,都已经平方了为什么还会有负数?? 背景: MSE的计算公式: ![图片说明]...
  • def calPerformance(y_true,y_pred):'''模型效果指标评估y_true:真实的数据值y_pred:回归模型预测的数据值explained_variance_score:解释回归模型的方差得分...mean_absolute_error:平均绝对误差(Mean Absolute ...

    def calPerformance(y_true,y_pred):

    '''

    模型效果指标评估

    y_true:真实的数据值

    y_pred:回归模型预测的数据值

    explained_variance_score:解释回归模型的方差得分,其值取值范围是[0,1],越接近于1说明自变量越能解释因变量

    的方差变化,值越小则说明效果越差。

    mean_absolute_error:平均绝对误差(Mean Absolute Error,MAE),用于评估预测结果和真实数据集的接近程度的程度

    ,其其值越小说明拟合效果越好。

    mean_squared_error:均方差(Mean squared error,MSE),该指标计算的是拟合数据和原始数据对应样本点的误差的

    平方和的均值,其值越小说明拟合效果越好。

    r2_score:判定系数,其含义是也是解释回归模型的方差得分,其值取值范围是[0,1],越接近于1说明自变量越能解释因

    变量的方差变化,值越小则说明效果越差。

    '''

    model_metrics_name=[explained_variance_score, mean_absolute_error, mean_squared_error, r2_score]

    tmp_list=[]

    for one in model_metrics_name:

    tmp_score=one(y_true,y_pred)

    tmp_list.append(tmp_score)

    x=[]

    x.append(tmp_list)

    f1 = pd.DataFrame(x,columns=['explained_variance_score', 'mean_absolute_error', 'mean_squared_error', 'r2_score'])

    print(f1)

    return tmp_list

    if __name__=='__main__':

    y_pred=[22, 21, 21, 21, 22, 26, 28, 28, 33, 41, 93, 112, 119, 132, 126, 120, 101, 56, 58, 58, 57, 57, 53, 52, 52, 51, 50, 49, 49, 50, 54, 58, 85, 115, 125, 131, 135, 137, 135, 126, 109, 80, 83, 83, 77, 75, 74, 73, 73, 69, 67, 64, 64, 65, 69, 72, 93, 126, 141, 145, 126, 107, 65, 67, 70, 73, 77, 80, 82, 82, 79, 77, 72, 69, 67, 65, 64, 67, 75, 88, 105, 107, 101, 102, 100, 84, 85, 56, 50, 44, 41, 40, 36, 36, 35, 35, 34, 37, 37, 37, 38, 40, 41, 41, 44, 74, 98, 89, 89, 95, 101, 117, 115, 75, 47, 41, 40, 40, 37, 38, 40, 37, 37, 42, 41, 43, 39, 40, 44, 47, 54, 59, 70, 83, 83, 77, 58, 48, 50, 47, 44, 43, 42, 42, 41, 39, 39, 39, 40, 40, 40, 40, 44, 46, 46, 47, 45, 44, 43, 38, 34, 32, 32, 36, 35, 33, 34, 33, 29, 29, 30, 29, 28, 27, 25, 24, 23, 22, 23, 22, 25, 27, 25, 24, 22, 26, 30, 32, 34, 35, 34, 34, 36, 35, 36, 35, 37, 41, 40, 40, 44, 52, 74, 79, 75, 67, 49, 46, 40, 42, 40, 42, 44, 44, 46, 45, 44, 44, 42, 44, 45, 45, 46, 48, 72, 100, 101, 106, 104, 106, 78, 53, 51, 51, 52, 53, 53, 54, 58, 58, 59, 58, 58, 60, 59, 57, 56, 57, 98, 106, 114, 119, 114, 92, 52, 46, 42, 40, 40, 35, 35, 35, 33, 32, 33, 36, 40, 46, 54, 59, 74, 117, 132, 138, 122, 102, 93, 65, 44, 42, 40, 38, 39, 39, 38, 39, 39, 41, 41, 43, 46, 51, 53, 53, 54, 51, 52, 49, 45, 45, 45, 42, 40, 41, 45, 49, 54, 53, 53, 52, 52, 52, 52, 51, 51, 53, 55, 56, 55, 52, 52, 50, 48, 45, 43, 43, 47, 49, 46, 44, 49, 52, 53, 55, 58, 59, 60, 60, 61, 65, 71, 73, 73, 106, 115, 111, 100, 104, 106, 95, 54, 53, 54, 58, 56, 54, 55, 54, 53, 54, 56, 58, 60, 63, 61, 56, 57, 64, 102, 112, 117, 122, 120, 114, 111, 75, 48, 39, 40, 41, 40, 38, 39, 39, 41, 44, 42, 46, 45, 40, 41, 39, 37, 32, 32, 27, 27, 25, 23, 21, 20, 18, 18, 18, 17, 14, 15, 15, 16, 16, 14, 13, 18, 23, 23, 32, 29, 45, 45, 43, 49, 47, 45, 39, 35, 32, 26, 23, 20, 19, 21, 23, 22, 24, 25, 28, 26, 25, 29, 30, 30, 32, 30, 30, 32, 33, 34, 33, 33, 32, 31, 30, 30, 29, 28, 28, 27, 28, 28, 30, 29, 30, 32, 33, 29, 28, 36, 36, 40, 42, 41, 42, 41, 39, 32, 34, 32, 33, 36, 40, 38, 42, 43, 44, 46, 46, 51, 50, 49, 48, 46, 40, 36, 36, 31, 27, 24, 23, 21, 18, 19, 17, 16, 15, 16, 14, 13, 13, 13, 15, 20, 23, 25, 31, 29, 29, 27, 30, 29, 19, 21, 23, 25, 28, 29, 28, 28, 31, 30, 32, 35, 33, 30, 30, 33, 33, 32, 33, 36, 36, 34, 31, 30, 29, 28, 28, 28, 19, 18, 17, 18, 17, 18, 19, 20, 21, 20, 25, 28, 30, 29, 29, 28, 26, 24, 22, 23, 22, 22, 24, 22, 23, 25, 23, 22, 23, 21, 25, 27, 30, 29, 32, 46, 73, 90, 73, 77, 54, 51, 46, 46, 47, 49, 47, 45, 42, 43, 41, 36, 35, 33, 32, 36, 41, 48, 51, 55, 55, 56, 73, 80, 68, 59, 59, 56, 59, 64, 59, 55, 48, 29, 30, 32, 30, 30, 32, 35, 29, 29, 32, 44, 52, 53, 52, 52, 46, 42, 38, 33, 30, 32, 32, 35, 34, 36, 39, 42, 39, 45, 48, 48, 42, 47, 52, 54, 54, 54, 49, 53, 55, 50, 49, 47, 46, 43, 43, 51, 49, 51, 50, 51, 52, 53, 52, 53, 73, 82, 88, 100, 83, 89, 103, 110, 110, 106, 79, 63, 68, 55, 50, 47, 50, 54, 58, 59, 58, 51, 41, 38, 37, 40, 40, 40, 47, 51, 51, 49, 50, 48, 46, 43, 43, 42, 42, 41, 39, 42, 42, 38, 38, 36, 33, 33, 34, 33, 34, 36, 35, 29, 28, 30, 34, 37, 42, 44, 47, 48, 51, 52, 52, 50, 44, 43, 44, 41, 37, 34, 34, 30, 30, 34, 28, 27, 25, 26, 25, 23, 22, 23, 23, 24, 23, 24, 26, 28, 29, 28, 26, 26, 26, 27, 27, 28, 28, 26, 29, 30, 28, 28, 25, 22, 22, 22, 20, 20, 20, 20, 21, 26, 24, 24, 24, 26, 31, 33, 35, 35, 34, 33, 30, 30, 28, 29, 28, 26, 25, 23, 22, 23, 23, 22, 22, 26, 26, 26, 25, 27, 34, 37, 39, 41, 38, 35, 34, 35, 37, 38, 35, 30, 26, 24, 23, 21, 19, 21, 23, 22, 21, 21, 24, 24, 28, 35, 36, 35, 35, 32, 27, 36, 39, 38, 38, 30, 32, 30, 29, 26, 24, 21, 21, 23, 23, 23, 23, 24, 26, 30, 35, 39, 38, 35, 34, 48, 52, 42, 35, 34, 35, 38, 36, 34, 33, 33, 35, 37, 30, 29, 33, 37, 39, 40, 37, 38, 41, 43, 49, 53, 56, 56, 40, 38, 35, 35, 36, 36, 36, 38, 41, 45, 41, 36, 39, 40, 36, 34, 35, 36, 36, 36, 35, 37, 37, 39, 38, 40, 42, 46, 51, 54, 59, 62, 64, 65, 79, 88, 79, 72, 70, 68, 67, 58, 58, 59, 60, 62, 62, 62, 61, 63, 63, 62, 63, 65, 67, 69, 70, 69, 108, 118, 123, 122, 127, 129, 129, 114, 79, 70, 67, 70, 71, 71, 71, 72, 73, 73, 75, 76, 78, 81, 79, 78, 105, 113, 116, 109, 107, 90, 90, 94, 102, 105, 95, 94, 90, 80, 82, 77, 64, 52, 49]

    y_true=[23, 23, 23, 22, 23, 26, 28, 28, 32, 37, 56, 64, 68, 74, 75, 71, 66, 55, 59, 59, 58, 58, 52, 51, 50, 49, 48, 47, 47, 48, 53, 59, 73, 83, 84, 86, 87, 90, 90, 88, 84, 78, 83, 83, 77, 75, 75, 73, 73, 69, 66, 64, 65, 68, 72, 77, 84, 96, 100, 102, 92, 79, 65, 66, 71, 75, 79, 82, 84, 84, 82, 79, 73, 70, 68, 65, 66, 70, 79, 93, 98, 85, 77, 76, 76, 72, 74, 57, 48, 44, 41, 40, 37, 36, 36, 35, 35, 37, 37, 37, 37, 39, 40, 40, 41, 53, 63, 60, 61, 64, 70, 84, 86, 66, 47, 41, 40, 40, 38, 39, 40, 38, 37, 41, 40, 42, 39, 40, 43, 46, 47, 47, 49, 56, 58, 56, 51, 47, 48, 46, 43, 42, 42, 41, 40, 39, 39, 39, 40, 40, 39, 40, 43, 44, 42, 42, 43, 43, 42, 38, 35, 33, 33, 37, 36, 34, 34, 34, 31, 31, 32, 31, 30, 29, 27, 26, 26, 25, 25, 24, 25, 25, 25, 24, 24, 28, 31, 33, 34, 35, 34, 34, 36, 35, 36, 35, 37, 40, 40, 40, 42, 45, 53, 54, 53, 52, 48, 46, 41, 43, 41, 42, 44, 44, 45, 44, 43, 43, 41, 43, 44, 43, 45, 46, 55, 65, 66, 71, 72, 73, 63, 52, 50, 50, 51, 52, 52, 53, 58, 58, 58, 57, 57, 59, 58, 57, 56, 56, 70, 71, 73, 76, 78, 70, 52, 45, 43, 41, 41, 36, 35, 35, 34, 33, 33, 36, 39, 44, 52, 59, 69, 88, 91, 96, 85, 70, 65, 54, 44, 42, 40, 38, 39, 39, 38, 39, 39, 40, 40, 42, 44, 48, 51, 51, 52, 49, 48, 44, 41, 42, 42, 41, 40, 41, 44, 47, 53, 52, 52, 51, 51, 51, 51, 50, 50, 52, 55, 57, 55, 51, 47, 44, 43, 42, 42, 42, 46, 47, 45, 43, 47, 51, 52, 55, 59, 61, 62, 61, 63, 68, 77, 79, 76, 84, 84, 80, 71, 72, 73, 70, 53, 52, 54, 59, 56, 54, 55, 53, 52, 54, 57, 59, 61, 66, 63, 57, 58, 64, 80, 86, 89, 91, 92, 90, 88, 70, 48, 39, 41, 42, 41, 39, 40, 40, 41, 43, 42, 45, 44, 40, 41, 39, 38, 34, 33, 29, 29, 27, 25, 24, 23, 21, 21, 21, 20, 17, 18, 18, 19, 19, 17, 16, 19, 22, 23, 33, 28, 41, 38, 40, 48, 45, 45, 40, 34, 31, 28, 25, 23, 22, 23, 25, 24, 26, 27, 29, 27, 26, 29, 30, 30, 32, 30, 30, 32, 33, 33, 32, 32, 32, 31, 30, 30, 29, 28, 28, 27, 28, 28, 29, 29, 30, 31, 32, 29, 29, 36, 36, 39, 40, 39, 40, 39, 38, 33, 34, 33, 33, 35, 38, 37, 40, 41, 42, 43, 44, 48, 47, 46, 45, 44, 39, 36, 36, 32, 29, 26, 25, 23, 21, 21, 20, 19, 18, 18, 17, 16, 16, 16, 18, 22, 24, 26, 30, 30, 30, 28, 31, 30, 22, 23, 25, 27, 29, 30, 29, 29, 32, 31, 32, 35, 33, 31, 31, 33, 32, 30, 31, 35, 35, 33, 31, 30, 29, 28, 28, 28, 21, 20, 20, 20, 20, 20, 21, 22, 22, 22, 23, 24, 24, 25, 24, 25, 24, 24, 23, 24, 23, 23, 25, 23, 24, 25, 24, 23, 24, 22, 25, 27, 29, 28, 31, 39, 50, 57, 53, 56, 49, 48, 45, 45, 46, 47, 46, 44, 42, 42, 41, 37, 36, 34, 33, 36, 40, 46, 49, 55, 56, 57, 62, 64, 58, 56, 59, 57, 60, 65, 60, 55, 48, 30, 29, 30, 28, 29, 31, 35, 29, 29, 31, 37, 44, 43, 44, 45, 45, 43, 39, 34, 32, 33, 33, 35, 34, 36, 38, 40, 38, 43, 46, 46, 41, 42, 42, 42, 42, 42, 41, 43, 45, 46, 47, 46, 44, 42, 42, 48, 46, 48, 47, 49, 50, 51, 50, 51, 58, 58, 60, 64, 57, 58, 65, 71, 74, 73, 66, 63, 66, 54, 48, 46, 48, 53, 58, 59, 58, 49, 40, 38, 37, 39, 40, 40, 45, 48, 48, 47, 47, 46, 44, 42, 42, 43, 41, 40, 39, 41, 41, 37, 39, 36, 34, 34, 34, 34, 34, 36, 35, 30, 29, 31, 34, 37, 41, 42, 45, 46, 48, 50, 50, 48, 43, 41, 42, 40, 37, 34, 34, 31, 30, 30, 29, 28, 27, 27, 26, 25, 24, 25, 24, 25, 24, 25, 26, 28, 29, 28, 26, 26, 26, 26, 26, 27, 27, 26, 29, 30, 28, 28, 26, 23, 23, 23, 21, 21, 21, 21, 22, 25, 24, 24, 24, 26, 27, 27, 28, 28, 28, 29, 30, 30, 29, 29, 28, 27, 26, 25, 24, 24, 24, 23, 23, 26, 26, 26, 26, 27, 28, 30, 31, 32, 32, 31, 32, 34, 36, 36, 34, 30, 27, 25, 25, 23, 21, 22, 24, 23, 22, 22, 25, 25, 28, 30, 29, 29, 30, 29, 28, 35, 37, 37, 37, 30, 32, 30, 29, 27, 25, 23, 23, 24, 24, 24, 24, 25, 25, 27, 31, 32, 33, 32, 34, 46, 50, 41, 35, 34, 35, 38, 36, 34, 33, 33, 35, 36, 30, 29, 30, 31, 31, 34, 36, 37, 40, 42, 46, 51, 56, 56, 40, 38, 35, 35, 36, 36, 36, 38, 40, 43, 40, 36, 36, 36, 36, 34, 35, 36, 36, 36, 35, 37, 37, 38, 37, 39, 41, 44, 48, 52, 58, 63, 65, 68, 71, 71, 65, 60, 58, 58, 59, 57, 57, 59, 60, 62, 62, 62, 61, 64, 64, 63, 65, 67, 70, 72, 73, 70, 81, 82, 84, 85, 88, 91, 93, 89, 80, 74, 70, 74, 75, 76, 76, 77, 79, 79, 82, 82, 86, 89, 87, 86, 93, 95, 94, 90, 87, 82, 83, 85, 94, 103, 101, 101, 96, 85, 86, 80, 66, 52, 48]

    calPerformance(y_true,y_pred)

    展开全文
  • Keras : KeyError: 'val_mean_absolute_error' 把训练轮次改的小一点,然后添加下面代码: print(history.history.keys()) 就可以打印出有哪些key: dict_keys(['loss', 'mae', 'val_loss', 'val_mae']) 发现并...

    运行《Python深度学习》里波士顿房价预测的代码报错,提示:

    Keras : KeyError: 'val_mean_absolute_error'
    

    把训练轮次改的小一点,然后添加下面代码:

    print(history.history.keys())
    

    就可以打印出有哪些key:

    dict_keys(['loss', 'mae', 'val_loss', 'val_mae'])
    

    发现并没有val_mean_absolute_error这个key。可能是和keras的版本有关。

    mae_history = history.history['val_mae']
    

    吐槽一句,python的库不向后兼容,太折磨人了

    展开全文
  • mae_history=history.history[‘val_mean_absolute_error’] 改为 mae_history=history.history[‘val_mae’]

    mae_history=history.history[‘val_mean_absolute_error’]
    改为
    mae_history=history.history[‘val_mae’]

    展开全文
  • 解决 KeyError:‘val_mean_absolute_error’ ** average_mae_history=[np.mean([x[i] for x in all_mae_histories]) for i in range(num_epochs)] 其实类似的文章不少 具体名字就不赘述了 报错的语句是这个: mae_...

    报错的语句是这个:

    mae_history=history.history[‘val_mean_absolute_error’]

    最后我尝试了一个不是办法的办法 改成如下:

    mae_history=history.history[‘mae’]

    万万没想到 就这么解决了

    运气而已 这次算是解决了

    还望有大神赐教 也好给我们这些小白讲讲清爽 谢谢了

    关于‘mae’ 怎末来的,用下面这个语句 查看你的key值是什么

    print(history.history.keys())
    

    输出结果为:

    dict_keys(['val_loss', 'val_mae', 'loss', 'mae'])
    

    用最后一个。

    展开全文
  • 解决 KeyError:'val_mean_absolute_error'

    千次阅读 多人点赞 2020-04-09 23:39:25
    只遇到了KeyError:‘val_mean_absolute_error’ 搜索了一下 居然没有合适的解答 没办法 一遍一遍的看代码 试图寻找突破点 源代码 如下: num_epochs=500 all_mae_histories=[] for i in range(k): print(‘process....
  • 注意多维数组 MAE 的计算方法 * ... from sklearn.metrics import mean_absolute_error >>> y_true = [3, -0.5, 2, 7] >>> y_pred = [2.5, 0.0, 2, 8] >>> mean_absolute_error(y_t...
  • 在使用mean_absolute_percentage_error时,导入模块报错 from sklearn.metrics import mean_absolute_percentage_error 报错信息: ImportError: cannot import name 'mean_absolute_percentage_error' from '...
  • 回归模型是机器学习中很重要的一类模型,不同于常见的分类模型,回归模型的性能评价指标跟分类...variance_score、mean_absolute_errormean_squared_error、r2_score,详细的解释已经在代码注释中了,就不再多解释...
  • from sklearn.metrics import mean_absolute_percentage_error y_true = [3, -0.5, 2, 7] y_pred = [2.5, 0.0, 2, 8] mean_absolute_percentage_error(y_true, y_pred) 的时候,报以下错误’ -------------------...
  • 解决KeyError: 'val_mean_absolute_error问题Boston Housing 小白记录出过的问题 修改 mae_history = history.history['vae_mean_absolute_error'] 只需要改成 mae_history = history.history['val_vae'] 查看...
  • from sklearn.metrics import mean_absolute_percentage_error
  • 问题:运行mae = mean_absolute_error(y_test, yhat),出现错误TypeError: only size-1 arrays can be converted to Python scalars 也不知道我在用什么版本的TensorFlow老出现一些版本不一致,代码运行出错 修改...
  • Mean Absolute Error(MAE) 一般记做MAE{\mathop{\rm MAE}\nolimits}MAE,平均绝对误差,比较预测结果与真值之间的逐像素绝对值差异: MAE(y,y^)=1n∑i=0n−1∣yi−y^i∣{\mathop{\rm MAE}\nolimits} (y,\hat y) = {1...
  • MAPE(Mean Absolute Percentage Error)是用来做销量预测最常用的指标,在实际的线上线下销量预测中有着非常重要的评估意义。但是在实际的项目过程中发现,有些时候的指标并不能非常好的表示模型拟合的效果,因此对这...
  • 显著性目标检测模型评价指标 之 平均绝对误差(MAE)原理与实现代码 目录 显著性目标检测模型评价指标 之 平均绝对误差(MAE)原理与实现代码 目录 一、显著性目标检测简介 ...二、Mean Absolute Erro...
  • 在对回归问题进行预测的时候,基于 sklearn 有两种方法可以调用评估指标,一种是直接使用模型评估模块 metrics 里面的类 mean_squared_errormean_absolute_error 即可。 另一种是通过调用交叉验证类 cross_val_...
  • 损失函数loss总结

    千次阅读 2019-05-07 11:10:47
    model.compile(loss='mean_squared_error', optimizer='sgd') 可以通过传递预定义目标函数名字指定目标函数,也可以传递一个Theano/TensroFlow的符号函数作为目标函数,该函数对每个数据点应该只返回一个标量值,...
  • 平均绝对值误差 计算标签和预测之间的绝对差值的平均值。‎ import tensorflow as tf y_true = [[0., 1.], [0., 0.]] y_pred = [[1., 1.], [1., 0.]] # Using 'auto'/'sum_over_batch_size' reduction type. ...
  • 'fowlkes_mallows_score', 'homogeneity_score', 'mutual_info_score', 'neg_log_loss', 'neg_mean_absolute_error', 'neg_mean_squared_error', 'neg_mean_squared_log_error', 'neg_median_absolute_error', '...
  • 目录 一、常用的评价指标 1、SSE(误差平方和) 2、R-square(决定系数) 3、Adjusted R-Square (校正决定系数) 二、python中的sklearn....(2)Mean absolute error(平均绝对误差) (3)Mean squared error(...
  • keras中内置的多种损失函数

    千次阅读 2018-10-26 13:10:14
    详细讲解 keras中的损失函数  mean_squared_error  mean_absolute_error  mean_absolute_percentage_error  mean_squared_logarithmic_error  squared_hinge  hinge  ...
  • sklearn中的模型评估

    千次阅读 2017-09-07 11:12:56
    如果从mean_absolute_errormean_squared_error(它计算了模型与数据间的距离)返回的得分将被忽略。 2.2 从metric函数定义你的scoring策略 sklearn.metric提供了一些函数,用来计算真实值与预测...
  • # evaluate predictions score = mean_absolute_error(y_test, yhat) print('MAE: %.3f' % score) # plot learning curves pyplot.title('Learning Curves') pyplot.xlabel('Epoch') pyplot.ylabel('...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 14,616
精华内容 5,846
关键字:

mean_absolute_error