SSLRRandomForest: General Interface Random Forest model

Description Usage Arguments Details References Examples

View source: R/RandomForest.R

Description

Random Forest is a simple and effective semi-supervised learning method. It is the same as the traditional Random Forest algorithm, but the difference is that it use Semi supervised Decision Trees It can be used in classification or regression. If Y is numeric is for regression, classification in another case

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
SSLRRandomForest(
  mtry = NULL,
  trees = 500,
  min_n = NULL,
  w = 0.5,
  replace = TRUE,
  tree_max_depth = Inf,
  sampsize = NULL,
  min_samples_leaf = NULL,
  allowParallel = TRUE
)

Arguments

mtry

number of features in each decision tree. Default is null. This means that mtry = log(n_features) + 1

trees

number of trees. Default is 500

min_n

number of minimum samples in each tree Default is null. This means that uses all training data

w

weight parameter ranging from 0 to 1. Default is 0.5

replace

replacing type in sampling. Default is true

tree_max_depth

maximum tree depth. Default is Inf

sampsize

Size of sample. Default if (replace) nrow(x) else ceiling(.632*nrow(x))

min_samples_leaf

the minimum number of any terminal leaf node. Default is 1

allowParallel

Execute Random Forest in parallel if doParallel is loaded. Default is TRUE

Details

We can use paralleling processing with doParallel package and allowParallel = TRUE.

References

Jurica Levati, Michelangelo Ceci, Dragi Kocev, Saso Dzeroski.
Semi-supervised classification trees.
Published online: 25 March 2017 © Springer Science Business Media New York 2017

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
library(tidyverse)
library(caret)
library(SSLR)
library(tidymodels)

data(wine)

set.seed(1)
train.index <- createDataPartition(wine$Wine, p = .7, list = FALSE)
train <- wine[ train.index,]
test  <- wine[-train.index,]

cls <- which(colnames(wine) == "Wine")

#% LABELED
labeled.index <- createDataPartition(train$Wine, p = .2, list = FALSE)
train[-labeled.index,cls] <- NA


m <- SSLRRandomForest(trees = 5,  w = 0.3) %>% fit(Wine ~ ., data = train)

#Accuracy
predict(m,test) %>%
  bind_cols(test) %>%
  metrics(truth = "Wine", estimate = .pred_class)


#For probabilities
predict(m,test, type = "prob")

SSLR documentation built on July 22, 2021, 9:08 a.m.