【发布时间】:2021-08-23 07:51:18
【问题描述】:
我有一个 Dataframe,其中包含一些 ML 模型,其中 2 列分别用于训练和测试精度
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 值解压缩为带有该列表的一对箱子。
【问题讨论】:
-
直接调用
sns.histplot,需要将dataframe转成long form。
标签: python python-3.x seaborn