在R中用predict()重新生成rpart()模型时获得一致的分类

时间:2019-04-03 09:44:06

标签: r predict rpart

这是我过去几天经常遇到的问题。

我拥有以下数据集,用于测试rpart()模型的准确性:

> head(resp41366_observed)
   ACTIVITY_X ACTIVITY_Y       observed 
1:         29         19 Feeding/Moving
2:         34         30 Moving/Feeding
3:         51         47 Moving/Feeding
4:         78         38 Moving/Feeding
5:         18         17 Feeding/Moving
6:          4          0 Feeding/Moving

模型是:

xtree <- rpart(classification ~ ACTIVITY_X + ACTIVITY_Y , data = train, method = "class", parms = list(split = "information"))

为了测试模型的准确性,我使用resp41366来预测resp41366$observed中看到的类,然后将模型预测的类与resp41366$observed类进行比较。

我正在使用的预测变量数据集为pred41361,其格式与resp41366完全相同。这是代码:

#Running the model
> resp41366_pred413561 = predict(xtree,resp41366,type="class")
> resp41366_pred413561<-data.table(resp41366_pred413561)
> names(resp41366_pred413561)="predicted"
#Merging the observed classes with the predicted classes by the model
> test_accuracy<-cbind(resp41366_observed,resp41366_pred413561)
> head(test_accuracy)
         observed      predicted
1: Feeding/Moving Moving/Feeding
2: Moving/Feeding Moving/Feeding
3: Moving/Feeding Moving/Feeding
4: Moving/Feeding Moving/Feeding
5: Feeding/Moving Feeding/Moving
6: Feeding/Moving Feeding/Moving
#Calculating accuracy
> obs<-as.factor(test_accuracy$observed)
> pred<-as.factor(test_accuracy$predicted)
> mean(obs == pred)
[1] 0.8208556

如果predicted类与observed类非常匹配,这是一个完美的方案。但是,如果重新生成test_accuracy,则可能会发生以下情况(例如):

#Calculating accuracy
> obs<-as.factor(test_accuracy$observed)
> pred<-as.factor(test_accuracy$predicted)
> mean(obs == pred)
[1] 0.02345

发生这种情况时,我可以通过如下改组predicted类,使它们再次与observed类兼容,将精度恢复到0.8208556:

1)将Feeding/Moving替换为Standing

2)将Moving/Feeding替换为Feeding/Moving

3)将Standing替换为Moving/Feeding

我的问题:是否有一种预定义类的方法,这样我总是得到一致的分类,而无需事后重新安排类?实施predict()时可能会丢失某些东西吗?

我希望有人可以帮助我解决这个问题,因为我需要将此模型用于observed类未知的数据集,并且每次重新生成数据时都需要具有一致的分类。

感谢任何输入!


代码:

#80:20 data split for cross-validation
trainIndex  <- sample(1:nrow(tableresults), 0.8 * nrow(tableresults))
train <- tableresults[trainIndex,]
test <- tableresults[-trainIndex,]
#Model implementation
xtree <- rpart(classification ~ ACTIVITY_X + ACTIVITY_Y , data = train, method = "class", parms = list(split = "information"))

数据详细信息:

