5. 2016.10.21 SVR, DecisionTree, RandomForest Method

And their Variable Importance using R

  • SVR:

    • A prevalent package

      library(e1071)
      fit <- svm(y ~ x1 + x2 + x3 + x4 + x5 + x7 + x8,
                data=sampled_train_data)
      
    • An alternative one which using func Importance() in library rminer

            ​```
            library(rminer)
            fit = fit(y ~ x1 + x2 + x3 + x4 + x5 + x7 + x8, 
                      sampled_train_data, model = 'svm')
            summary(fit) # show results
            im = Importance(fit,sampled_train_data)
            ​```
      

    ​

  • Decision Tree:

    library(rpart) fit <- rpart(y ~ x1 + x2 + x3 + x4 + x5 + x7 + x8, method=”anova”, data=sampled_train_data, control=rpart.control(minsplit=100, cp=0) ) summary(fit) # show results fit$variable.importance # importance of each predictor

    • method="anova" for regression model, method="class" for classification model
  • Random Forest:

    library(randomForest) fit <- randomForest(y ~ x1 + x2 + x3 + x4 + x5 + x7 + x8, data=sampled_train_data, ntree = 5000) summary(fit) # show results importance(fit) # importance of each predictor