简体   繁体   中英

Cannot read f1-score from csv file

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' "

Use:

saved_column = df['f1-score']

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

Maybe this way is necessary:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM