knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "90%",
  fig.align = "center"
)

library(ggplot2)

theme_set(theme_minimal(base_size = 5) + theme(legend.position = "bottom"))

if(require(showtext)){
  sysfonts::font_add_google("IBM Plex Sans", "plex")
  showtext::showtext_auto()
}

klassets

R-CMD-check Github stars R-CMD-check

The {klassets} package is a collection of functions to simulate data sets to:

knitr::include_graphics("man/figures/animation_quasi_anscombre.gif")

Some examples

Don't forget to visualize the data

library(klassets)

set.seed(123)

df <- sim_quasianscombe_set_1(beta0 = 3, beta1 = 0.5)

plot(df) +
  ggplot2::labs(subtitle = "Very similar to the given parameters (3 and 0.5)")
library(patchwork)

df2 <- sim_quasianscombe_set_2(df, fun = sin)
df6 <- sim_quasianscombe_set_6(df, groups = 2, b1_factor = -1)

plot(df2) + plot(df6)

Compare models in a classifications task

df <- sim_response_xy(relationship = function(x, y) sin(x*pi) > sin(y*pi))

df

plot(df)

You can fit different models and see how the predictions are made.

plot(fit_logistic_regression(df, order = 4)) +
plot(fit_classification_tree(df))            +
plot(fit_classification_random_forest(df))   +
plot(fit_knn(df))                            +
  plot_layout(guides = "collect")

How $K$-means works

Another example of what can be done with {klassets}.

knitr::include_graphics("man/figures/animation_kmeans_iterations.gif")

Where to start

You can check:

Installation

You can install the development version of klassets from GitHub with:

# install.packages("remotes")
remotes::install_github("jbkunst/klassets")

Extra Info(?!)

Why the name Klassets? Just a weird merge for Class/Klass and sets.

Some inspiration and similar ideas:



jbkunst/klassets documentation built on Dec. 7, 2022, 9:18 p.m.