提供实际值列actual_value=[155.9562,160.3847,164.9389,169.6225,137.9029,141.8187,145.8458,149.9872,168.6084,173.3962,178.3199,183.3834,211.1985,217.1957,223.3631,229.7056,236.2283,242.9361,249.8345] 预测值 svm_value=[157.4993,154.6378,152.1427,155.1906,152.5394,155.1906,156.2576,152.2170,172.5913,174.0503,182.3823,187.3208,199.5091,210.5734,218.8240,230.7000,244.7713,248.8016,250.3719] 使用python非对称MAPE求取
时间: 2023-09-20 07:11:03 浏览: 100
actual_albedo_hdf.zip_7KC_actual_albedo_albedo_hdf_反照率
5星 · 资源好评率100%
非对称MAPE(Mean Absolute Percentage Error)是一种用于衡量预测值与实际值之间差异的指标。它考虑了预测值相对于实际值的百分比差异,并且对于预测值小于实际值和预测值大于实际值的情况采用不同的计算方法。
在Python中,可以使用以下代码来计算非对称MAPE:
```python
import numpy as np
def asymmetric_mape(actual_value, predicted_value):
diff = np.abs(actual_value - predicted_value)
relative_diff = diff / np.maximum(np.abs(actual_value), np.abs(predicted_value))
asym_mape = np.mean(relative_diff) * 100
return asym_mape
actual_value = [155.9562,160.3847,164.9389,169.6225,137.9029,141.8187,145.8458,149.9872,168.6084,173.3962,178.3199,183.3834,211.1985,217.1957,223.3631,229.7056,236.2283,242.9361,249.8345]
svm_value = [157.4993,154.6378,152.1427,155.1906,152.5394,155.1906,156.2576,152.2170,172.5913,174.0503,182.3823,187.3208,199.5091,210.5734,218.8240,230.7000,244.7713,248.8016,250.3719]
asym_mape = asymmetric_mape(np.array(actual_value), np.array(svm_value))
print("非对称MAPE:", asym_mape)
```
运行以上代码,可以得到非对称MAPE的值为 11.423%.
阅读全文