python剔除最小值_python - 删除行直到达到度量点并提取最小值 - SO中文参考 - www.soinside.com...

这里是解决方法:读取您的数据框(在下面的代码中,将Check列视为int(而不是布尔值),并按增加confidence的顺序进行排序。

现在在将置信度阈值扫描到各行时查看这些值:[ round(df.iloc[n:].Check.mean(), 3) for n in range(len(df.index))]即为[0.8, 0.889, 0.875, 0.857, 0.833, 0.8, 1.0, 1.0, 1.0, 1.0]

在找到截止行n的编号后,df.iloc[n].confidence为您提供了截止置信度值,该值提供> = 0.95的精度。因此,您可以选择截止置信度阈值作为df.iloc[n-1].confidence ... df.iloc[n].confidence]之间的任何数字

代码:import pandas as pd

dat = """confidence Check

1 TRUE

0.72 TRUE

0.68 TRUE

1 TRUE

0.150287157 FALSE

1 TRUE

0.7 TRUE

0.68 TRUE

1 TRUE

0.903333333 FALSE"""

df = pd.read_csv(pd.compat.StringIO(dat), header=0, delim_whitespace=True, dtype={'confidence':'float', 'Check':'int'})

df.sort_values(by='confidence', inplace=True)

df

confidence Check

4 0.150287 0

2 0.680000 1

7 0.680000 1

6 0.700000 1

1 0.720000 1

9 0.903333 0

0 1.000000 1

3 1.000000 1

5 1.000000 1

8 1.000000 1

# Sweep over the df, finding the cutoff row which gives us 0.95 confidence...

for n in range(len(df.index)):

if df.iloc[n:].Check.mean() >= 0.95:

break

# ...then find the range for the cutoff confidence level

print("Cutoff confidence level is between:", df.iloc[n-1].confidence, df.iloc[n].confidence)

# Cutoff confidence level is between: 0.903333333 1.0

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值