400多个线图的ggplot颜色相互重叠

时间:2018-05-22 12:42:43

标签: r ggplot2

我有这个数据,我试图绘制。下面我列出了前500个观察中的dput,但是如果这还不够,我已经在dropbox上传了.csv文件。

我正在尝试做两件事。

首先将配色方案更改为更美观的配色方案。我查看了scale_colour_manualscale_colour_brewer命令,但没有任何工作,我是否正确认为colour = factor(group_id)是否覆盖了这些命令?

plot <- combo_data %>%
  ggplot(aes(ID)) + 
  geom_line(aes(y = value, colour = factor(group_id))) +
  facet_wrap("type", scales = "free") +
  labs(title = "data", y = "y score", x = "x result") +
  theme_bw(base_size = 11, base_family = "") +
  theme(aspect.ratio = 1) + theme(legend.position="none")

plot

其次,我认为以不同的尺寸和颜色绘制最佳线条可能会很有趣。我对最佳线的意思是在测试数据上在迭代100处得分最高的线。然后在测试线和火车线上将此线显示为黑色。我不确定从哪里开始。

structure(list(type = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("Train", 
"Test"), class = "factor"), group_id = structure(c(75L, 75L, 
75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 
75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 
75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 
75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 
75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 
75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 
75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 75L, 
75L, 75L, 75L, 75L, 75L, 75L, 75L, 60L, 60L, 60L, 60L, 60L, 60L, 
60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 
60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 
60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 
60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 
60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 
60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 
60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 60L, 
60L, 60L, 60L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 
95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 
95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 
95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 
95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 
95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 
95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 
95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 95L, 87L, 
87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 
87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 
87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 
87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 
87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 
87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 
87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 
87L, 87L, 87L, 87L, 87L, 87L, 87L, 87L, 198L, 198L, 198L, 198L, 
198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 
198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 
198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 
198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 
198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 
198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 
198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 
198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 
198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L), .Label = c("373", 
"157", "169", "277", "61", "385", "253", "265", "361", "145", 
"37", "49", "170", "38", "266", "158", "278", "62", "146", "50", 
"374", "254", "267", "386", "362", "63", "255", "279", "51", 
"39", "375", "171", "159", "387", "363", "147", "268", "172", 
"280", "40", "376", "256", "64", "160", "52", "148", "388", "364", 
"26", "350", "242", "134", "230", "349", "122", "133", "25", 
"110", "218", "2", "14", "241", "326", "13", "229", "338", "28", 
"337", "109", "325", "352", "136", "121", "340", "1", "244", 
"217", "16", "232", "27", "328", "124", "112", "135", "351", 
"220", "4", "15", "327", "231", "243", "123", "339", "111", "3", 
"219", "281", "389", "65", "173", "392", "284", "66", "68", "390", 
"174", "176", "377", "282", "53", "67", "272", "391", "175", 
"164", "269", "54", "161", "283", "56", "162", "270", "380", 
"378", "365", "260", "41", "163", "257", "150", "368", "149", 
"271", "42", "258", "44", "379", "366", "152", "55", "259", "151", 
"367", "43", "291", "30", "356", "138", "354", "246", "32", "18", 
"140", "248", "342", "245", "353", "183", "236", "126", "128", 
"137", "234", "29", "344", "20", "222", "116", "31", "114", "224", 
"195", "6", "332", "8", "247", "330", "233", "355", "17", "341", 
"421", "409", "125", "313", "139", "73", "193", "399", "85", 
"329", "205", "181", "127", "303", "289", "343", "5", "221", 
"235", "99", "113", "97", "397", "301", "19", "423", "411", "207", 
"87", "331", "115", "315", "75", "223", "7", "206", "182", "184", 
"314", "422", "98", "410", "74", "302", "194", "208", "86", "290", 
"100", "400", "398", "424", "292", "304", "88", "412", "196", 
"316", "76", "69", "395", "285", "179", "393", "287", "71", "177", 
"72", "180", "288", "396", "273", "167", "381", "165", "383", 
"275", "57", "59", "286", "394", "178", "70", "168", "369", "384", 
"153", "60", "45", "263", "261", "276", "371", "155", "47", "58", 
"166", "382", "274", "48", "156", "264", "372", "154", "262", 
"370", "46", "317", "101", "425", "209", "141", "357", "249", 
"359", "33", "251", "35", "36", "143", "360", "144", "252", "250", 
"319", "103", "305", "89", "77", "413", "142", "211", "358", 
"197", "34", "293", "427", "401", "185", "240", "307", "24", 
"348", "132", "199", "345", "91", "415", "237", "129", "295", 
"403", "130", "187", "21", "347", "23", "239", "131", "238", 
"22", "79", "346", "12", "228", "336", "120", "225", "333", "226", 
"118", "334", "117", "9", "10", "11", "227", "335", "119", "102", 
"426", "318", "210", "428", "104", "198", "320", "414", "212", 
"306", "90", "200", "416", "308", "186", "92", "294", "402", 
"78", "404", "80", "296", "188", "105", "429", "213", "321", 
"431", "107", "323", "215", "214", "322", "106", "430", "309", 
"417", "93", "201", "432", "324", "216", "108", "419", "95", 
"311", "203", "418", "310", "202", "312", "420", "94", "96", 
"204", "405", "297", "189", "407", "81", "406", "408", "298", 
"191", "299", "300", "83", "190", "82", "84", "192"), class = "factor"), 
    value = c(0.841206, 0.8618822, 0.875903, 0.88118, 0.8839989, 
    0.886475, 0.8882447, 0.8894316, 0.8908262, 0.8921857, 0.8932049, 
    0.8942344, 0.8951237, 0.8957491, 0.896584, 0.8973019, 0.8981658, 
    0.8989417, 0.8996812, 0.9004134, 0.901327, 0.9018033, 0.9024117, 
    0.903043, 0.9037018, 0.9042794, 0.9048006, 0.9052915, 0.9058164, 
    0.9063951, 0.9068556, 0.9073168, 0.9078021, 0.9082714, 0.9088147, 
    0.9091887, 0.9096099, 0.909963, 0.9103733, 0.9107867, 0.9111795, 
    0.9115447, 0.9119722, 0.9123242, 0.9126455, 0.9129585, 0.9132838, 
    0.9135908, 0.9138768, 0.9141479, 0.9144209, 0.9146787, 0.914935, 
    0.9152107, 0.9154533, 0.9157019, 0.9159447, 0.9161997, 0.916484, 
    0.9167047, 0.9169661, 0.9171712, 0.9173915, 0.9176118, 0.9178227, 
    0.918049, 0.9182602, 0.9184434, 0.9186592, 0.9188716, 0.9190693, 
    0.9192857, 0.9195024, 0.9196496, 0.9198572, 0.9200831, 0.9202567, 
    0.9204585, 0.9206453, 0.9208152, 0.9210011, 0.9212046, 0.9213677, 
    0.9215177, 0.9217053, 0.9218623, 0.9220282, 0.9221877, 0.9223855, 
    0.9225362, 0.9227441, 0.9229132, 0.9230628, 0.9232101, 0.9233585, 
    0.9234887, 0.9236338, 0.9237964, 0.9239475, 0.9241024, 0.8384197, 
    0.8657936, 0.8742507, 0.8790596, 0.8816859, 0.8840703, 0.8857966, 
    0.8873143, 0.8893761, 0.8908329, 0.8924197, 0.8937073, 0.8946219, 
    0.8957115, 0.8967053, 0.8976097, 0.8983678, 0.8991453, 0.8999762, 
    0.9006377, 0.9011831, 0.9018029, 0.902479, 0.9030517, 0.9036508, 
    0.9041685, 0.9048059, 0.9053054, 0.9059556, 0.9065373, 0.9070341, 
    0.9075528, 0.9080415, 0.9086106, 0.9090282, 0.9094788, 0.909848, 
    0.9102646, 0.9106493, 0.9110334, 0.9114573, 0.9118822, 0.9122389, 
    0.9125876, 0.9129038, 0.9132206, 0.9135435, 0.9138549, 0.9141243, 
    0.9144137, 0.9147554, 0.9150141, 0.9152936, 0.9155378, 0.9158067, 
    0.9160321, 0.9162476, 0.9164621, 0.9167002, 0.9169366, 0.9171693, 
    0.91737, 0.9175802, 0.9177766, 0.9180018, 0.9182022, 0.9183998, 
    0.918624, 0.9187906, 0.9189664, 0.919135, 0.9193349, 0.9195179, 
    0.9197035, 0.9198967, 0.9200179, 0.920191, 0.9203527, 0.9205381, 
    0.9206639, 0.9207979, 0.9209801, 0.9211415, 0.9212902, 0.9214497, 
    0.9216006, 0.921792, 0.9219525, 0.9220746, 0.9222501, 0.9224183, 
    0.9225453, 0.9227172, 0.9228856, 0.9230288, 0.9231751, 0.9232918, 
    0.9234427, 0.9235908, 0.923704, 0.8521024, 0.8599692, 0.8650719, 
    0.8698721, 0.8742038, 0.8779644, 0.8805255, 0.8821768, 0.8841775, 
    0.8863809, 0.8885177, 0.8902829, 0.8918345, 0.8934113, 0.8948588, 
    0.8959888, 0.8970833, 0.8978984, 0.8988414, 0.8996618, 0.9004221, 
    0.9011989, 0.9020187, 0.9027475, 0.9034219, 0.9040693, 0.9047331, 
    0.9052631, 0.9058026, 0.906447, 0.9069784, 0.9074736, 0.9080329, 
    0.9085461, 0.9089783, 0.9094398, 0.909851, 0.910268, 0.9106672, 
    0.9110267, 0.9114393, 0.9118172, 0.9121966, 0.9125761, 0.9129089, 
    0.9132603, 0.9135873, 0.9139339, 0.9142628, 0.9145902, 0.9149295, 
    0.9152295, 0.9154791, 0.9157817, 0.9160329, 0.9162877, 0.916573, 
    0.9168525, 0.9170776, 0.9173148, 0.9175679, 0.9177926, 0.9179937, 
    0.9182309, 0.9184223, 0.9186295, 0.9188425, 0.9190884, 0.919309, 
    0.9195113, 0.91972, 0.9199461, 0.9201244, 0.9203068, 0.9204946, 
    0.9207167, 0.9208302, 0.9210215, 0.9211949, 0.9213679, 0.9215854, 
    0.9217385, 0.9219124, 0.9221097, 0.9222984, 0.9224837, 0.9226755, 
    0.9228615, 0.9230026, 0.9232086, 0.9233537, 0.9234917, 0.9236705, 
    0.9238187, 0.9239422, 0.9241217, 0.9242824, 0.9244052, 0.9245568, 
    0.9247348, 0.8530171, 0.8589155, 0.8649798, 0.869903, 0.8740718, 
    0.8779266, 0.8812847, 0.8830766, 0.8845762, 0.8865907, 0.8886054, 
    0.8900654, 0.891648, 0.893375, 0.8949505, 0.8960962, 0.8972805, 
    0.8983584, 0.8992835, 0.9001622, 0.9010127, 0.9017991, 0.9024695, 
    0.903095, 0.9037992, 0.9045072, 0.9051554, 0.9057973, 0.9064632, 
    0.9070142, 0.907557, 0.908059, 0.9085351, 0.9090597, 0.9095042, 
    0.909992, 0.9103988, 0.9108294, 0.9113101, 0.9116431, 0.9120507, 
    0.9124416, 0.9128079, 0.9131532, 0.9134848, 0.9137904, 0.9141308, 
    0.9144465, 0.9147451, 0.915065, 0.9153496, 0.9156175, 0.9158787, 
    0.9161347, 0.9163608, 0.9166158, 0.9168822, 0.9170952, 0.9173387, 
    0.9175292, 0.9177493, 0.9179786, 0.9181876, 0.9183715, 0.9185886, 
    0.918782, 0.9189904, 0.9192009, 0.9193388, 0.9195374, 0.9197003, 
    0.9198778, 0.9200472, 0.9201834, 0.920368, 0.920576, 0.9207296, 
    0.9209001, 0.9210757, 0.9212034, 0.9213856, 0.9215478, 0.9217044, 
    0.9218511, 0.9220772, 0.9222213, 0.9223657, 0.9225307, 0.9226667, 
    0.9228219, 0.9230022, 0.9231716, 0.9233128, 0.9234431, 0.9235595, 
    0.9237126, 0.923853, 0.9240294, 0.9241574, 0.9243085, 0.8718445, 
    0.8931301, 0.8988919, 0.90295, 0.9055216, 0.9073954, 0.9082992, 
    0.9094717, 0.910552, 0.9115187, 0.9123528, 0.9131647, 0.91393, 
    0.9148608, 0.9156235, 0.9163686, 0.9170021, 0.9177401, 0.9185156, 
    0.9192533, 0.9200075, 0.9207595, 0.9214583, 0.9221539, 0.9227934, 
    0.9234405, 0.9241619, 0.9247472, 0.9253838, 0.925926, 0.9265156, 
    0.9271585, 0.9277358, 0.9283588, 0.9289936, 0.9294738, 0.9299869, 
    0.9304908, 0.9309697, 0.9314306, 0.9319144, 0.9323344, 0.9327798, 
    0.9331807, 0.9336512, 0.9340747, 0.9344835, 0.9349425, 0.9353857, 
    0.9357808, 0.9361138, 0.9364561, 0.9368398, 0.9371623, 0.9375385, 
    0.9378483, 0.9382014, 0.9385149, 0.9388302, 0.9390995, 0.9394548, 
    0.9397823, 0.9401236, 0.9404473, 0.9407854, 0.9410838, 0.941425, 
    0.9417274, 0.942012, 0.9423166, 0.9426162, 0.9428458, 0.9431165, 
    0.9434549, 0.9437244, 0.9439903, 0.9442947, 0.9445493, 0.9448181, 
    0.9450798, 0.9452847, 0.9455464, 0.9458335, 0.9460275, 0.9462473, 
    0.9464572, 0.9466602, 0.9469266, 0.9471858, 0.9473951, 0.9476667, 
    0.9479168, 0.9481527, 0.9483371, 0.9485883, 0.9488048, 0.949047, 
    0.9492654, 0.9494981, 0.9497255), ID = c(1L, 2L, 3L, 4L, 
    5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 
    18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 
    30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 
    42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 
    54L, 55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 63L, 64L, 65L, 
    66L, 67L, 68L, 69L, 70L, 71L, 72L, 73L, 74L, 75L, 76L, 77L, 
    78L, 79L, 80L, 81L, 82L, 83L, 84L, 85L, 86L, 87L, 88L, 89L, 
    90L, 91L, 92L, 93L, 94L, 95L, 96L, 97L, 98L, 99L, 100L, 1L, 
    2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 
    15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 
    27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 
    39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 
    51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 
    63L, 64L, 65L, 66L, 67L, 68L, 69L, 70L, 71L, 72L, 73L, 74L, 
    75L, 76L, 77L, 78L, 79L, 80L, 81L, 82L, 83L, 84L, 85L, 86L, 
    87L, 88L, 89L, 90L, 91L, 92L, 93L, 94L, 95L, 96L, 97L, 98L, 
    99L, 100L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 
    12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 
    24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 
    36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 
    48L, 49L, 50L, 51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L, 
    60L, 61L, 62L, 63L, 64L, 65L, 66L, 67L, 68L, 69L, 70L, 71L, 
    72L, 73L, 74L, 75L, 76L, 77L, 78L, 79L, 80L, 81L, 82L, 83L, 
    84L, 85L, 86L, 87L, 88L, 89L, 90L, 91L, 92L, 93L, 94L, 95L, 
    96L, 97L, 98L, 99L, 100L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 
    9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 
    21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 
    33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 
    45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L, 55L, 56L, 
    57L, 58L, 59L, 60L, 61L, 62L, 63L, 64L, 65L, 66L, 67L, 68L, 
    69L, 70L, 71L, 72L, 73L, 74L, 75L, 76L, 77L, 78L, 79L, 80L, 
    81L, 82L, 83L, 84L, 85L, 86L, 87L, 88L, 89L, 90L, 91L, 92L, 
    93L, 94L, 95L, 96L, 97L, 98L, 99L, 100L, 1L, 2L, 3L, 4L, 
    5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 
    18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 
    30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 
    42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 
    54L, 55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 63L, 64L, 65L, 
    66L, 67L, 68L, 69L, 70L, 71L, 72L, 73L, 74L, 75L, 76L, 77L, 
    78L, 79L, 80L, 81L, 82L, 83L, 84L, 85L, 86L, 87L, 88L, 89L, 
    90L, 91L, 92L, 93L, 94L, 95L, 96L, 97L, 98L, 99L, 100L)), .Names = c("type", 
"group_id", "value", "ID"), row.names = c(NA, -500L), class = c("tbl_df", 
"tbl", "data.frame"))

