R Machine Learning Skill
Sub-skills
| Sub-skill |
Description |
| r-ml-frameworks |
tidymodels, caret, mlr3, h2o |
| r-ml-boosting |
xgboost, lightgbm, gbm |
| r-ml-trees |
randomForest, ranger, rpart |
| r-ml-regularization |
glmnet, lasso, elastic-net |
| r-ml-deeplearning |
torch, keras, neural networks |
| r-ml-timeseries |
prophet, fable, forecast |
| r-ml-survival |
survival, survminer |
| r-ml-anomaly |
AnomalyDetection, anomalize |
Machine learning and predictive modeling in R.
ML Frameworks
| Package |
Description |
| caret ★ |
Classification and Regression Training |
| mlr3 ★ |
Next-gen extensible ML framework |
| tidymodels ★ |
Tidyverse-friendly modeling |
| h2o |
Deep learning, RF, GBM, GLM |
Gradient Boosting
| Package |
Description |
| xgboost ★ |
eXtreme Gradient Boosting |
| lightgbm ★ |
Light Gradient Boosting Machine |
| gbm |
Generalized Boosted Regression |
| bst |
Gradient Boosting |
| mboost |
Model-Based Boosting |
| CoxBoost |
Cox models boosting |
| GAMBoost |
GAM boosting |
| gamboostLSS |
GAMLSS boosting |
| GMMBoost |
Mixed models boosting |
Tree-Based Methods
| Package |
Description |
| randomForest |
Breiman's random forests |
| ranger ★ |
Fast random forests |
| randomForestSRC |
RF for survival/regression/classification |
| rpart |
Recursive partitioning trees |
| party |
Recursive partitioning lab |
| partykit |
Partitioning toolkit |
| C50 |
C5.0 Decision Trees |
| Cubist |
Rule-based regression |
| evtree |
Evolutionary trees |
| tree |
Classification/regression trees |
| bigrf |
Big Random Forests |
Regularization & Linear Models
| Package |
Description |
| glmnet ★ |
Lasso and elastic-net GLMs |
| lars |
Least Angle Regression, Lasso |
| elasticnet |
Elastic-Net, Sparse PCA |
| penalized |
L1/L2 penalized estimation |
| ncvreg |
SCAD/MCP regularization |
| grplasso |
Group Lasso |
| grpreg |
Grouped covariates regularization |
| L0Learn |
Best subset selection |
Neural Networks & Deep Learning
| Package |
Description |
| torch ★ |
PyTorch-like tensors/NNs |
| MXNet |
Flexible GPU deep learning |
| nnet |
Feed-forward NNs |
| RSNNS |
Stuttgart NN Simulator |
| keras |
Keras interface |
Mixed Effects Models
| Package |
Description |
| lme4 ★ |
Mixed-effects models |
| nlme |
Mixed-effects with custom covariance |
| glmmTMB |
Generalized mixed-effects |
Time Series & Forecasting
| Package |
Description |
| prophet ★ |
Facebook's forecasting tool |
| fable |
Tidy forecasting |
| forecast |
Time series forecasting |
Anomaly Detection
| Package |
Description |
| AnomalyDetection |
Twitter's anomaly detection |
| anomalize |
Tidy anomaly detection |
| BreakoutDetection |
Twitter's breakout detection |
| CausalImpact |
Google's causal inference |
SVM & Kernel Methods
| Package |
Description |
| kernlab |
Kernel-based ML lab |
| e1071 |
SVM, Naive Bayes, etc. |
| LiblineaR |
Linear predictive models |
| svmpath |
SVM path algorithm |
| penalizedSVM |
Feature selection SVM |
Clustering & Dimensionality
| Package |
Description |
| kohonen |
Self-Organizing Maps |
| Rsomoclu |
Parallel SOM |
| hda |
Heteroscedastic Discriminant Analysis |
| klaR |
Classification and visualization |
Feature Selection
| Package |
Description |
| Boruta |
All-relevant feature selection |
| FSelector |
Subset-search/ranking selection |
| varSelRF |
Variable selection with RF |
Survival Analysis
| Package |
Description |
| survival ★ |
Survival analysis |
| survminer |
Survival visualization |
| ahaz |
Additive hazards regression |
Other
| Package |
Description |
| arules |
Association rules mining |
| rattle |
GUI for data mining |
| rminer |
Simplified NN/SVM usage |
| ROCR |
Classifier performance visualization |
| SuperLearner |
Ensemble learning |
| RWeka |
Weka interface |
Quick Examples
# tidymodels workflow
library(tidymodels)
split <- initial_split(df, prop = 0.8)
train <- training(split)
test <- testing(split)
model <- rand_forest(trees = 100) %>%
set_engine("ranger") %>%
set_mode("classification")
recipe <- recipe(target ~ ., data = train) %>%
step_normalize(all_numeric())
workflow <- workflow() %>%
add_model(model) %>%
add_recipe(recipe)
fit <- workflow %>% fit(data = train)
predict(fit, test)
# xgboost
library(xgboost)
dtrain <- xgb.DMatrix(data = as.matrix(train_x), label = train_y)
model <- xgb.train(
params = list(objective = "binary:logistic", max_depth = 6),
data = dtrain, nrounds = 100
)
# caret
library(caret)
ctrl <- trainControl(method = "cv", number = 5)
model <- train(target ~ ., data = train, method = "rf", trControl = ctrl)
Resources
1---2name: r-ml3description: R machine learning packages. Use for classification, regression, clustering, deep learning, gradient boosting (xgboost, lightgbm), random forests, neural networks, and time series forecasting.4metadata:5 source: https://skillmd.com/skills/leolin990405/r-ml6---78# R Machine Learning Skill910## Sub-skills1112| Sub-skill | Description |13|-----------|-------------|14| [r-ml-frameworks](r-ml-frameworks/SKILL.md) | tidymodels, caret, mlr3, h2o |15| [r-ml-boosting](r-ml-boosting/SKILL.md) | xgboost, lightgbm, gbm |16| [r-ml-trees](r-ml-trees/SKILL.md) | randomForest, ranger, rpart |17| [r-ml-regularization](r-ml-regularization/SKILL.md) | glmnet, lasso, elastic-net |18| [r-ml-deeplearning](r-ml-deeplearning/SKILL.md) | torch, keras, neural networks |19| [r-ml-timeseries](r-ml-timeseries/SKILL.md) | prophet, fable, forecast |20| [r-ml-survival](r-ml-survival/SKILL.md) | survival, survminer |21| [r-ml-anomaly](r-ml-anomaly/SKILL.md) | AnomalyDetection, anomalize |2223Machine learning and predictive modeling in R.2425## ML Frameworks2627| Package | Description |28|---------|-------------|29| **caret** ★ | Classification and Regression Training |30| **mlr3** ★ | Next-gen extensible ML framework |31| **tidymodels** ★ | Tidyverse-friendly modeling |32| **h2o** | Deep learning, RF, GBM, GLM |3334## Gradient Boosting3536| Package | Description |37|---------|-------------|38| **xgboost** ★ | eXtreme Gradient Boosting |39| **lightgbm** ★ | Light Gradient Boosting Machine |40| **gbm** | Generalized Boosted Regression |41| **bst** | Gradient Boosting |42| **mboost** | Model-Based Boosting |43| **CoxBoost** | Cox models boosting |44| **GAMBoost** | GAM boosting |45| **gamboostLSS** | GAMLSS boosting |46| **GMMBoost** | Mixed models boosting |4748## Tree-Based Methods4950| Package | Description |51|---------|-------------|52| **randomForest** | Breiman's random forests |53| **ranger** ★ | Fast random forests |54| **randomForestSRC** | RF for survival/regression/classification |55| **rpart** | Recursive partitioning trees |56| **party** | Recursive partitioning lab |57| **partykit** | Partitioning toolkit |58| **C50** | C5.0 Decision Trees |59| **Cubist** | Rule-based regression |60| **evtree** | Evolutionary trees |61| **tree** | Classification/regression trees |62| **bigrf** | Big Random Forests |6364## Regularization & Linear Models6566| Package | Description |67|---------|-------------|68| **glmnet** ★ | Lasso and elastic-net GLMs |69| **lars** | Least Angle Regression, Lasso |70| **elasticnet** | Elastic-Net, Sparse PCA |71| **penalized** | L1/L2 penalized estimation |72| **ncvreg** | SCAD/MCP regularization |73| **grplasso** | Group Lasso |74| **grpreg** | Grouped covariates regularization |75| **L0Learn** | Best subset selection |7677## Neural Networks & Deep Learning7879| Package | Description |80|---------|-------------|81| **torch** ★ | PyTorch-like tensors/NNs |82| **MXNet** | Flexible GPU deep learning |83| **nnet** | Feed-forward NNs |84| **RSNNS** | Stuttgart NN Simulator |85| **keras** | Keras interface |8687## Mixed Effects Models8889| Package | Description |90|---------|-------------|91| **lme4** ★ | Mixed-effects models |92| **nlme** | Mixed-effects with custom covariance |93| **glmmTMB** | Generalized mixed-effects |9495## Time Series & Forecasting9697| Package | Description |98|---------|-------------|99| **prophet** ★ | Facebook's forecasting tool |100| **fable** | Tidy forecasting |101| **forecast** | Time series forecasting |102103## Anomaly Detection104105| Package | Description |106|---------|-------------|107| **AnomalyDetection** | Twitter's anomaly detection |108| **anomalize** | Tidy anomaly detection |109| **BreakoutDetection** | Twitter's breakout detection |110| **CausalImpact** | Google's causal inference |111112## SVM & Kernel Methods113114| Package | Description |115|---------|-------------|116| **kernlab** | Kernel-based ML lab |117| **e1071** | SVM, Naive Bayes, etc. |118| **LiblineaR** | Linear predictive models |119| **svmpath** | SVM path algorithm |120| **penalizedSVM** | Feature selection SVM |121122## Clustering & Dimensionality123124| Package | Description |125|---------|-------------|126| **kohonen** | Self-Organizing Maps |127| **Rsomoclu** | Parallel SOM |128| **hda** | Heteroscedastic Discriminant Analysis |129| **klaR** | Classification and visualization |130131## Feature Selection132133| Package | Description |134|---------|-------------|135| **Boruta** | All-relevant feature selection |136| **FSelector** | Subset-search/ranking selection |137| **varSelRF** | Variable selection with RF |138139## Survival Analysis140141| Package | Description |142|---------|-------------|143| **survival** ★ | Survival analysis |144| **survminer** | Survival visualization |145| **ahaz** | Additive hazards regression |146147## Other148149| Package | Description |150|---------|-------------|151| **arules** | Association rules mining |152| **rattle** | GUI for data mining |153| **rminer** | Simplified NN/SVM usage |154| **ROCR** | Classifier performance visualization |155| **SuperLearner** | Ensemble learning |156| **RWeka** | Weka interface |157158## Quick Examples159160```r161# tidymodels workflow162library(tidymodels)163split <- initial_split(df, prop = 0.8)164train <- training(split)165test <- testing(split)166167model <- rand_forest(trees = 100) %>%168 set_engine("ranger") %>%169 set_mode("classification")170171recipe <- recipe(target ~ ., data = train) %>%172 step_normalize(all_numeric())173174workflow <- workflow() %>%175 add_model(model) %>%176 add_recipe(recipe)177178fit <- workflow %>% fit(data = train)179predict(fit, test)180181# xgboost182library(xgboost)183dtrain <- xgb.DMatrix(data = as.matrix(train_x), label = train_y)184model <- xgb.train(185 params = list(objective = "binary:logistic", max_depth = 6),186 data = dtrain, nrounds = 100187)188189# caret190library(caret)191ctrl <- trainControl(method = "cv", number = 5)192model <- train(target ~ ., data = train, method = "rf", trControl = ctrl)193```194195## Resources196197- tidymodels: https://www.tidymodels.org/198- caret: https://topepo.github.io/caret/199- xgboost: https://xgboost.readthedocs.io/200- mlr3: https://mlr3.mlr-org.com/