Skip to content

Commit

Permalink
Revise visualisation documentation for Plotly charts, Matplotlib (#2061)
Browse files Browse the repository at this point in the history
Update the documentation about plotly charts and general intro to kedro viz. More to come on experiment tracking.
  • Loading branch information
stichbury authored and jmholzer committed Jan 9, 2023
1 parent eaa7331 commit 9005bb5
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 112 deletions.
2 changes: 1 addition & 1 deletion docs/source/contribution/contribute_to_kedro.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ We welcome any and all contributions to Kedro, at whatever level you can manage.
- Join the community on [Slack](https://slack.kedro.org)
- Review Kedro's [GitHub issues](https://github.com/kedro-org/kedro/issues) or raise your own issue to report a bug or feature request
- Start a conversation about the Kedro project on [GitHub discussions](https://github.com/kedro-org/kedro/discussions)
- Make a pull request on the [Kedro-Community GitHub repo](https://github.com/kedro-org/kedro-community) to update the curated list of Kedro community content.
- Make a pull request on the [Kedro-Community GitHub repo](https://github.com/kedro-org/kedro-community) to update the curated list of Kedro community content
- Report a bug or propose a new feature on [GitHub issues](https://github.com/kedro-org/kedro/issues)
- [Review other contributors' PRs](https://github.com/kedro-org/kedro/pulls)
- [Contribute code](./developer_contributor_guidelines.md), for example to fix a bug or add a feature
Expand Down
Binary file modified docs/source/meta/images/chart-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/source/meta/images/pipeline_visualisation_matplotlib.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 15 additions & 20 deletions docs/source/visualisation/experiment_tracking.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
# Set up experiment tracking

Experiment tracking is the process of saving all machine-learning related experiment information so that it is easy to find and compare past runs. [Kedro-Viz](https://github.com/kedro-org/kedro-viz) supports native experiment tracking from [version 4.1.1](https://github.com/kedro-org/kedro-viz/releases/tag/v4.1.1) onwards. When experiment tracking is enabled in your Kedro project, you will be able to access, edit and [compare your experiments](#access-run-data-and-compare-runs) directly from the Kedro-Viz web app, as well as [see how your metrics have changed over time](#view-your-metrics-timeline).
Experiment tracking is the process of saving all machine-learning related experiment information so you can compare different runs.

[Kedro-Viz](https://github.com/kedro-org/kedro-viz) supports native experiment tracking from [version 4.1.1](https://github.com/kedro-org/kedro-viz/releases/tag/v4.1.1) onwards. When experiment tracking is enabled in your Kedro project, you will be able to access, edit and [compare your experiments](#access-run-data-and-compare-runs) and additionally [track how your metrics change over time](#view-your-metrics-timeline).

![](../meta/images/experiment-tracking_demo_small.gif)

Enabling experiment tracking features on Kedro-Viz relies on:

* [setting up a session store to capture experiment metadata](#set-up-the-session-store),
* [experiment tracking datasets to let Kedro know what metrics should be tracked](#set-up-tracking-datasets)
* [experiment tracking datasets to let Kedro know what metrics should be tracked](#set-up-tracking-datasets),
* [modifying your nodes and pipelines to output those metrics](#set-up-your-nodes-and-pipelines-to-log-metrics).

This tutorial will provide a step-by-step process to set up experiment tracking and access your logged metrics from each run on Kedro-Viz. It will use the starter outlined in the [spaceflights tutorial](../tutorial/spaceflights_tutorial.md). You can also jump directly to [this section for direct reference in setting up experiment tracking](../logging/experiment_tracking.md) for your Kedro project.
This page describes the steps necessary to set up experiment tracking and access logged metrics, using the [spaceflights tutorial](../tutorial/spaceflights_tutorial.md).

You can also access a more detailed [Kedro-Viz live demo](https://kedro-viz-live-demo.hfa4c8ufrmn4u.eu-west-2.cs.amazonlightsail.com/).

## Set up a project
[Further information is available in the experiment tracking section](../logging/experiment_tracking.md) for your Kedro project.

```{note}
You can skip this step if you have followed all previous parts of the tutorial.
```
You can also access a more detailed [Kedro-Viz experiment tracking demo](https://demo.kedro.org/experiment-tracking).

## Set up a project

We assume that you have already [installed Kedro](../get_started/install.md) and [Kedro-Viz](../visualisation/kedro-viz_visualisation.md). To set up a new project using the spaceflights starter, run:

```bash
kedro new --starter=spaceflights
```

Feel free to name your project as you like, but this guide will assume the project is named **Kedro Experiment Tracking Tutorial**, and that your project is in a sub-folder in your working directory that was created by `kedro new`, named `kedro-experiment-tracking-tutorial`.
Feel free to name your project as you like, but this guide will assume the project is named **Kedro Experiment Tracking Tutorial**.

## Set up the session store

Expand All @@ -52,18 +54,15 @@ There are two types of tracking datasets: [`tracking.MetricsDataSet`](/kedro.ext
Set up two datasets to log `r2 scores` and `parameters` for each run by adding the following in the `conf/base/catalog.yml` file:

```yaml
data_science.active_modelling_pipeline.metrics:
active_modelling_pipeline.metrics:
type: tracking.MetricsDataSet
filepath: data/09_tracking/metrics.json

data_processing.companies_columns:
companies_columns:
type: tracking.JSONDataSet
filepath: data/09_tracking/companies_columns.json
```
```{note}
These two datasets include namespaces to correspond to the pipeline setup. If you have a project without namespaces, you can still use experiment tracking.
```
## Set up your nodes and pipelines to log metrics
Expand Down Expand Up @@ -142,7 +141,7 @@ node(

Having set up both datasets, you can now generate your first set of experiment tracking data!

## Generate the Run data
## Generate the run data

The beauty of native experiment tracking in Kedro is that all tracked data is generated and stored each time you do a Kedro run. Hence, to generate the data, you need only execute:

Expand All @@ -166,7 +165,7 @@ Here comes the fun part of accessing your run data on Kedro-Viz. Having ensured
kedro viz
```

When you open the Kedro-Viz web app, you will see an experiment tracking icon ![](../meta/images/experiment-tracking-icon.png) on your left. Click the icon to go to the experiment tracking page (you can also access the page via `http://127.0.0.1:4141/runsList`), where you will now see the set of experiment data generated from your previous runs:
When you open the Kedro-Viz web app, you will see an experiment tracking icon ![](../meta/images/experiment-tracking-icon.png) on your left. Click the icon to go to the experiment tracking page (you can also access the page via `http://127.0.0.1:4141/experiment-tracking`), where you will now see the set of experiment data generated from your previous runs:

![](../meta/images/experiment-tracking_runsList.png)

Expand Down Expand Up @@ -197,8 +196,6 @@ def create_confusion_matrix(companies: pd.DataFrame):
return plt
```

> You might have to execute `pip install seaborn` if the [seaborn library](https://seaborn.pydata.org/) is not installed yet.
And now add this node to the `data_processing` pipeline (`src/kedro-experiment-tracking-tutorial/pipelines/data_processing/pipeline.py`)

```python
Expand All @@ -225,8 +222,6 @@ After running the pipeline with `kedro run`, the plot will be saved and you will
![](../meta/images/expand-plot-comparison-view.gif)


> [Read more about creating plots and visualising them in Kedro-Viz](./kedro-viz_visualisation.md).

## View your metrics timeline

Additionally, you can monitor the changes to metrics over time from the pipeline visualisation tab ![](../meta/images/pipeline_visualisation_icon.png). Clicking on any MetricsDataset node will open a side panel displaying how the metric value has changed over time.
Expand Down
30 changes: 18 additions & 12 deletions docs/source/visualisation/kedro-viz_visualisation.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,48 @@
# Get started with Kedro-Viz

[Kedro-Viz](https://github.com/kedro-org/kedro-viz) is a key part of Kedro. It displays data and nodes, and the connections between them, to visualise the structure of the pipelines in a Kedro project.
[Kedro-Viz](https://github.com/kedro-org/kedro-viz) is a key part of Kedro. It visualises the pipelines in a Kedro project by showing data, nodes, and the connections between them.

This section assumes you are familiar with the basic Kedro concepts described in the [spaceflights tutorial](../tutorial/spaceflights_tutorial.md). If you have not yet worked through the tutorial, you can still follow this example.

If you haven't installed Kedro [follow the documentation to get set up](../get_started/install.md).

Then, in your terminal window, navigate to the folder you want to store the project.

Generate a copy of the spaceflights tutorial project with all the code in place by using the [Kedro starter for the spaceflights tutorial](https://github.com/kedro-org/kedro-starters/tree/main/spaceflights):

```bash
kedro new --starter=spaceflights
```

When prompted for a project name, you can enter any name, but we will assume `Kedro Tutorial` throughout.
When prompted for a project name, you can enter anything, but we will assume `Kedro Tutorial` throughout.

When your project is ready, navigate to the root directory of the project and install the dependencies for the project, which include Kedro-Viz:

```bash
pip install -r src/requirements.txt
```

The next step is optional, but useful to check that all is working. Run the full set of pipelines for the tutorial project:

```bash
kedro run
```

## Visualise the spaceflights project

To run Kedro-Viz, type the following into your terminal from the project directory:
To start Kedro-Viz, type the following into your terminal from the project directory:

```bash
kedro viz
```

The command automatically opens a browser tab to serve the visualisation at http://127.0.0.1:4141/.
The command opens a browser tab to serve the visualisation at `http://127.0.0.1:4141/`.

You should see the following:

![](../meta/images/pipeline_visualisation.png)

If a visualisation panel opens up and a pipeline is not visible, then please check that your tutorial project code is complete if you've not generated it from the starter template.

### Need help?

If you still can't see the visualisation, the Kedro community can help!
If a visualisation panel opens up and a pipeline is not visible, refresh the view, and check that your tutorial project code is complete if you've not generated it from the starter template. If you still don't see the visualisation, the Kedro community can help:

* use the [#questions channel](https://slack.kedro.org/) on our Slack channel (which replaces our Discord server) to ask the community for help
* search the [searchable archive of Discord discussions](https://linen-discord.kedro.org/)
Expand Down Expand Up @@ -114,15 +120,15 @@ The visualisation now includes the layers:
## Share a pipeline visualisation
You can share a Kedro-Viz visualisation as a JSON file from the terminal:
You can share a the pipeline structure within a Kedro-Viz visualisation as a JSON file from the terminal:
```bash
kedro viz --save-file my_shareable_pipeline.json
```

This command will save a visualisation of the `__default__` pipeline as a JSON file called `my_shareable_pipeline.json`.
This command will save a visualisation of the `__default__` pipeline as a JSON file called `my_shareable_pipeline.json`. It doesn't share data, such as that in the code panel, nor can you share images or charts.

To visualise the JSON file, type the following to load it from the terminal:
To visualise the shared file, type the following to load it from the terminal:

```bash
kedro viz --load-file my_shareable_pipeline.json
Expand Down
Loading

0 comments on commit 9005bb5

Please sign in to comment.