编辑:xgbmodel.cv$evaluation_log

structure(list(iter = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 
13, 14, 15, 16, 17, 18, 19, 20), train_auc_mean = c(0.8783153, 
0.8953862, 0.900536, 0.9030217, 0.9049995, 0.9066914, 0.9080874, 
0.9088161, 0.9100754, 0.9108984, 0.912043, 0.9128935, 0.9137224, 
0.91465, 0.9154111, 0.9162045, 0.916924, 0.9176951, 0.9183826, 
0.9189338), train_auc_std = c(0.00717009945607681, 0.00249586501237372, 
0.00269250771585954, 0.00254956443534881, 0.00232702583784572, 
0.00181327638266765, 0.00133006362257542, 0.0013852951634466, 
0.00113504547930466, 0.00130808304018898, 0.00111638568601384, 
0.00112030141031364, 0.000975854825194455, 0.00115169779023825, 
0.00108698007799259, 0.00111895515998081, 0.00100959803891298, 
0.000955721345432234, 0.000954352681180355, 0.000932746782367693
), test_auc_mean = c(0.8679278, 0.8843016, 0.8896035, 0.8919551, 
0.8938367, 0.8955483, 0.8964231, 0.8969212, 0.8978634, 0.8986166, 
0.899632, 0.9003129, 0.9007414, 0.9013951, 0.9017771, 0.9022693, 
0.9027743, 0.9030824, 0.9035715, 0.9037952), test_auc_std = c(0.00695311168901748, 
0.00404615660101717, 0.00577139448054154, 0.0057856306907767, 
0.00606116769360227, 0.00624799443101764, 0.00538974117096598, 
0.00540648223525145, 0.00556229789206102, 0.00540702262249037, 
0.00515849813414524, 0.00518186297484329, 0.00513731438008862, 
0.00526564910433983, 0.0053733205273774, 0.00549749955981443, 
0.00561555858396273, 0.0057395095469953, 0.00560829002906322, 
0.00561293322246843)), .Names = c("iter", "train_auc_mean", "train_auc_std", 
"test_auc_mean", "test_auc_std"), class = c("data.table", "data.frame"
), row.names = c(NA, -20L), .internal.selfref = <pointer: 0x00000000047e0788>)

