Home > Software design >  Cannot read f1-score from csv file
Cannot read f1-score from csv file

Time:09-07

i am reading classification_report file after doing 10 fold cv
for i in _all_files:
    print(i)
    df = pd.read_csv(i)


    saved_column = df.f1-score
    a = saved_column[5]
    li.append(a)
print(li)
print(sum(li))
print(len(li))
print(sum(li)/len(li))

I want to add f1-score and find mean. But I am getting below error. I am able to fetch accuracy, precision and recall score using above code but bot f2-score. The error I am getting is "AttributeError: 'DataFrame' object has no attribute 'f1' "

CodePudding user response:

Use:

saved_column = df['f1-score']

Hyphens are not allowed as part of an attribute name. That is, using the dot notation.

CodePudding user response:

Maybe this way is necessary:

saved_column = df['f1-score']
a = saved_column.iloc[5]
  • Related