def compute_AOC(df):
TPR = []
FPR = []
threshold = int
df.sort_values(by='proba', ascending=False )
для каждой строки создайте новый динамически столбец на основе значений в proba
column
for i in range(len(df)):
threshold = df.iloc[i, 1]
df.insert(i+2, i, 'x')
df.loc[(df.proba >= threshold ),i] = 1
df.loc[(df.proba < threshold ),i] = 0
# здесь я пытаюсь получить доступ к вновь созданному столбцу, но df выбрасывает ошибка
fp = len(df[(df.y == 0) & (df.i == 1)])
fn = len(df[(df.y == 1) & (df.i == 0)])
tp = len(df[(df.y == 1) & (df.i == 1)])
tn = len(df[(df.y == 0) & (df.i == 0)])
Recall = (tp/(tp+fn))
Precision = (tp/(tp+fp))
TPR.append(Recall)
FPR.append(Precision)
return TPR, FPR
#here I am iterating every row with i variable and mycolumname should contain ivalue like Threshold_i..and should be able to use that column for ohter filters. In the above case i'am not able to call because my column name is a number and it pops an error "no attribute as such in dataframe"