You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# This assumed you launch this livebook from its location in the exgboost/notebooks folder
11
19
```
@@ -24,24 +32,24 @@ This notebook will go over some of the details of the `EXGBoost.Plotting` module
24
32
25
33
There are 2 main APIs exposed to control plotting in `EXGBoost`:
26
34
27
-
- Top-level API (`EXGBoost.plot_tree/2`)
35
+
* Top-level API (`EXGBoost.plot_tree/2`)
28
36
29
-
- Using predefined styles
30
-
- Defining custom styles
31
-
- Mix of the first 2
37
+
* Using predefined styles
38
+
* Defining custom styles
39
+
* Mix of the first 2
32
40
33
-
-`EXBoost.Plotting` module API
41
+
*`EXBoost.Plotting` module API
34
42
35
-
- Use the Vega `data` spec defined in `EXGBoost.Plotting.get_data_spec/2`
36
-
- Define your own Vega spec using the data from either `EXGBoost.Plotting.to_tabular/1` or some other means
43
+
* Use the Vega `data` spec defined in `EXGBoost.get_data_spec/2`
44
+
* Define your own Vega spec using the data from either `EXGBoost.Plotting.to_tabular/1` or some other means
37
45
38
46
We will walk through each of these in detail.
39
47
40
48
Regardless of which API you choose to use, it is helpful to understand how the plotting module works (althought the higher-level API you choose to work with the less important it becomes).
41
49
42
50
## Implementation Details
43
51
44
-
The plotting functionality provided in `EXGBoost` is powered by the [Vega](https://vega.github.io/vega/) JavaScript library and the Elixir [`VegaLite`](https://hexdocs.pm/vega_lite/VegaLite.html) library which provides the piping to interop with the JavaScript libraries. **We do not actually much use the Elixir API provided by the Elixir VegaLite library. It is mainly used for the purposes of rendering.**
52
+
The plotting functionality provided in `EXGBoost` is powered by the [Vega](https://vega.github.io/vega/) JavaScript library and the Elixir [`VegaLite`](https://hexdocs.pm/vega_lite/VegaLite.html) library which provides the piping to interop with the JavaScript libraries. **We do not actually much use the Elixir API provided by the Elixir VegaLite library. It is mainly used for the purposes of rendering.**
45
53
46
54
Vega is a plotting library built on top of the very powerful [D3](https://d3js.org/) JavaScript library. Vega visualizations are defined according to the respective JSON Schema specification. Vega-Lite offers a [reduced schema](https://vega.github.io/schema/vega-lite/v5.json) compared to the [full Vega spec](https://vega.github.io/schema/vega/v5.json). `EXGBoost.Plotting` leverages several transforms which are not available in the reduced Vega-Lite schema, which is the reason for targeting the lower-level API.
47
55
@@ -69,7 +77,7 @@ y_test = Nx.tensor(y_test)
69
77
70
78
## Train Your Booster
71
79
72
-
Now go ahead and train your booster. We will use `early_stopping_rounds: 1` because we're not interested in the accuracy of the booster for this demonstration (_Note that we need to set `evals` to use early stopping_).
80
+
Now go ahead and train your booster. We will use `early_stopping_rounds: 1` because we're not interested in the accuracy of the booster for this demonstration (*Note that we need to set `evals` to use early stopping*).
73
81
74
82
You will notice that `EXGBoost` also provides an implementation for `Kino.Render` so that `EXGBoost.Booster`s are rendered as a plot by default.
75
83
@@ -112,20 +120,20 @@ This API uses [Vega `Mark`s](https://vega.github.io/vega/docs/marks/) to describ
112
120
113
121
The plot is composed of the following parts:
114
122
115
-
- Top-level keys: Options controlling parts of the plot outside of direct control of a `Mark`, such as `:padding`, `:autosize`, etc. Accepts any Vega top-level [top-level key](https://vega.github.io/vega/docs/specification/) in addition to several specific to this API (scuh as `:style` and `:depth`).
116
-
-`:leaves`: `Mark` specifying the leaf nodes of the tree
* Top-level keys: Options controlling parts of the plot outside of direct control of a `Mark`, such as `:padding`, `:autosize`, etc. Accepts any Vega top-level [top-level key](https://vega.github.io/vega/docs/specification/) in addition to several specific to this API (scuh as `:style` and `:depth`).
124
+
*`:leaves`: `Mark` specifying the leaf nodes of the tree
By default, plotting only shows one (the first) tree, but seeing as a `Booster` is really an ensemble of trees you can choose which tree to plot through the `:index` option, or set to `nil` to have a dropdown box to select the tree.
You'll also notice that the plot is interactive, with support for scrolling, zooming, and collapsing sections of the tree. If you click on a split node you will toggle the visibility of its descendents, and the rest of the tree will fill the canvas.
@@ -340,7 +348,7 @@ For example, if you just want to change the default pre-configured style you can
0 commit comments