我尝试在我的随机林代码中测量MAPE(平均绝对百分比误差)值。MAE值为7.5。当我试图计算MAPE时,它输出:Accuracy: -inf %

这是我计算MAPE的代码。如何使它工作,或者为什么它不计算一个值。在

^{pr2}$

以下是值:errors: array([ 2.165, 6.398, 2.814, ..., 21.268, 8.746, 11.63 ])

test_labels: array([45, 47, 98, ..., 87, 47, 72])

这些类型包括:var1 int64

var2 int64

var3 float64

var4 int64

var6 float64

var7 int64

var1. float64

dtype: object

示例值,超过8000个条目var1 var2. var3 var4 var5 var6 var7

"420823370" "183" "2019-09-07 22:13:04" "84" "2019-09-07 22:12:46" "72" "00:00:18"

"420521201" "183" "2019-09-07 17:43:03" "84" "2019-09-07 17:42:51" "46" "00:00:12"

"420219554" "183" "2019-09-07 12:43:02" "88" "2019-09-07 12:42:39" "72" "00:00:23"

"419618820" "183" "2019-09-07 02:43:01" "92" "2019-09-07 02:42:46" "80" "00:00:15"

"419618819" "183" "2019-09-07 02:43:01" "84" "2019-09-07 02:42:46" "80" "00:00:15"

"417193989" "183" "2019-09-05 10:42:52" "82" "2019-09-05 10:42:23" "0" "00:00:29"

"416891691" "183" "2019-09-05 05:42:51" "78" "2019-09-05 05:42:49" "72" "00:00:02"

"416587222" "183" "2019-09-05 00:42:51" "88" "2019-09-05 00:42:35" "99" "00:00:16"

"416587223" "183" "2019-09-05 00:42:51" "82" "2019-09-05 00:42:35" "99" "00:00:16"

"416587224" "183" "2019-09-05 00:42:51" "80" "2019-09-05 00:42:35" "99" "00:00:16"

id:Big Int. ts_tuid: Big Int. rssi: numeric. batl: real. ts_diff:interval

下面是代码示例:

从CSV加载数据model = (

pd.read_csv("source.csv", parse_dates=['var3', 'var5'], date_parser=lambda x: pd.to_datetime(x))

.assign(

rssi_ts=lambda x: x.loc[:, 'var3'].astype(int) / 10 ** 9,

batl_ts=lambda x: x.loc[:, 'var5'].astype(int) / 10 ** 9,

ts_diff=lambda x: pd.to_timedelta(x.loc[:, 'ts_diff']).astype(int) / 10 ** 9

)

)

# Labels are the values we want to predict

labels_b = np.array(halti['var4'])

# Remove the labels from the features

# axis 1 refers to the columns

features_r = halti.drop('var4', axis = 1)

features_r2 = list(features_r.columns)

# Convert to numpy array

features_r = np.array(features_r)

# Using Skicit-learn to split data into training and testing sets

from sklearn.model_selection import train_test_split

# Split the data into training and testing sets

train_features, test_features, train_labels, test_labels = train_test_split(features_r, labels_b, test_size = 0.25, random_state = 42)

# Import the model we are using

from sklearn.ensemble import RandomForestRegressor

# Instantiate model with 1000 decision trees

rf = RandomForestRegressor(n_estimators = 1000, random_state = 42)

# Train the model on training data

rf.fit(train_features, train_labels);

# Use the forest's predict method on the test data

predictions = rf.predict(test_features)

# Calculate the absolute errors

errors = abs(predictions - test_labels)

# Print out the mean absolute error (mae)

print('Mean Absolute Error:', round(np.mean(errors), 2), 'degrees.')

mape = 100 * (errors / test_labels)

# Calculate and display accuracy

accuracy = 100 - np.mean(mape)

print('Accuracy:', round(accuracy, 2), '%.')