1 个答案:

答案 0 :(得分:9)

我要做的是:绘制所有具有相同颜色和低alpha(甚至低于0.1的曲线)的曲线,并绘制不同颜色的最佳曲线(我在本例中只选了一个随机曲线)

library(tidyverse)
combo_data %>%
  ggplot(aes(ID)) + 
  geom_path(aes(y = value, group = group_id), color = "black", alpha =0.1) +
  facet_wrap("type", scales = "free") +
  geom_path(data = combo_data %>%
              filter(group_id == 12), aes(y = value), color = "orange")

enter image description here

我不认为你可以为400个团队做得更好(除非使用交互式图(例如plotly),这样可以在两个方面中挑出每一行)。

这是方法:

combo_data %>%
  ggplot(aes(ID)) + 
  geom_path(aes(y = value, group = group_id), color = "black", alpha =0.1) +
  geom_path(aes(y = value, frame = group_id), color = "orange") +
  facet_wrap("type", scales = "free") +
  labs(title = "data", y = "y score", x = "x result") +
  theme_bw(base_size = 11, base_family = "") +
  theme(aspect.ratio = 1) + theme(legend.position="none") ->p

library(plotly)
ggplotly(p)  

enter image description here

在这里你可以看到一个可以播放的滑块,它会在动画中逐个显示所有的线条。

