0

I have a dataframe like below:

        f-measure   perc%
class_0  0.98       0.25
class_1  0.86       0.25
class_0  0.98       0.33
class_1  0.86       0.33
class_0  0.97       1.00
class_1  0.75       1.00

How can I draw a curve line showing f-measure where the x-axis represents the perc% column and y-axis represents the f-measure. I think I need two curves one for class_0 and another one for class_1. So how can I draw both curves in the same figure? You are allowed to modify the structure of the dataframe if needed.

bib
  • 944
  • 3
  • 15
  • 32

1 Answers1

1

The fastest way would be using .lineplot from seaborn package.

import seaborn as sns
sns.lineplot(x='perc%', y='f-measure', hue='index', data=df.reset_index())

This is the same as:

for c in df.index.unique():
    plt.plot(df.loc[c, 'perc%'], df.loc[c, 'f-measure'], label=c)
plt.xlabel('perc%')
plt.ylabel('f-measure')
plt.legend(title='index')

The output will be this:

enter image description here

Gusti Adli
  • 1,225
  • 4
  • 13