Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set positive class to 1 in R

I'm currently working on preditive models with the 'randomForest' package.

Fitting my model as follow

rf <- foreach(ntree=rep(10, 3), .combine= combine,  .packages='randomForest') %dopar% {
randomForest(bou~.,data=train, trees=50, importance=TRUE)}

When using 'confusionMatrix' from the 'caret' package, I've got the results below :

enter image description here

I'd like to know if it's possible to set the positive class to 1 in the model. I searched in the package description but couldn't find anything about it.

Thank you very much.

Edit : I've found it. It's an option in the 'confusionMatrix' command from the 'caret' package. I was lokking at the wrong place. Here an example if needed.

confusionMatrix(predicted,true_values,positive='1')

Should I leave my post or delete it ?

like image 204
Laurent Magon Avatar asked Jul 08 '16 09:07

Laurent Magon


People also ask

How do you change the positive class in a confusion matrix in R?

Changing the positive Class: One of the proficient way of doing this is through re-leveling of the target variable. To change the Positive Class to "Malignant" can be done using the relevel() function. The relevel() changes the reference level of the variable.

What is confusionmatrix in R?

A confusion matrix in R is a table that will categorize the predictions against the actual values. It includes two dimensions, among them one will indicate the predicted values and another one will represent the actual values.

What does positive class mean?

Positive class is the class that is related to your objective function. For example, if you want to classify whether the objects are present or not in a given scenario. So for all the data samples where objects are present will be considered in the positive class.


1 Answers

I've found it. It's an option in the confusionMatrix command from the caret package. I was looking at the wrong place. Here an example if needed:

confusionMatrix(predicted,true_values,positive='1')
like image 166
Laurent Magon Avatar answered Oct 16 '22 02:10

Laurent Magon