> dput(tableresults)
structure(list(ACTIVITY_X = c(40L, 60L, 62L, 60L, 66L, 60L, 57L, 
54L, 52L, 93L, 80L, 14L, 61L, 51L, 40L, 20L, 21L, 5L, 53L, 48L, 
73L, 73L, 21L, 29L, 63L, 59L, 57L, 51L, 53L, 67L, 72L, 74L, 70L, 
60L, 74L, 85L, 77L, 68L, 58L, 80L, 34L, 45L, 34L, 60L, 75L, 62L, 
66L, 51L, 53L, 48L, 62L, 62L, 57L, 5L, 1L, 12L, 23L, 5L, 4L, 
0L, 13L, 45L, 44L, 31L, 68L, 88L, 43L, 70L, 18L, 83L, 71L, 67L, 
75L, 74L, 49L, 90L, 44L, 64L, 57L, 22L, 29L, 52L, 37L, 32L, 120L, 
45L, 22L, 54L, 30L, 9L, 27L, 14L, 3L, 29L, 12L, 61L, 60L, 29L, 
15L, 7L, 6L, 0L, 2L, 0L, 4L, 1L, 7L, 0L, 0L, 0L, 0L, 0L, 1L, 
23L, 49L, 46L, 8L, 31L, 45L, 60L, 37L, 61L, 52L, 51L, 38L, 86L, 
60L, 41L, 43L, 40L, 42L, 42L, 48L, 64L, 71L, 59L, 0L, 27L, 12L, 
3L, 0L, 0L, 8L, 21L, 6L, 2L, 7L, 4L, 3L, 3L, 46L, 46L, 59L, 53L, 
37L, 44L, 39L, 49L, 37L, 47L, 17L, 36L, 32L, 33L, 26L, 12L, 8L, 
31L, 35L, 27L, 27L, 24L, 17L, 35L, 39L, 28L, 54L, 5L, 0L, 0L, 
0L, 0L, 17L, 22L, 25L, 12L, 0L, 5L, 41L, 51L, 66L, 39L, 32L, 
53L, 43L, 40L, 44L, 45L, 48L, 51L, 41L, 45L, 39L, 46L, 59L, 31L, 
5L, 24L, 18L, 5L, 15L, 13L, 0L, 26L, 0L), ACTIVITY_Y = c(47L, 
74L, 63L, 56L, 61L, 53L, 40L, 41L, 49L, 32L, 54L, 13L, 99L, 130L, 
38L, 14L, 6L, 5L, 94L, 96L, 38L, 43L, 29L, 47L, 66L, 47L, 38L, 
31L, 36L, 35L, 38L, 72L, 54L, 44L, 45L, 51L, 80L, 48L, 39L, 85L, 
42L, 39L, 37L, 75L, 36L, 45L, 32L, 35L, 41L, 26L, 99L, 163L, 
124L, 0L, 0L, 24L, 37L, 0L, 6L, 0L, 29L, 29L, 26L, 27L, 54L, 
147L, 82L, 98L, 12L, 83L, 97L, 104L, 128L, 81L, 42L, 102L, 60L, 
79L, 58L, 15L, 14L, 75L, 75L, 40L, 130L, 40L, 13L, 54L, 42L, 
7L, 10L, 3L, 0L, 15L, 8L, 75L, 55L, 26L, 18L, 1L, 13L, 0L, 0L, 
0L, 1L, 0L, 4L, 0L, 0L, 0L, 0L, 0L, 0L, 17L, 45L, 38L, 10L, 31L, 
52L, 36L, 65L, 97L, 45L, 59L, 49L, 92L, 51L, 34L, 21L, 20L, 29L, 
28L, 22L, 32L, 30L, 86L, 0L, 15L, 7L, 4L, 0L, 0L, 0L, 11L, 3L, 
0L, 1L, 3L, 1L, 0L, 72L, 62L, 98L, 55L, 26L, 39L, 28L, 81L, 20L, 
52L, 12L, 48L, 24L, 40L, 30L, 5L, 6L, 40L, 37L, 33L, 26L, 17L, 
14L, 39L, 27L, 28L, 67L, 0L, 0L, 0L, 0L, 0L, 10L, 12L, 14L, 7L, 
0L, 2L, 39L, 67L, 74L, 28L, 23L, 57L, 34L, 36L, 36L, 37L, 46L, 
43L, 73L, 65L, 31L, 64L, 128L, 17L, 3L, 12L, 17L, 0L, 9L, 7L, 
0L, 17L, 0L), classification = c("Moving/Feeding", "Standing", 
"Standing", "Standing", "Standing", "Standing", "Moving/Feeding", 
"Moving/Feeding", "Moving/Feeding", "Standing", "Standing", "Feeding/Moving", 
"Standing", "Standing", "Moving/Feeding", "Feeding/Moving", "Feeding/Moving", 
"Feeding/Moving", "Standing", "Standing", "Standing", "Standing", 
"Moving/Feeding", "Moving/Feeding", "Standing", "Moving/Feeding", 
"Moving/Feeding", "Moving/Feeding", "Moving/Feeding", "Moving/Feeding", 
"Standing", "Standing", "Standing", "Moving/Feeding", "Standing", 
"Standing", "Standing", "Standing", "Moving/Feeding", "Standing", 
"Moving/Feeding", "Moving/Feeding", "Moving/Feeding", "Standing", 
"Standing", "Moving/Feeding", "Moving/Feeding", "Moving/Feeding", 
"Moving/Feeding", "Moving/Feeding", "Standing", "Standing", "Standing", 
"Feeding/Moving", "Feeding/Moving", "Feeding/Moving", "Moving/Feeding", 
"Feeding/Moving", "Feeding/Moving", "Feeding/Moving", "Feeding/Moving", 
"Moving/Feeding", "Moving/Feeding", "Moving/Feeding", "Standing", 
"Standing", "Standing", "Standing", "Feeding/Moving", "Standing", 
"Standing", "Standing", "Standing", "Standing", "Moving/Feeding", 
"Standing", "Moving/Feeding", "Standing", "Standing", "Feeding/Moving", 
"Feeding/Moving", "Standing", "Moving/Feeding", "Moving/Feeding", 
"Standing", "Moving/Feeding", "Feeding/Moving", "Moving/Feeding", 
"Moving/Feeding", "Feeding/Moving", "Feeding/Moving", "Feeding/Moving", 
"Feeding/Moving", "Feeding/Moving", "Feeding/Moving", "Standing", 
"Standing", "Moving/Feeding", "Feeding/Moving", "Feeding/Moving", 
"Feeding/Moving", "Feeding/Moving", "Feeding/Moving", "Feeding/Moving", 
"Feeding/Moving", "Feeding/Moving", "Feeding/Moving", "Feeding/Moving", 
"Feeding/Moving", "Feeding/Moving", "Feeding/Moving", "Feeding/Moving", 
"Feeding/Moving", "Feeding/Moving", "Moving/Feeding", "Moving/Feeding", 
"Feeding/Moving", "Moving/Feeding", "Moving/Feeding", "Moving/Feeding", 
"Moving/Feeding", "Standing", "Moving/Feeding", "Moving/Feeding", 
"Moving/Feeding", "Standing", "Standing", "Moving/Feeding", "Moving/Feeding", 
"Moving/Feeding", "Moving/Feeding", "Moving/Feeding", "Moving/Feeding", 
"Moving/Feeding", "Standing", "Standing", "Feeding/Moving", "Feeding/Moving", 
"Feeding/Moving", "Feeding/Moving", "Feeding/Moving", "Feeding/Moving", 
"Feeding/Moving", "Feeding/Moving", "Feeding/Moving", "Feeding/Moving", 
"Feeding/Moving", "Feeding/Moving", "Feeding/Moving", "Feeding/Moving", 
"Standing", "Moving/Feeding", "Standing", "Moving/Feeding", "Moving/Feeding", 
"Moving/Feeding", "Moving/Feeding", "Standing", "Moving/Feeding", 
"Moving/Feeding", "Feeding/Moving", "Moving/Feeding", "Moving/Feeding", 
"Moving/Feeding", "Moving/Feeding", "Feeding/Moving", "Feeding/Moving", 
"Moving/Feeding", "Moving/Feeding", "Moving/Feeding", "Moving/Feeding", 
"Feeding/Moving", "Feeding/Moving", "Moving/Feeding", "Moving/Feeding", 
"Moving/Feeding", "Standing", "Feeding/Moving", "Feeding/Moving", 
"Feeding/Moving", "Feeding/Moving", "Feeding/Moving", "Feeding/Moving", 
"Feeding/Moving", "Feeding/Moving", "Feeding/Moving", "Feeding/Moving", 
"Feeding/Moving", "Moving/Feeding", "Standing", "Standing", "Moving/Feeding", 
"Moving/Feeding", "Moving/Feeding", "Moving/Feeding", "Moving/Feeding", 
"Moving/Feeding", "Moving/Feeding", "Moving/Feeding", "Moving/Feeding", 
"Moving/Feeding", "Moving/Feeding", "Moving/Feeding", "Moving/Feeding", 
"Standing", "Moving/Feeding", "Feeding/Moving", "Feeding/Moving", 
"Feeding/Moving", "Feeding/Moving", "Feeding/Moving", "Feeding/Moving", 
"Feeding/Moving", "Feeding/Moving", "Feeding/Moving")), class = "data.frame", row.names = c(NA, 
-215L))

