https://github.com/jbkunst/klassets
https://github.com/jbkunst/klassets
Last synced: 1 day ago
JSON representation
- Host: GitHub
- URL: https://github.com/jbkunst/klassets
- Owner: jbkunst
- License: other
- Created: 2022-05-20T15:34:04.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-11-29T15:45:27.000Z (5 months ago)
- Last Synced: 2025-03-26T23:07:32.827Z (19 days ago)
- Language: R
- Homepage: https://jkunst.com/klassets
- Size: 127 MB
- Stars: 64
- Watchers: 5
- Forks: 9
- Open Issues: 1
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - jbkunst/klassets - (R)
README
---
output: github_document
editor_options:
chunk_output_type: console
---```{r, include = FALSE}
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
[](https://github.com/jbkunst/klassets/actions)
[](https://github.com/jbkunst/klassets)
[](https://github.com/jbkunst/klassets/actions/workflows/R-CMD-check.yaml)The `{klassets}` package is a collection of functions to simulate data sets to:
- Teach how some Statistics Models and Machine Learning algorithms works.
- Illustrate certain some particular events such as heteroskedasticity or the Simpson's paradox.
- Compare the predictions between models, for example logistic regression vs decision tree vs $k$-Nearest Neighbours.```{r, echo=FALSE}
knitr::include_graphics("man/figures/animation_quasi_anscombre.gif")
```# Some examples
## Don't forget to visualize the data
```{r}
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)")
``````{r}
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
```{r}
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.
```{r, out.width = "100%"}
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}`.
```{r, echo=FALSE}
knitr::include_graphics("man/figures/animation_kmeans_iterations.gif")
```## Where to start
You can check:
- `vignette("Quasi-Anscombe-data-sets")` to know more about `sim_quasianscombe_set*` functions family.
- `vignette("Binary-classification")`/`vignette("Regression")` to see classifiers/regression models/methods.
- `vignette("Clustering")` to see clustering functions.
- `vignette("MNIST")` to work with this data set to compare models and check
some variable importance metrics.## Installation
You can install the development version of klassets from [GitHub](https://github.com/) with:
``` r
# 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:
- https://jumpingrivers.github.io/datasauRus/
- https://eliocamp.github.io/metamer/
- http://www.econometricsbysimulation.com/2019/03/the-importance-of-graphing-your-data.html This is almost the same, but the approach it's different.