编程语言
首页 > 编程语言> > CSP期末预测之最佳阈值——python版

CSP期末预测之最佳阈值——python版

作者:互联网

m = input()
y = []
result = []
dic = dict()
def predict(y,seita):
    if y < seita:
        return 0
    else:
        return 1

def getkey(dic,maxvalue):
    dic = dict(dic)
    indexs = []
    for key,value in dic.items():
        if value == maxvalue:
            indexs.append(key)
    return max(indexs)


for i in range(int(m)):
    y_,result_ = input().split()
    y_ = int(y_)
    result_ = int(result_)
    y.append(y_)
    result.append(result_)
    if y_<0 or y_>10**8:
        pass

for seita in y:
    count = 0
    for index,yi in enumerate(y):
        if predict(yi,seita) == result[index]:
            count = count + 1
    dic[seita] = count

print(getkey(dic,max(dic.values())))


标签:count,阈值,python,seita,dic,result,indexs,CSP,append
来源: https://blog.csdn.net/weixin_44330842/article/details/113805565