MyNixOS website logo
Description

A Unified Tidy Interface to R's Machine Learning Ecosystem.

Provides a unified tidyverse-compatible interface to R's machine learning packages. Wraps established implementations from 'glmnet', 'randomForest', 'xgboost', 'e1071', 'rpart', 'gbm', 'nnet', 'cluster', 'dbscan', and others - providing consistent function signatures, tidy tibble output, unified 'ggplot2'-based visualization, and optional formatted 'gt' tables via the tl_table() family of functions. The underlying algorithms are unchanged; 'tidylearn' simply makes them easier to use together. Access raw model objects via the $fit slot for package-specific functionality. Methods include random forests Breiman (2001) <doi:10.1023/A:1010933404324>, LASSO regression Tibshirani (1996) <doi:10.1111/j.2517-6161.1996.tb02080.x>, elastic net Zou and Hastie (2005) <doi:10.1111/j.1467-9868.2005.00503.x>, support vector machines Cortes and Vapnik (1995) <doi:10.1007/BF00994018>, and gradient boosting Friedman (2001) <doi:10.1214/aos/1013203451>.

tidylearn tidylearn logo

Machine Learning for Tidynauts

CRAN status License: MIT

Overview

tidylearn provides a unified tidyverse-compatible interface to R's machine learning ecosystem. It wraps proven packages like glmnet, randomForest, xgboost, e1071, cluster, and dbscan - you get the reliability of established implementations with the convenience of a consistent, tidy API.

What tidylearn does:

  • Provides one consistent interface (tl_model()) to 20+ ML algorithms
  • Returns tidy tibbles instead of varied output formats
  • Offers unified ggplot2-based visualization across all methods
  • Enables pipe-friendly workflows with %>%
  • Orchestrates complex workflows combining multiple techniques

What tidylearn is NOT:

  • A reimplementation of ML algorithms (uses established packages under the hood)
  • A replacement for the underlying packages (you can access the raw model via model$fit)

Why tidylearn?

Each ML package in R has its own API, output format, and conventions. tidylearn provides a translation layer so you can:

Without tidylearnWith tidylearn
Learn different APIs for each packageOne API for everything
Write custom code to extract resultsConsistent tibble output
Create different plots for each modelUnified visualization
Manage package-specific quirksFocus on your analysis

The underlying algorithms are unchanged - tidylearn simply makes them easier to use together.

Installation

# Install from CRAN
install.packages("tidylearn")

# Or install development version from GitHub
# devtools::install_github("ces0491/tidylearn")

Quick Start

Unified Interface

A single tl_model() function dispatches to the appropriate underlying package:

library(tidylearn)

# Classification -> uses randomForest::randomForest()
model <- tl_model(iris, Species ~ ., method = "forest")

# Regression -> uses stats::lm()
model <- tl_model(mtcars, mpg ~ wt + hp, method = "linear")

# Regularization -> uses glmnet::glmnet()
model <- tl_model(mtcars, mpg ~ ., method = "lasso")

# Clustering -> uses stats::kmeans()
model <- tl_model(iris[,1:4], method = "kmeans", k = 3)

# PCA -> uses stats::prcomp()
model <- tl_model(iris[,1:4], method = "pca")

Tidy Output

All results come back as tibbles, ready for dplyr and ggplot2:

# Predictions as tibbles
predictions <- predict(model, new_data = test_data)

# Metrics as tibbles
metrics <- tl_evaluate(model, test_data)

# Easy to pipe
model %>%
  predict(test_data) %>%
  bind_cols(test_data) %>%
  ggplot(aes(x = actual, y = prediction)) +
  geom_point()

Access the Underlying Model

You always have access to the raw model from the underlying package:

model <- tl_model(iris, Species ~ ., method = "forest")

# Access the randomForest object directly
model$fit  # This is the randomForest::randomForest() result

# Use package-specific functions if needed
randomForest::varImpPlot(model$fit)

