-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
99 lines (71 loc) · 2.69 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include=FALSE}
lgr::get_logger("mlr3")$set_threshold("warn")
lgr::get_logger("mlr3spatial")$set_threshold("warn")
set.seed(1)
options(width = 80)
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
REBUILD = TRUE
RECREATE_ALL_2DFIGS = FALSE
```
# vistool
<!-- badges: start -->
[![r-cmd-check](https://github.com/slds-lmu/vistool/actions/workflows/r-cmd-check.yaml/badge.svg)](https://github.com/slds-lmu/vistool/actions/workflows/r-cmd-check.yaml)
<!-- badges: end -->
The goal of `vistool` is to visualize optimization traces and aid in teaching optimization-related concepts.
## Installation
You can install the development version of vistool from [GitHub](https://github.com/) with:
``` r
# install.packages("pak")
pak::pak("slds-lmu/vistool")
```
Please note that visualization features rely on [`plotly`]() which in turns relies on certain functionality provided by Python packages, which are accessed via reticulate.
Most importantly this affects the `$save()` functionality for plots, which uses `plotly::save_image()` internally, and requires the `kaleido` Python package.
The following instructions are provided by `?plotly::save_image` and assume you do not have `miniconda` installed already:
```r
install.packages('reticulate')
reticulate::install_miniconda()
reticulate::conda_install('r-reticulate', 'python-kaleido')
reticulate::conda_install('r-reticulate', 'plotly', channel = 'plotly')
reticulate::use_miniconda('r-reticulate')
```
## Example
```{r example-setup}
library(vistool)
library(mlr3verse)
```
This examples shows how to visualize the prediction surface of an SVM on the `pima` task included in `mlr3`:
```{r example}
# Create an example task, add missing data imputation and select 2 features
task = tsk("pima")
task = po("imputemean")$train(list(task))[[1]]
task$select(c("insulin", "mass"))
# Select example learner
learner = lrn("classif.svm", predict_type = "prob")
# Create the Visualizer object from task and learner
vis = as_visualizer(task, learner)
# Define a 3D scene
vis$set_scene(x = 1.4, y = 1.4, z = 1.4)
```
View interactively:
```{r example-plot, eval=FALSE}
vis$plot()
```
![](man/figures/demo_1.png)
Save static version as png:
```{r example-save}
vis$save("man/figures/demo_1.png", width = 500, height = 500)
```
## Resources
For visualization of...
* [Loss Functions](https://slds-lmu.github.io/vistool/articles/loss_functions.html)
* [Model Predictions](https://slds-lmu.github.io/vistool/articles/model.html)
* [Objective Functions](https://slds-lmu.github.io/vistool/articles/objective.html)