Skip to content
Back to skills

R Ml Frameworks

ASecurity

R machine learning frameworks. Use for unified ML workflows with tidymodels, caret, mlr3, and h2o.

  • 5 stars
  • 0 votes
  • 1 copy
  • 2 views
  • Added June 4, 2026
datatestingbackendperformance

Security analysis

A100/100

Pro scans all 14 files and shows the line behind each finding

Scanned June 4, 2026

npx -y skills add LeoLin990405/r-analytics-skill --skill r-ml-frameworks --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of R Ml Frameworks?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for R Ml Frameworks
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/leolin990405-r-ml-frameworks/badge)](https://www.skillsdirectory.com/skills/leolin990405-r-ml-frameworks)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: r-ml-frameworks
description: R machine learning frameworks. Use for unified ML workflows with tidymodels, caret, mlr3, and h2o.
---

# R ML Frameworks

Unified machine learning workflows.

## tidymodels

```r
library(tidymodels)

# 1. Split data
set.seed(123)
split <- initial_split(df, prop = 0.8, strata = target)
train <- training(split)
test <- testing(split)

# 2. Create recipe (preprocessing)
recipe <- recipe(target ~ ., data = train) %>%
  step_normalize(all_numeric_predictors()) %>%
  step_dummy(all_nominal_predictors()) %>%
  step_zv(all_predictors()) %>%
  step_impute_median(all_numeric_predictors())

# 3. Specify model
model_spec <- rand_forest(
  mtry = tune(),
  trees = 500,
  min_n = tune()
) %>%
  set_engine("ranger") %>%
  set_mode("classification")

# 4. Create workflow
wf <- workflow() %>%
  add_recipe(recipe) %>%
  add_model(model_spec)

# 5. Cross-validation
folds <- vfold_cv(train, v = 5, strata = target)

# 6. Tune hyperparameters
tune_results <- tune_grid(
  wf,
  resamples = folds,
  grid = 20,
  metrics = metric_set(roc_auc, accuracy)
)

# 7. Select best model
best_params <- select_best(tune_results, metric = "roc_auc")
final_wf <- finalize_workflow(wf, best_params)

# 8. Final fit
final_fit <- last_fit(final_wf, split)
collect_metrics(final_fit)

# 9. Predictions
predictions <- predict(final_fit$.workflow[[1]], test)
```

## caret

```r
library(caret)

# Train control
ctrl <- trainControl(
  method = "cv",
  number = 5,
  classProbs = TRUE,
  summaryFunction = twoClassSummary
)

# Train model
model <- train(
  target ~ .,
  data = train,
  method = "rf",
  trControl = ctrl,
  tuneLength = 10,
  metric = "ROC"
)

# Results
print(model)
plot(model)

# Predictions
pred <- predict(model, test)
pred_prob <- predict(model, test, type = "prob")

# Confusion matrix
confusionMatrix(pred, test$target)

# Variable importance
varImp(model)
```

## mlr3

```r
library(mlr3)
library(mlr3learners)
library(mlr3tuning)

# Task
task <- TaskClassif$new(id = "my_task", backend = df, target = "target")

# Learner
learner <- lrn("classif.ranger", predict_type = "prob")

# Resampling
resampling <- rsmp("cv", folds = 5)

# Benchmark
design <- benchmark_grid(
  tasks = task,
  learners = list(
    lrn("classif.ranger"),
    lrn("classif.xgboost"),
    lrn("classif.log_reg")
  ),
  resamplings = resampling
)
bmr <- benchmark(design)
bmr$aggregate(msr("classif.auc"))

# Tuning
learner <- lrn("classif.ranger",
  mtry = to_tune(1, 10),
  num.trees = to_tune(100, 500)
)
instance <- tune(
  tuner = tnr("grid_search"),
  task = task,
  learner = learner,
  resampling = resampling,
  measure = msr("classif.auc")
)
```

## h2o

```r
library(h2o)
h2o.init()

# Convert to H2O frame
train_h2o <- as.h2o(train)
test_h2o <- as.h2o(test)

# AutoML
aml <- h2o.automl(
  x = predictors,
  y = "target",
  training_frame = train_h2o,
  max_runtime_secs = 300,
  nfolds = 5
)

# Best model
leader <- aml@leader
h2o.performance(leader, test_h2o)

# Predictions
pred <- h2o.predict(leader, test_h2o)

# Shutdown
h2o.shutdown(prompt = FALSE)
```

## Model Comparison

| Framework | Strengths | Use Case |
|-----------|-----------|----------|
| tidymodels | Tidy syntax, modern | General ML |
| caret | Simple, many models | Quick prototyping |
| mlr3 | Flexible, extensible | Research |
| h2o | AutoML, scalable | Production |

Files in this skill

  • Boruta/SKILL.md2.7 KB
  • SKILL.md3.3 KB
  • arules/SKILL.md3.3 KB
  • caret/SKILL.md3.3 KB
  • e1071/SKILL.md3.1 KB
  • gbm/SKILL.md3.7 KB
  • h2o/SKILL.md1.5 KB
  • kernlab/SKILL.md3.4 KB
  • lme4/SKILL.md2.6 KB
  • mlr3/SKILL.md1.7 KB
  • nlme/SKILL.md3.5 KB
  • randomForest/SKILL.md3.1 KB
  • rpart/SKILL.md3.2 KB
  • tidymodels/SKILL.md3.8 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.