计算误差

作者: 兀o | 来源:发表于2019-01-13 19:06 被阅读0次
  1. 每个数据集的实际列和预测列,使用 jud_data 找出数据集的误差比例,以及每种类型的误差百分比。

测试题目提示: 误差是指,任何时候,预测值不符合实际值的情况。此外,还有类型I和类型II的误差需要考虑。我们也知道我们可以通过最大化其他类型的误差来最小化某一种类型的误差。如果我们预测所有的个体都是无辜的,那么有多少有罪的人被贴上了错误的标签?同样,如果我们预测所有人都有罪,那么有多少无辜的人被贴上了错误的标签?

  1. 使用 par_data 找出数据集的误差比例,以及每种类型的误差百分比。
import numpy as np
import pandas as pd

jud_data = pd.read_csv('judicial_dataset_predictions.csv')
par_data = pd.read_csv('parachute_dataset.csv')
jud_data.head()
par_data.head()
  1. Above, you can see the actual and predicted columns for each of the datasets. Using the jud_data, find the proportion of errors for the dataset, and furthermore, the percentage of errors of each type. Use the results to answer the questions in quiz 1 below.
jud_data[jud_data['actual'] != jud_data['predicted']].shape[0]/jud_data.shape[0] # Number of errros
jud_data.query("actual == 'innocent' and predicted == 'guilty'").count()[0]/jud_data.shape[0] # Type 1
jud_data.query("actual == 'guilty' and predicted == 'innocent'").count()[0]/jud_data.shape[0] # Type 2
#If everyone was predicted as guilty, then every actual innocent 
#person would be a type I error.
# Type I = pred guilty, but actual = innocent
jud_data[jud_data['actual'] == 'innocent'].shape[0]/jud_data.shape[0]
  1. Above, you can see the actual and predicted columns for each of the datasets. Using the par_data, find the proportion of errors for the dataset, and furthermore, the percentage of errors of each type. Use the results to answer the questions in quiz 2 below.
par_data[par_data['actual'] != par_data['predicted']].shape[0]/par_data.shape[0] # Number of errros
par_data.query("actual == 'fails' and predicted == 'opens'").count()[0]/par_data.shape[0] # Type 1
par_data.query("actual == 'opens' and predicted == 'fails'").count()[0]/par_data.shape[0] # Type 2
#If every parachute was predicted to not open, 
#the proportion of Type II Errors made.  

# This would just be the total of actual opens in the dataset, 
# as we would label these all as not open, but actually they open

# Type II = pred no open, but actual = open
par_data[par_data['actual'] == 'opens'].shape[0]/par_data.shape[0]

相关文章

  • UICollectionViewFlowLayout计算item

    使用UICollectionViewFlowLayout时, cell的宽度计算误差导致collectionVie...

  • 计算误差

    每个数据集的实际列和预测列,使用 jud_data 找出数据集的误差比例,以及每种类型的误差百分比。 测试题目提示...

  • 关于OC中的精度计算NSDecimalNumber

    //NSDecimalNumber是NSNumber的子类,是苹果针对浮点型计算时存在精度计算误差的问题而提供的一...

  • js计算精度误差解决方案

    小数计算误差 先乘以小数点位数,计算后再除以位数 转字符串 toFixed() xx.5误差

  • NSDecimalNumber 介绍

    NSDecimalNumber是NSNumber的不可变子类。苹果针对浮点型计算时存在精度计算误差的问题而提供的一...

  • 2019-08-14

    NSDecimalNumber是NSNumber的不可变子类。苹果针对浮点型计算时存在精度计算误差的问题而提供的一...

  • js处理浮点数计算误差(精确度)

    js处理浮点数计算误差众所周知, 浮点计算会产生舍入误差的问题, 比如, 0.1 + 0.2, 结果应该是0 .3...

  • JS计算误差小谈

    平时在写 js 代码时会用到一些简单的计算,比方说系统中我们数据库储存的金额是分,前端展示的是元,所以在用户输入元...

  • [R] 添加误差棒的分组折线图:geom_path: Each

    想做一个简单的分组折线图,并添加误差棒,类似下面这样的: 计算误差需要安装Rmisc包中的summarySE函数。...

  • 浮点数计算误差解析

    浮点运算 近期因为在公司的新系统刚上线不久,还在每日填坑监控中,所以会定期拉取error级别日志来观察系统稳定,在...

网友评论

    本文标题:计算误差

    本文链接:https://www.haomeiwen.com/subject/ovyldqtx.html