Wrapped Packages

tidylearn provides a unified interface to these established R packages:

Supervised Learning

MethodUnderlying PackageFunction Called
"linear"statslm()
"polynomial"statslm() with poly()
"logistic"statsglm(..., family = binomial)
"ridge", "lasso", "elastic_net"glmnetglmnet()
"tree"rpartrpart()
"forest"randomForestrandomForest()
"boost"gbmgbm()
"xgboost"xgboostxgb.train()
"svm"e1071svm()
"nn"nnetnnet()
"deep"keraskeras_model_sequential()

Unsupervised Learning

MethodUnderlying PackageFunction Called
"pca"statsprcomp()
"mds"stats, MASS, smacofcmdscale(), isoMDS(), etc.
"kmeans"statskmeans()
"pam"clusterpam()
"clara"clusterclara()
"hclust"statshclust()
"dbscan"dbscandbscan()

Integration Workflows

Beyond wrapping individual packages, tidylearn provides orchestration functions that combine multiple techniques:

Dimensionality Reduction + Supervised Learning

# Reduce dimensions before classification
reduced <- tl_reduce_dimensions(iris, response = "Species",
                                method = "pca", n_components = 3)
model <- tl_model(reduced$data, Species ~ ., method = "logistic")

Cluster-Based Feature Engineering

# Add cluster membership as a feature
enriched <- tl_add_cluster_features(data, response = "target",
                                    method = "kmeans", k = 3)
model <- tl_model(enriched, target ~ ., method = "forest")

Semi-Supervised Learning

# Use clustering to propagate labels to unlabeled data
model <- tl_semisupervised(data, target ~ .,
                          labeled_indices = labeled_idx,
                          cluster_method = "kmeans")

AutoML

# Automatically try multiple approaches
result <- tl_auto_ml(data, target ~ .,
                    time_budget = 300)
result$leaderboard

Unified Visualization

Consistent ggplot2-based plotting regardless of model type:

# Generic plot method works for all model types
plot(forest_model)       # Automatic visualization based on model type
plot(linear_model)       # Diagnostic plots for regression
plot(pca_result)         # Variance explained for PCA

# Specialized plotting functions for unsupervised learning
plot_clusters(clustering_result, cluster_col = "cluster")
plot_variance_explained(pca_result$fit$variance_explained)

# Interactive dashboard for detailed exploration
tl_dashboard(model, test_data)

Philosophy

tidylearn is built on these principles:

  1. Transparency: The underlying packages do the real work. tidylearn makes them easier to use together without hiding what's happening.

  2. Consistency: One interface, tidy output, unified visualization - across all methods.

  3. Accessibility: Focus on your analysis, not on learning different package APIs.

  4. Interoperability: Results work seamlessly with dplyr, ggplot2, and the broader tidyverse.

Documentation

# View package help
?tidylearn

# Explore main functions
?tl_model
?tl_evaluate
?tl_auto_ml

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see LICENSE for details.

Author

Cesaire Tobias ([email protected])

Acknowledgments

tidylearn is a wrapper that builds upon the excellent work of many R package authors. The actual algorithms are implemented in:

  • stats (base R): lm, glm, prcomp, kmeans, hclust, cmdscale
  • glmnet: Ridge, LASSO, and elastic net regularization
  • randomForest: Random forest implementation
  • xgboost: Gradient boosting
  • gbm: Gradient boosting machines
  • e1071: Support vector machines
  • nnet: Neural networks
  • rpart: Decision trees
  • cluster: PAM, CLARA clustering
  • dbscan: Density-based clustering
  • MASS: Sammon mapping, isoMDS
  • smacof: SMACOF MDS algorithm
  • keras/tensorflow: Deep learning (optional)

Thank you to all the package maintainers whose work makes tidylearn possible.


Metadata

Version

0.2.0

License

Unknown

Platforms (78)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    uefi
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-uefi
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-linux
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-uefi
  • x86_64-windows