java的mape_python中的MAPE(平均绝对百分比误差)测量结果相关推荐

  1. python使用numpy包编写自定义函数计算MAPE(平均绝对百分比误差)指标mean absolute percentage error (MAPE)、MAPE指标解读、MAPE指标使用的注意事项

    python使用numpy包编写自定义函数计算MAPE(平均绝对百分比误差)指标mean absolute percentage error (MAPE).MAPE指标解读.MAPE指标使用的注意事项 ...

  2. python使用numpy包编写自定义函数计算SMAPE(对称平均绝对百分比误差)指标Symmetric mean absolute percentage error、SMAPE指标解读、指标使用的注

    python使用numpy包编写自定义函数计算SMAPE(对称平均绝对百分比误差)指标Symmetric mean absolute percentage error (SMAPE).SMAPE指标解 ...

  3. 如何在 Python 中计算 MAPE

    平均绝对百分比误差 (MAPE) 通常用于衡量模型的预测准确性.计算如下: MAPE = (1/n) * Σ(|实际 - 预测| / |实际|) * 100 在哪里: Σ – 表示"总和&q ...

  4. java从字符串中提取数字

    1.做一下操作时会一般会用到提取数字操纵: a.列表中有翻页,当新添加的数据不是放在第一条或者最后一条时,需要翻页并循环找到对应的那条数据 b.当新添加的数据放在第一条或者最后一条时,则不需要翻页,只 ...

  5. JAVA Web项目中所出现错误及解决方式合集(不断更新中)

    JAVA Web项目中所出现错误及解决方式合集 前言 一.几个或许会用到的软件下载官网 二.Eclipse的[preferences]下没有[sever]选项 三.Tomcat的安装路径找不到 四.T ...

  6. Java类Demo中存在_Java中的数据类型转换

    先来看一个题: Java类Demo中存在方法func0.func1.func2.func3和func4,请问该方法中,哪些是不合法的定义?( ) public class Demo{ float fu ...

  7. Java数据结构一 —— Java Collections API中的表

    1.Collection接口 位于java.util包中,以下是重要的部分. 1 public interface Collection<AnyType> extends Iterable ...

  8. Java之戳中痛点 - (4)i++ 和 ++i 探究原理

    先看一个例子: package com.test;public class AutoIncrement {public static void main(String[] args) {int a=7 ...

  9. 回归模型和时间序列模型中的MAPE指标是什么?MAPE指标解读、MAPE越大越好还是越小越好、使用MAPE指标的注意事项

    回归模型和时间序列模型中的MAPE指标是什么?MAPE指标解读.MAPE越大越好还是越小越好.使用MAPE指标的注意事项 目录

最新文章

  1. 创建操作/删除多行数据的UITableView的细节
  2. pstools中如何绕过协议提示
  3. JustForex开始提供比特币和比特币现金支付方式
  4. 一句话搞定python六剑客
  5. react-router的使用(二)——NavLink的使用、Switch的作用、Redirect
  6. J.U.C并发框架源码阅读(十七)ReentrantReadWriteLock
  7. 多个相同name的文本输入框,输入其中一个后,使剩下的不能输入值
  8. MATLAB元胞自动机
  9. Java之美[从蛮荒到撬动地球]之设计模式三
  10. SSD选购扫盲指南M.2接口硬盘选择:NVMe于sata3
  11. STM32CubeMX使用教程
  12. SpringMVC项目报错500的可能解决方法
  13. jquery实现类似以前凡客诚品右侧图文切换结合效果
  14. 奥城大学计算机科学专业,我是学工程专业本科毕业,托福70分,GRE1020分,都很低,我想去美国留学马上走,...
  15. 从零写CRNN文字识别 —— (1)准备工作
  16. 【微信公众号】微信扫一扫,条形码/一维码,二维码功能解析
  17. Poland’s ruling Law and Justice party is doing lasting damage
  18. macOS忘记密码后如何修改密码
  19. linux网卡驱动离线安装_手动安装linux网卡驱动方法
  20. P1258 小车问题

热门文章

  1. Git的多人协作模式
  2. ffmpeg文件无法下载
  3. python制作电脑软件_利用PYTHON制作桌面版爬虫软件(二)
  4. Linux的网络协议中的网卡缓冲区
  5. 基础补习—概率—台大叶柄成(第二周)
  6. 惠普安装linux网卡,网络无人职守安装linux PXE
  7. cadence 器件(过孔)被盖油
  8. VLSI 基础知识梳理
  9. 网络安全工程师可以考取哪些有价值的证书?
  10. android afw 开关,androidForWorkApp 资源类型