如何在R语言的ggplot2中设置y轴以比较机器学习模型

我有一个机器学习模型准确率的数据集,我希望通过箱线图来进行比较,但我不知道如何将y轴设置为准确率。

我的数据是模型在每次交叉验证中的准确率:

Model     1         2          3            4          5           6            7           8           9        10LR  0.69047619  0.71428571  0.61904762  0.57142857  0.69047619  0.69047619  0.73809524  0.76190476  0.78571429  0.76190476SVM 0.80952381  0.76190476  0.76190476  0.76190476  0.80952381  0.76190476  0.78571429  0.76190476  0.88095238  0.88095238RF  0.73809524  0.61904762  0.52380952  0.61904762  0.73809524  0.71428571  0.73809524  0.71428571  0.88095238  0.71428571GBM 0.83333333  0.83333333  0.73809524  0.73809524  0.78571429  0.83333333  0.80952381  0.80952381  0.88095238  0.85714286MLP 0.85714286  0.80952381  0.80952381  0.76190476  0.78571429  0.83333333  0.76190476  0.92857143  0.92857143  0.85714286Keras   0.9047619   0.85714286  0.80952381  0.85714286  0.83333333  0.78571429  0.88095238  0.92857143  0.88095238  0.92857143

我尝试过:

accuracy <- c(0,1)p <- ggplot(bxplt, aes(Model, accuracy))p + geom_boxplot()Error: Aesthetics must be either length 1 or the same as the data (6): y

我觉得自己可能忽略了一些显而易见的东西,但我找不到任何足够相似的问题或具有类似示例的资源,任何帮助将不胜感激。

dput(bxplt)structure(list(Model = structure(c(3L, 6L, 5L, 1L, 4L, 2L), .Label = c("GBM", "Keras", "LR", "MLP", "RF", "SVM"), class = "factor"), X1 = c(0.69047619, 0.80952381, 0.73809524, 0.83333333, 0.85714286, 0.9047619), X2 = c(0.71428571, 0.76190476, 0.61904762, 0.83333333, 0.80952381, 0.85714286),     X3 = c(0.61904762, 0.76190476, 0.52380952, 0.73809524, 0.80952381,     0.80952381), X4 = c(0.57142857, 0.76190476, 0.61904762, 0.73809524,     0.76190476, 0.85714286), X5 = c(0.69047619, 0.80952381, 0.73809524,     0.78571429, 0.78571429, 0.83333333), X6 = c(0.69047619, 0.76190476,     0.71428571, 0.83333333, 0.83333333, 0.78571429), X7 = c(0.73809524,     0.78571429, 0.73809524, 0.80952381, 0.76190476, 0.88095238    ), X8 = c(0.76190476, 0.76190476, 0.71428571, 0.80952381,     0.92857143, 0.92857143), X9 = c(0.78571429, 0.88095238, 0.88095238,     0.88095238, 0.92857143, 0.88095238), X10 = c(0.76190476,     0.88095238, 0.71428571, 0.85714286, 0.85714286, 0.92857143    )), class = "data.frame", row.names = c(NA, -6L))

回答:

你应该重塑你的数据框:

library(tidyverse)df %>%  gather(key = "fold", value = "accuracy", -Model) %>%  ggplot(aes(Model, accuracy)) +  geom_boxplot()

enter image description here

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注