calculate_feature_importances: Calculate True and Permuted Feature Importances

View source: R/modelTrainingTuningFittingTesting.R

calculate_feature_importancesR Documentation

Calculate True and Permuted Feature Importances

Description

This function fits a Random Forest model and calculates the true and permuted feature importances. It performs permutations on the target variable to generate permuted importances for comparison.

Usage

calculate_feature_importances(model, X_train, y_train, n_permutations = 1000)

Arguments

model

The Random Forest model to be used.

X_train

Training feature matrix.

y_train

Training target vector.

n_permutations

The number of permutations to perform (default: 1000).

Value

A list containing three data frames: one for true feature importances, one for permuted importances, and one containing the top features (filtered non-zero true importances).

Examples

feat_importances <- Rf2pval::calculate_feature_importances(fitting_results$model,processed_training_data$X_training_mat,processed_training_data$y_training_vector,n_permutations=1000)

Print the fitting results, provides accuracy, f1 score, precision, recall and roc_auc scores on the model as fitted to the validation set
print(top_features)

tkolisnik/Rf2pval documentation built on Feb. 20, 2024, 5:39 a.m.