ML：根据不同机器学习模型输出的预测值+且与真实值相减得到绝对误差对比+误差可视化

​输出结果​

​实现代码​

## 实现代码

# -*- coding: utf-8 -*-#ML：根据不同机器学习模型输出的预测值+且与真实值相减得到绝对误差对比+误差可视化#Model_comparison_error_Plot()函数：根据不同模型预测值输出绝对误差对比且可视化def Model_comparison_error_Plot(list_str01,list_str02,list_num00, Xlabel,Ylabel,title):    #数字列表相减功能：将两个字符串列表改为数字列表并相减    #(1)、依次将两个字符串列表改为数字列表    import numpy as np    list_num01 = list(map(float, list_str01))    list_num02 = list(map(float, list_str02))        #(2)、列表内数字相减求差    #T1、利用array方法    list_array01 = np.array(list_num01)    list_array02 = np.array(list_num02)    list_array00 = np.array(list_num00)     #定义标准列表        list_subtraction01 = list_array00 - list_array01    list_subtraction02 = list_array00 - list_array02    print(list_array00)    print('list_subtraction01', list_subtraction01)    print('list_subtraction02', list_subtraction02)        #T2、利用列表的for循环指针对应取出法    error01 = []    error02 = []    for i in range(len(list_num00)):        error01.append(round (list_num01[i] - list_num00[i],3) )        error02.append(round (list_num02[i] - list_num00[i],3) )    print(error01)    print(error02)        #(3)、绘制error曲线    import matplotlib.pyplot as plt         x = range(0,len(list_subtraction01))    y1 = list_subtraction01    y2 = list_subtraction02    y_zero = [0 for x in range(0, len(list_subtraction01))]    plt.plot(x,y_zero,'r--',label='zero')     plt.plot(x,y1,'g',label='STD-DTR')                          plt.plot(x,y2,'b',label='STD-XGBR')         plt.xlabel(Xlabel)    plt.ylabel(Ylabel)    plt.title(title)         plt.legend(loc=1)       plt.show()DTR_list =  ['67.330', '66.794', '65.319', '65.435', '67.903', '67.743', '63.994', '62.466', '67.581', '67.505', '64.196', '63.726', '66.749', '67.363', '65.962', '65.630', '66.602', '66.956', '63.730', '63.858', '67.370', '66.902', '63.392', '63.408', '64.428', '73.083', '72.952', '73.561', '73.148', '73.258', '72.558']XGBR_list =  ['66.398', '66.308', '66.197', '66.323', '66.388', '66.388', '65.761', '65.074', '65.516', '65.448', '65.534', '65.530', '64.163', '64.097', '62.860', '62.860', '63.771', '63.926', '62.667', '62.902', '62.981', '62.981', '62.987', '62.897', '66.465', '72.292', '71.947', '71.947', '71.947', '71.947', '71.928']real_list = [64, 68, 64, 68, 65, 65, 63, 63, 66, 65, 65, 65, 64, 65, 61, 62, 64, 63, 66, 60, 66, 62, 64, 61, 71, 75, 73, 73, 73, 73, 73]title = 'Comparisons and Visualization of Absolute Errors in Output of Predicted Values of Different Models'Xlabel = 'working condition'Ylabel = 'Absolute Error Value'Model_comparison_error_Plot(DTR_list,XGBR_list,real_list,Xlabel,Ylabel,title)