Reputation: 1615
I try to do some prediction in R . I loaded & cleaned the data, fit a model and did a prediction which looks pretty good. My problem now is that my prediction gives me a percentage of probability of the occurence of e certain factor instead of the factor itself:
I have a dataset on how well people perform some exercise. This performance is messured in A-D ( which is a factor-variable in my dataset). When I do the prediction I get this output:
but I want to have it like that:
[ B A E A A C D A A A C ]
How would I do that? This is my code:
modFitA1 <- rpart(classe ~ ., data=PML_Train_red, method="class")
Predictn<-predict(modFitA1, newdata= PML_Test_red)
Predictn
Upvotes: 0
Views: 6061
Reputation: 37661
Even though you put method="class"
in your model statement, you need to add type="class"
to your predict statement.
Predictn<-predict(modFitA1, newdata= PML_Test_red, type="class")
Upvotes: 1