Continous output instead of classification

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Continous output instead of classification

iamanoop
I was trying to do some classification problem where target variable should be one of 4 classes. I tried rpart and ranger packages to do this.
rf.model <- rpart(Target ~ .-Id, data=train, method="class")
pred <- predict(rf.model, train)
View(pred)


So my pred looks like this :

            Front         Left        Rear        Right
1     0.006661686 0.0100859171 0.961399577 0.0218528203
2     0.006661686 0.0100859171 0.961399577 0.0218528203
3     0.974920089 0.0007868208 0.001278584 0.0230145070
4     0.006661686 0.0100859171 0.961399577 0.0218528203
5     0.006661686 0.0100859171 0.961399577 0.0218528203
6     0.974920089 0.0007868208 0.001278584 0.0230145070
7     0.006661686 0.0100859171 0.961399577 0.0218528203
8     0.006661686 0.0100859171 0.961399577 0.0218528203
9     0.974920089 0.0007868208 0.001278584 0.0230145070
10    0.974920089 0.0007868208 0.001278584 0.0230145070

While Target Output should be classified like this :
Target :

Rear
Rear
Front
Rear
Rear
Rear
Rear
Rear
Rear
Front


I had this same problem before with other datasets. Now again I am facing this problem
What is my mistake and how can I correct it?