The goal of LogisticEnsembles is to perform a complete analysis of logistic data. The package automatically returns 24 models (13 individual models and 11 ensembles of models)
You can install the development version of LogisticEnsembles like so:
devtools::install_github("InfiniteCuriosity/LogisticEnsembles")This is a basic example which shows you how to solve a common problem:
library(LogisticEnsembles)
head(LogisticEnsembles::Lebron)
start_time <- Sys.time()
Logistic(data = Lebron,
colnum = 6,
numresamples = 25,
remove_VIF_greater_than <- 5.00,
save_all_trained_models = "N",
save_all_plots = "N",
set_seed = "N",
how_to_handle_strings = 0,
do_you_have_new_data = "N",
remove_ensemble_correlations_greater_than = 0.80,
use_parallel = "Y",
train_amount = 0.50,
test_amount = 0.25,
validation_amount = 0.25)
end_time <- Sys.time()
duration <- end_time - start_time
duration
warnings()LogisticEnsembles only requires the code seen above, and it automatically builds 24 logistic models from the data.
Each of the 24 models fit the data to the training set, make predictions and measure accuracy on the test and validation sets. It does this by converting the predictions using the logistic function in the stats package, as follows:
gam is used, but the process is identical for all 24 functions:
-
Build the model on the training data gam_train_fit <- gam::gam(y ~ ., data = train)
-
Use the model to make predictions on new data gam_train_pred <- stats::predict(gam_train_fit, train01, type = "response")
-
Convert predicted values to logistic using the plogis function (commonly called the 'inverse logit' function. This transforms real numbers into probabilities between 0 and 1) gam_train_predictions <- as.numeric(plogis(gam_train_pred))
-
Covert the predictions to binomial gam_train_predictions_binomial <- rbinom(n = length(gam_train_predictions), size = 1, prob = gam_train_predictions) # This converts the values to binomial
-
Create a summary table (commonly called a confusion matrix) gam_train_table <- table(gam_train_predictions_binomial, y_train) # This creates a summary table (commonly called a confusion matrix)
The list of 24 models:
- Cubist
- Flexible Discriminant Analysis
- Generalized Additive Models
- Generalized Linear Models
- Lasso
- Linear
- Linear Discriminant Analysis
- Penalized Discriminant Analysis
- Quadratic Discrmininant Analysis
- Random Forest
- Ridge
- Support Vector Machines
- Trees
- Ensemble Bagging
- Ensemble C50
- Ensemble Gradient Boosted
- Ensemble Lasso
- Ensemble Partial Least Squares
- Ensemble Penalized Discrmininant Analysis
- Ensemble Ridge
- Ensemble RPart
- Ensemble Support Vector Machines
- Ensemble Trees
- Ensemble XGBoost
The 25 plots automatically created by the package are:
- accuracy_plot
- total_plot_fixed_scales
- total_plot_free_scales
- accuracy_barchart
- overfitting_plot_fixed_scales
- overfitting_plot_free_scales
- Duration_barchart
- Overfitting_barchart
- ROC_curves
- Boxplots
- Barchart
- True_positive_rate_fixed_scales
- True_positive_rate_free_scales
- True_negative_rate_fixed_scales
- True_negative_rate_free_scales
- False_positive_rate_fixed_scales
- False_positive_rate_free_scales
- False_negative_rate_fixed_scales
- False_negative_rate_free_scales
- F1_score_fixed_scales
- F1_score_free_scales
- Positive_predictive_value_fixed_scales
- Positive_predictive_value_free_scales
- Negative_predictive_value_fixed_scales
- Negative_predictive_value_free_scales
Note that several of the plots are represented twice - once with fixed scales and once with free scales.
The 7 tables and reports automatically created:
- Head_of_data
- Summary_tables
- Ensemble Correlation
- Ensemble_head
- Data_Summary
- VIF_results
- Summary report. This includes the Model, Accuracy, True Positive, True Negative, False Positive, False Negative, Positive Predictive Value, Negative Predictive Value, F1 score, Area under the curve, overfitting min, overfitting mean, overfitting max, and duration.
The package also returns all 24 summary confusion matrices, alphabetical by model. If the user uses resampling, it adds up the values, so any error is visible, even if an event only happens once. For example, from the results about the Lebron data:
$Summary_tables$Cubist y_test cubist_test_predictions_binomial 0 1 0 4801 2555 1 4730 7080
It is also possible to save all trained models, save all plots, set the seed, and much more within LogisticEnsembles.
Summary: LogisticEnsembles should give everything you need to write a summary report based on the data.