2
$\begingroup$

I'm using a Random Forest method to predict the behavior of failures at Period_12. My dataset has information about the eleven periods before, considering 112 subperiods (rows). Each one of these subperiods is classified according to two classes, "Normal" or "Failure". However, the events "Failure" occur much less than the event "Normal". When using the k-fold crossvalidation (named MODEL 1 at the script), I have a Kappa metric equal to zero, while when using the Stratified k-fold crossvalidation (MODEL 2), I have a Kappa metric of 0,325 for mtry=11.

My questions: a) Why is the Kappa metric so low? It is related with the occurrences of events "Failure" in my dataset? Is there a way to improve this value? b) When I set folds <- 10 at the MODEL 2, I have an even lower value for Kappa metric.

Someone could help me to understand the output of my model or can suggest a way to improve it?

The script:

library(caret)

data_failures <- read.csv('OUTPUT.csv', header = TRUE, sep = ",", stringsAsFactors = TRUE)

# MODEL 1

train.control <- trainControl(method = "cv", number = 10)

model <- train(Period_12 ~., data = data_failures, method = "rf", trControl = train.control)

print(model)


# MODEL 2
folds <- 4

cvIndex <- createFolds(factor(data_failures$Period_12), folds, returnTrain = TRUE)

tc <- trainControl(index = cvIndex, method = 'cv', number = folds)

model2 <- train(Period_12 ~., data = data_failures, method = "rf", trControl = tc)

print(model2)

The output:

Random Forest

112 samples
 11 predictor
  2 classes: 'Failure', 'Normal'

No pre-processing
Resampling: Cross-Validated (10 fold)
Summary of sample sizes: 100, 102, 102, 100, 100, 101, ...
Resampling results across tuning parameters:

  mtry  Accuracy   Kappa
   2    0.9484848  0
   6    0.9384848  0
  11    0.9384848  0

Accuracy was used to select the optimal model using the largest value.
The final value used for the model was mtry = 2.
Random Forest

112 samples
 11 predictor
  2 classes: 'Failure', 'Normal'

No pre-processing
Resampling: Cross-Validated (4 fold)
Summary of sample sizes: 84, 84, 84, 84
Resampling results across tuning parameters:

  mtry  Accuracy   Kappa
   2    0.9464286  0.000
   6    0.9464286  0.000
  11    0.9553571  0.325

Accuracy was used to select the optimal model using the largest value.
The final value used for the model was mtry = 11.
Warning message:
In nominalTrainWorkflow(x = x, y = y, wts = weights, info = trainInfo,  :
  There were missing values in resampled performance measures.

A sample of the data:

     Period_1 Period_2 Period_3 Period_4 Period_5 Period_6 Period_7 Period_8
1     Normal   Normal   Normal   Normal   Normal   Normal   Normal   Normal
2     Normal  Failure  Failure   Normal   Normal   Normal   Normal   Normal
3     Normal  Failure  Failure   Normal   Normal   Normal   Normal   Normal
4     Normal  Failure  Failure   Normal   Normal   Normal   Normal   Normal
5     Normal   Normal   Normal   Normal   Normal   Normal   Normal   Normal
6     Normal   Normal   Normal   Normal   Normal   Normal   Normal   Normal
7     Normal  Failure   Normal   Normal   Normal   Normal   Normal   Normal
8     Normal  Failure   Normal   Normal   Normal   Normal   Normal   Normal
9     Normal  Failure   Normal   Normal   Normal   Normal   Normal   Normal
10    Normal   Normal   Normal   Normal   Normal   Normal   Normal   Normal
$\endgroup$

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.