这里是resp41366_observed。上面使用的resp41366数据集就是resp41366_observed而没有resp41366$observed

> dput(resp41366_observed)
structure(list(ACTIVITY_X = c(29L, 34L, 51L, 78L, 18L, 4L, 27L, 
19L, 23L, 21L, 19L, 52L, 71L, 141L, 103L, 59L, 85L, 129L, 86L, 
129L, 82L, 67L, 79L, 49L, 51L, 32L, 27L, 48L, 10L, 2L, 18L, 29L, 
39L, 70L, 64L, 88L, 90L, 94L, 69L, 91L, 80L, 81L, 92L, 109L, 
96L, 84L, 67L, 89L, 85L, 67L, 79L, 68L, 88L, 72L, 67L, 65L, 71L, 
79L, 63L, 64L, 36L, 56L, 61L, 80L, 49L, 45L, 65L, 59L, 58L, 62L, 
49L, 58L, 68L, 52L, 78L, 51L, 73L, 75L, 80L, 75L, 89L, 63L, 33L, 
41L, 44L, 34L, 43L, 9L, 11L, 21L, 30L, 34L, 41L, 30L, 24L, 31L, 
65L, 52L, 21L, 35L, 39L, 35L, 27L, 32L, 38L, 38L, 56L, 65L, 81L, 
28L, 38L, 10L, 32L, 45L, 26L, 8L, 0L, 19L, 56L, 7L, 0L, 23L, 
13L, 1L, 2L, 29L, 15L, 15L, 1L, 33L, 3L, 45L, 143L, 46L, 78L, 
76L, 81L, 44L, 89L, 15L, 45L, 52L, 49L, 64L, 55L, 52L, 72L, 68L, 
95L, 66L, 74L, 103L, 49L, 26L, 7L, 29L, 25L, 31L, 7L, 13L, 12L, 
3L, 22L, 40L, 40L, 47L, 9L, 29L, 9L, 11L, 14L, 4L, 58L, 53L, 
60L, 30L, 40L, 42L, 41L, 48L, 40L, 31L, 51L, 29L, 33L, 76L, 38L, 
35L, 27L, 46L, 60L, 54L, 47L, 55L, 35L, 51L, 64L, 63L, 32L, 43L, 
52L, 47L, 41L, 64L, 54L, 56L, 66L, 64L, 33L, 26L, 28L, 33L, 45L, 
53L, 46L, 37L, 39L, 52L, 31L, 1L, 0L, 56L, 19L, 17L, 21L, 33L, 
68L, 61L, 78L, 31L, 0L, 11L, 63L, 62L, 43L, 42L, 154L, 4L, 187L, 
43L, 56L, 49L, 62L, 46L, 71L, 56L, 46L, 66L, 14L, 0L, 0L, 7L, 
0L, 0L, 0L, 17L, 39L, 23L, 0L, 0L, 0L, 4L, 3L, 9L, 8L, 14L, 7L, 
17L, 2L, 6L, 0L, 67L, 49L, 0L, 7L, 2L, 0L, 3L, 0L, 0L, 11L, 0L, 
2L, 4L, 10L, 4L, 3L, 55L, 41L, 34L, 43L, 21L, 0L, 6L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 4L, 81L, 63L, 44L, 30L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 27L, 41L, 38L, 26L, 30L, 44L, 57L, 69L, 31L, 54L, 
32L, 60L, 37L, 15L, 55L, 49L, 52L, 59L, 49L, 9L, 8L, 12L, 11L, 
14L, 20L, 54L, 43L, 64L, 53L, 61L, 108L, 39L, 63L, 54L, 56L, 
60L, 46L, 64L, 15L, 3L, 8L, 43L, 90L, 43L, 64L, 38L, 13L, 12L, 
46L, 24L, 1L, 30L, 9L, 58L, 105L, 2L, 4L, 2L, 4L, 8L), ACTIVITY_Y = c(19L, 
30L, 47L, 38L, 17L, 0L, 20L, 11L, 11L, 8L, 13L, 46L, 105L, 133L, 
131L, 64L, 76L, 94L, 58L, 69L, 47L, 57L, 155L, 49L, 72L, 43L, 
38L, 53L, 4L, 1L, 12L, 22L, 43L, 91L, 72L, 80L, 74L, 89L, 93L, 
115L, 79L, 89L, 85L, 103L, 87L, 84L, 71L, 98L, 83L, 81L, 83L, 
74L, 85L, 83L, 58L, 86L, 63L, 55L, 64L, 54L, 34L, 46L, 88L, 71L, 
69L, 51L, 58L, 53L, 53L, 67L, 57L, 70L, 71L, 77L, 59L, 74L, 58L, 
61L, 93L, 77L, 72L, 73L, 13L, 14L, 24L, 25L, 29L, 4L, 5L, 3L, 
13L, 14L, 16L, 10L, 7L, 13L, 54L, 38L, 17L, 19L, 20L, 15L, 10L, 
8L, 19L, 15L, 26L, 75L, 62L, 31L, 34L, 9L, 31L, 59L, 27L, 0L, 
0L, 3L, 59L, 5L, 0L, 14L, 6L, 0L, 0L, 28L, 7L, 14L, 0L, 24L, 
6L, 34L, 168L, 68L, 115L, 103L, 67L, 35L, 122L, 39L, 42L, 42L, 
43L, 47L, 44L, 39L, 77L, 43L, 112L, 68L, 59L, 188L, 127L, 25L, 
3L, 15L, 15L, 25L, 0L, 6L, 3L, 0L, 30L, 30L, 21L, 38L, 6L, 20L, 
17L, 7L, 8L, 5L, 61L, 87L, 44L, 57L, 43L, 73L, 87L, 46L, 97L, 
42L, 60L, 29L, 34L, 75L, 43L, 83L, 42L, 86L, 105L, 78L, 72L, 
103L, 51L, 88L, 74L, 66L, 42L, 36L, 45L, 77L, 60L, 69L, 49L, 
61L, 53L, 44L, 71L, 23L, 28L, 21L, 24L, 61L, 39L, 28L, 29L, 53L, 
39L, 0L, 2L, 29L, 25L, 23L, 16L, 43L, 70L, 107L, 149L, 62L, 1L, 
5L, 63L, 61L, 32L, 159L, 209L, 1L, 255L, 68L, 68L, 90L, 94L, 
64L, 92L, 97L, 75L, 77L, 15L, 0L, 0L, 12L, 0L, 0L, 0L, 33L, 56L, 
37L, 0L, 0L, 0L, 1L, 0L, 3L, 6L, 4L, 0L, 11L, 0L, 1L, 0L, 41L, 
61L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 3L, 0L, 5L, 
54L, 51L, 26L, 30L, 31L, 0L, 0L, 0L, 5L, 0L, 0L, 0L, 0L, 0L, 
16L, 88L, 55L, 42L, 24L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 15L, 
30L, 29L, 21L, 26L, 43L, 56L, 40L, 22L, 6L, 19L, 16L, 15L, 13L, 
46L, 59L, 88L, 41L, 35L, 9L, 1L, 2L, 5L, 6L, 4L, 40L, 24L, 55L, 
41L, 56L, 210L, 26L, 127L, 67L, 65L, 73L, 41L, 47L, 8L, 1L, 10L, 
23L, 76L, 36L, 79L, 15L, 0L, 2L, 46L, 39L, 4L, 23L, 2L, 48L, 
141L, 1L, 0L, 1L, 1L, 4L), observed = c("Feeding/Moving", "Moving/Feeding", 
"Moving/Feeding", "Moving/Feeding", "Feeding/Moving", "Feeding/Moving", 
"Feeding/Moving", "Feeding/Moving", "Feeding/Moving", "Feeding/Moving", 
"Feeding/Moving", "Moving/Feeding", "Standing", "Standing", "Standing", 
"Moving/Feeding", "Standing", "Standing", "Standing", "Standing", 
"Standing", "Moving/Feeding", "Standing", "Moving/Feeding", "Moving/Feeding", 
"Moving/Feeding", "Moving/Feeding", "Moving/Feeding", "Feeding/Moving", 
"Feeding/Moving", "Feeding/Moving", "Feeding/Moving", "Moving/Feeding", 
"Standing", "Standing", "Standing", "Standing", "Standing", "Standing", 
"Standing", "Standing", "Standing", "Standing", "Standing", "Standing", 
"Standing", "Standing", "Standing", "Standing", "Standing", "Standing", 
"Standing", "Standing", "Standing", "Moving/Feeding", "Standing", 
"Standing", "Standing", "Moving/Feeding", "Moving/Feeding", "Moving/Feeding", 
"Moving/Feeding", "Standing", "Standing", "Moving/Feeding", "Moving/Feeding", 
"Moving/Feeding", "Moving/Feeding", "Moving/Feeding", "Moving/Feeding", 
"Moving/Feeding", "Moving/Feeding", "Standing", "Moving/Feeding", 
"Standing", "Moving/Feeding", "Standing", "Standing", "Standing", 
"Standing", "Standing", "Standing", "Feeding/Moving", "Feeding/Moving", 
"Moving/Feeding", "Moving/Feeding", "Moving/Feeding", "Feeding/Moving", 
"Feeding/Moving", "Feeding/Moving", "Feeding/Moving", "Feeding/Moving", 
"Moving/Feeding", "Feeding/Moving", "Feeding/Moving", "Feeding/Moving", 
"Moving/Feeding", "Moving/Feeding", "Feeding/Moving", "Feeding/Moving", 
"Moving/Feeding", "Feeding/Moving", "Feeding/Moving", "Feeding/Moving", 
"Moving/Feeding", "Feeding/Moving", "Moving/Feeding", "Standing", 
"Standing", "Moving/Feeding", "Moving/Feeding", "Feeding/Moving", 
"Moving/Feeding", "Moving/Feeding", "Feeding/Moving", "Feeding/Moving", 
"Feeding/Moving", "Feeding/Moving", "Moving/Feeding", "Feeding/Moving", 
"Feeding/Moving", "Feeding/Moving", "Feeding/Moving", "Feeding/Moving", 
"Feeding/Moving", "Moving/Feeding", "Feeding/Moving", "Feeding/Moving", 
"Feeding/Moving", "Moving/Feeding", "Feeding/Moving", "Moving/Feeding", 
"Standing", "Moving/Feeding", "Standing", "Standing", "Standing", 
"Moving/Feeding", "Standing", "Feeding/Moving", "Moving/Feeding", 
"Moving/Feeding", "Moving/Feeding", "Moving/Feeding", "Moving/Feeding", 
"Moving/Feeding", "Standing", "Moving/Feeding", "Standing", "Standing", 
"Standing", "Standing", "Standing", "Feeding/Moving", "Feeding/Moving", 
"Feeding/Moving", "Feeding/Moving", "Moving/Feeding", "Feeding/Moving", 
"Feeding/Moving", "Feeding/Moving", "Feeding/Moving", "Feeding/Moving", 
"Moving/Feeding", "Moving/Feeding", "Moving/Feeding", "Feeding/Moving", 
"Feeding/Moving", "Feeding/Moving", "Feeding/Moving", "Feeding/Moving", 
"Feeding/Moving", "Moving/Feeding", "Standing", "Moving/Feeding", 
"Moving/Feeding", "Moving/Feeding", "Moving/Feeding", "Moving/Feeding", 
"Moving/Feeding", "Standing", "Moving/Feeding", "Moving/Feeding", 
"Moving/Feeding", "Moving/Feeding", "Standing", "Moving/Feeding", 
"Moving/Feeding", "Moving/Feeding", "Moving/Feeding", "Standing", 
"Moving/Feeding", "Moving/Feeding", "Standing", "Moving/Feeding", 
"Standing", "Standing", "Moving/Feeding", "Moving/Feeding", "Moving/Feeding", 
"Moving/Feeding", "Moving/Feeding", "Moving/Feeding", "Moving/Feeding", 
"Moving/Feeding", "Moving/Feeding", "Moving/Feeding", "Moving/Feeding", 
"Moving/Feeding", "Feeding/Moving", "Moving/Feeding", "Feeding/Moving", 
"Moving/Feeding", "Moving/Feeding", "Moving/Feeding", "Moving/Feeding", 
"Moving/Feeding", "Moving/Feeding", "Moving/Feeding", "Feeding/Moving", 
"Feeding/Moving", "Moving/Feeding", "Feeding/Moving", "Feeding/Moving", 
"Feeding/Moving", "Moving/Feeding", "Standing", "Standing", "Standing", 
"Moving/Feeding", "Feeding/Moving", "Feeding/Moving", "Moving/Feeding", 
"Moving/Feeding", "Moving/Feeding", "Standing", "Standing", "Feeding/Moving", 
"Standing", "Moving/Feeding", "Moving/Feeding", "Standing", "Standing", 
"Moving/Feeding", "Standing", "Standing", "Moving/Feeding", "Standing", 
"Feeding/Moving", "Feeding/Moving", "Feeding/Moving", "Feeding/Moving", 
"Feeding/Moving", "Feeding/Moving", "Feeding/Moving", "Feeding/Moving", 
"Moving/Feeding", "Moving/Feeding", "Feeding/Moving", "Feeding/Moving", 
"Feeding/Moving", "Feeding/Moving", "Feeding/Moving", "Feeding/Moving", 
"Feeding/Moving", "Feeding/Moving", "Feeding/Moving", "Feeding/Moving", 
"Feeding/Moving", "Feeding/Moving", "Feeding/Moving", "Moving/Feeding", 
"Moving/Feeding", "Feeding/Moving", "Feeding/Moving", "Feeding/Moving", 
"Feeding/Moving", "Feeding/Moving", "Feeding/Moving", "Feeding/Moving", 
"Feeding/Moving", "Feeding/Moving", "Feeding/Moving", "Feeding/Moving", 
"Feeding/Moving", "Feeding/Moving", "Feeding/Moving", "Moving/Feeding", 
"Moving/Feeding", "Moving/Feeding", "Moving/Feeding", "Feeding/Moving", 
"Feeding/Moving", "Feeding/Moving", "Feeding/Moving", "Feeding/Moving", 
"Feeding/Moving", "Feeding/Moving", "Feeding/Moving", "Feeding/Moving", 
"Feeding/Moving", "Feeding/Moving", "Standing", "Moving/Feeding", 
"Moving/Feeding", "Feeding/Moving", "Feeding/Moving", "Feeding/Moving", 
"Feeding/Moving", "Feeding/Moving", "Feeding/Moving", "Feeding/Moving", 
"Feeding/Moving", "Feeding/Moving", "Feeding/Moving", "Moving/Feeding", 
"Moving/Feeding", "Feeding/Moving", "Moving/Feeding", "Moving/Feeding", 
"Moving/Feeding", "Moving/Feeding", "Feeding/Moving", "Moving/Feeding", 
"Feeding/Moving", "Moving/Feeding", "Feeding/Moving", "Feeding/Moving", 
"Moving/Feeding", "Moving/Feeding", "Standing", "Moving/Feeding", 
"Moving/Feeding", "Feeding/Moving", "Feeding/Moving", "Feeding/Moving", 
"Feeding/Moving", "Feeding/Moving", "Feeding/Moving", "Moving/Feeding", 
"Moving/Feeding", "Moving/Feeding", "Moving/Feeding", "Moving/Feeding", 
"Standing", "Moving/Feeding", "Standing", "Moving/Feeding", "Moving/Feeding", 
"Moving/Feeding", "Moving/Feeding", "Moving/Feeding", "Feeding/Moving", 
"Feeding/Moving", "Feeding/Moving", "Moving/Feeding", "Standing", 
"Moving/Feeding", "Standing", "Feeding/Moving", "Feeding/Moving", 
"Feeding/Moving", "Moving/Feeding", "Moving/Feeding", "Feeding/Moving", 
"Feeding/Moving", "Feeding/Moving", "Moving/Feeding", "Standing", 
"Feeding/Moving", "Feeding/Moving", "Feeding/Moving", "Feeding/Moving", 
"Feeding/Moving")), row.names = c(NA, -374L), class = c("data.table", 
"data.frame"), .internal.selfref = <pointer: 0x0000000002541ef0>)

1 个答案:

答案 0 :(得分:1)

  1. 我建议您使用框架进行分类或ML任务,例如MLRCARET

  2. 也许您准备好数据,使训练和测试保持一致,然后再将其推入管道,并让框架进行拆分(重新映射)。