Learn R Programming

daltoolboxdp (version 1.2.737)

skcla_rf: Random Forest Classifier

Description

Implements classification using the Random Forest algorithm. Wraps scikit-learn's RandomForestClassifier through reticulate.

Usage

skcla_rf(
  attribute,
  slevels,
  n_estimators = 100,
  criterion = "gini",
  max_depth = NULL,
  min_samples_split = 2,
  min_samples_leaf = 1,
  min_weight_fraction_leaf = 0,
  max_features = "sqrt",
  max_leaf_nodes = NULL,
  min_impurity_decrease = 0,
  bootstrap = TRUE,
  oob_score = FALSE,
  n_jobs = NULL,
  random_state = NULL,
  verbose = 0,
  warm_start = FALSE,
  class_weight = NULL,
  ccp_alpha = 0,
  max_samples = NULL,
  monotonic_cst = NULL
)

Value

A skcla_rf classifier object.

Arguments

attribute

Target attribute name for model building

slevels

List of possible values for classification target

n_estimators

Number of trees in random forest

criterion

Function name for measuring split quality

max_depth

Maximum tree depth value

min_samples_split

Minimum samples needed for internal node split

min_samples_leaf

Minimum samples needed at leaf node

min_weight_fraction_leaf

Minimum weighted fraction value

max_features

Number of features to consider for best split

max_leaf_nodes

Maximum number of leaf nodes

min_impurity_decrease

Minimum impurity decrease needed for split

bootstrap

Whether to use bootstrap samples

oob_score

Whether to use out-of-bag samples

n_jobs

Number of parallel jobs

random_state

Seed for random number generation

verbose

Whether to enable verbose output

warm_start

Whether to reuse previous solution

class_weight

Weights associated with classes

ccp_alpha

Complexity parameter value for pruning

max_samples

Number of samples for training estimators

monotonic_cst

Monotonicity constraints for features

Details

Tree Ensemble

References

Breiman, L. (2001). Random Forests. Machine Learning.

Examples

Run this code
if (FALSE) {
data(iris)

# 1) Define classifier with target attribute and its levels
clf <- skcla_rf(attribute = 'Species', slevels = levels(iris$Species), n_estimators = 200)

# 2) Fit and predict
clf <- daltoolbox::fit(clf, iris)
pred <- predict(clf, iris)   # wrapper drops target column internally
table(pred, iris$Species)
}

# More examples:
# https://github.com/cefet-rj-dal/daltoolboxdp/blob/main/examples/skcla_rf.md

Run the code above in your browser using DataLab