我有一个Dataframe,它由一些ML模型组成,有两列,分别用于训练和测试精度
evaluations_df
Out[13]:
Model train_accuracy test_accuracy
0 Logistic Regression 100.000000 86.956522
1 Decision Tree 99.065421 84.782609
2 Random Forest 92.523364 82.608696
3 Ada Boosting 100.000000 89.130435
4 Gradient Boosting 100.000000 84.782609
5 Nearest Neighbors 88.785047 82.608696
6 Support Vector Machine 93.457944 82.608696
7 Naive Bayes 99.065421 89.130435我想绘制类似于这个的图:

其中,x值是模型的数量,其中它的刻度将被模型名称替换,而y值将是一对每个精度度量。
我试过这样的方法:
sns.histplot(data=evaluations_df, x=range(len(evaluations_df)), y=['train_accuracy', 'test_accuracy'],
color=['r', 'b'],
shrink=0.8,
multiple='dodge')但它会引发以下错误:
ValueError: Length of list vectors must match length of `data` when both are used, but `data` has length 8 and the vector passed to `y` has length 2.我似乎无法使用该列表将y值作为一对存储箱进行解包。
发布于 2021-08-23 08:03:18
在不使用seaborn和仅使用pandas的情况下,您可以执行以下操作:
evaluations_df.plot.bar(x='Model', y=['train_accuracy', 'test_accuracy'])https://stackoverflow.com/questions/68889001
复制相似问题