EDIT1:顺便提一下,我建议检查那些在测试集中开始下降的ROC曲线。 ROC曲线不应下降(根据定义)。 根据评论,这些不是ROC曲线。从我的回答中删除了对ROC的提及。

EDIT2:如果你想要一个传奇:

combo_data %>%
  mutate(what = factor(ifelse(group_id == 12,
                                 "the_one",
                                 "all_others"))) %>% #create  grouping variable
  ggplot(aes(ID)) + 
  geom_path(aes(y = value, group = group_id, color = what, alpha = what)) + #color by grouping variable and alpha by it as well
  facet_wrap("type", scales = "free") +
  scale_color_manual(values = c("grey50", "orange")) + #I like this color combo
  scale_alpha_manual(values = c(0.05, 1)) +
  guides(alpha = guide_legend(override.aes = list(alpha = 1))) #so the legend is meaningful 

enter image description here

获取具有最高测试值的曲线首先找到值:

combo_data %>%
  filter(type == "Test") %>%
  summarise(max = max(value)) %>%
  pull(max) -> best_val

然后用它来标记组:

combo_data %>%
  group_by(group_id) %>%
  mutate(what = factor(ifelse(any(value == best_val),
                              "the_one",
                              "all_others"))) %>%
  ggplot(aes(ID)) + 
  geom_path(aes(y = value, group = group_id, color = what, alpha = what)) +
  facet_wrap("type", scales = "free") +
  scale_color_manual(values = c("grey50", "orange")) +
  scale_alpha_manual(values = c(0.05, 1)) +
  guides(alpha = guide_legend(override.aes = list(alpha = 1)))

enter image description here