-
Notifications
You must be signed in to change notification settings - Fork 409
Add GS:Visualization and Plots #3050
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2b04b63
e865161
f6bc44e
b9013dc
07086b9
7175d17
ff00094
6771178
77dbdf5
42bf550
10e0344
b6c8b3e
1952a9b
653ffaa
219a59c
f4df213
93fdb93
925f472
7053759
b343d34
dc6a2ed
51b9820
7dd9675
07dcd51
4f3b0f1
c90918d
9a7ab68
5ff8661
6b3f660
8c9f957
29ceb79
99b4487
63af2d9
ca6ae91
fc49d48
2eb2e6a
4e6cf30
a11b4c5
3af2c42
b4ee07c
ad9b474
e894d0b
18c45f0
4ca9196
987105f
314791d
f34c59f
3b28572
a153b70
603674a
63f9dc0
4427ff3
1f70192
eb1853a
79f2bf3
4cacc6b
80af071
debec87
fcd0cd5
18274b3
2ae5379
b4681fe
6f5264d
f26f366
c1f4961
b0ed669
7e411e2
cf02e81
b2a832e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,109 @@ | ||||||
| --- | ||||||
| title: 'Get Started: Visualization with Plots' | ||||||
| --- | ||||||
|
|
||||||
| # Get Started: Visualization with Plots | ||||||
|
|
||||||
|
iesahin marked this conversation as resolved.
|
||||||
| In this section, we'll add visualization to the [`example-dvc-experiments`][ede] | ||||||
| project (explored [previously](/doc/start/experiments)). If you would like to | ||||||
| try these yourself, please refer to the project. [README] about how to install. | ||||||
|
|
||||||
| [ede]: https://github.com/iterative/example-dvc-experiments | ||||||
| [readme]: | ||||||
| https://github.com/iterative/example-dvc-experiments/blob/main/README.md | ||||||
|
|
||||||
| ## Creating plots from tabular data | ||||||
|
|
||||||
| A useful plot to show the classification performance is the [confusion matrix]. | ||||||
| In order to produce it, DVC expects a CSV **plots file** in the form: | ||||||
|
|
||||||
| ```csv | ||||||
| actual,predicted | ||||||
| 0,0 | ||||||
| 0,2 | ||||||
| ... | ||||||
| ``` | ||||||
|
|
||||||
| > We added a [loop] comparing the results to generate this file from the | ||||||
| > predictions. | ||||||
|
|
||||||
| [loop]: | ||||||
| https://github.com/iterative/example-dvc-experiments/blob/main/src/train.py#L123 | ||||||
| [confusion matrix]: https://en.wikipedia.org/wiki/Confusion_matrix | ||||||
|
|
||||||
| Running the experiment with `dvc exp run` will produce `plots/confusion.csv`. | ||||||
| Use `dvc plots show` to present it as an HTML file, and open it in the browser: | ||||||
|
|
||||||
| ```dvc | ||||||
| $ dvc plots show plots/confusion.csv --template confusion \ | ||||||
| -x actual -y predicted | ||||||
| file:///.../example-dvc-experiments/plots/confusion.json.html | ||||||
| ``` | ||||||
|
|
||||||
|  | ||||||
|
|
||||||
| ## Displaying user-generated plot images | ||||||
|
|
||||||
| Let's produce another plot to see misclassified examples from each class. This | ||||||
| procedure generates the misclassification examples from the validation data and | ||||||
| arranges them into a _confusion table_ that shows the correct label, and | ||||||
| misclassification sample. The code to generate an image from a set of training | ||||||
| images is omitted here but you can find the code in [the example | ||||||
| project.][misclassified-example-code] | ||||||
|
jorgeorpinel marked this conversation as resolved.
|
||||||
|
|
||||||
| [misclassified-example-code]: | ||||||
| https://github.com/iterative/example-dvc-experiments/blob/48b1e5078c957f71674c00f416290eaa3b20b559/src/util.py#L49 | ||||||
|
|
||||||
| ```dvc | ||||||
| $ dvc plots show plots/misclassified.png | ||||||
| ``` | ||||||
|
|
||||||
|  | ||||||
|
|
||||||
| ## Autogenerating plots from deep learning code | ||||||
|
|
||||||
| An important issue for deep learning projects is to observe in which epoch do | ||||||
| training and validation loss differ. DVC helps in that regard with its Python | ||||||
| integrations to deep learning libraries via [DVCLive]. | ||||||
|
|
||||||
| The example project uses Keras to train a classifier, and we have a DVCLive | ||||||
| callback that visualizes the training and validation loss for each epoch. We | ||||||
| first import the callback from DVCLive. | ||||||
|
|
||||||
| ```python | ||||||
| from dvclive.keras import DvcLiveCallback | ||||||
| ``` | ||||||
|
|
||||||
| Then we add this callback to the | ||||||
| [`fit` method](https://keras.io/api/models/model_training_apis/#fit-method) | ||||||
| call. | ||||||
|
|
||||||
| ```python | ||||||
| model.fit( | ||||||
| ... | ||||||
| callbacks=[DvcLiveCallback()], | ||||||
| ...) | ||||||
| ``` | ||||||
|
|
||||||
| With these two changes, the model metrics are automatically logged to | ||||||
| `dvclive.json` and plotted in `training_metrics/index.html`: | ||||||
|
|
||||||
|  | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
The image is not readable though. Can the fonts be larger? And maybe the top part with dvclive.json sample should be a regular code block (under the image) with a few rows of the data instead of just one.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the same in the documentation: https://dvc.org/doc/dvclive/dvclive-with-dvc#html-report Zooming in to make the axis labels readable makes the whole chart so large. How could we solve this @daavoo ?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can still change the label as suggested for now.
Yes we have that problem in a few places but at least those are GIFs and you can see changing plots so maybe it doesn't matter that much that the text is readable in some other cases.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's better to create separate issue or deal with this in #3455
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will be tracked in #3470
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes but still the image caption could be better. It's helpful to have descriptive image captions for SEO and even image searches. |
||||||
|
|
||||||
| DVCLive has other capabilities, like saving the model every epoch or modifying | ||||||
| these default values. | ||||||
|
|
||||||
| In summary, DVC provides more than one option to use visualization in your | ||||||
| workflow: | ||||||
|
|
||||||
| - DVC can generate HTML files that includes interactive plots from data series | ||||||
| in JSON, YAML, CSV, or TSV format. | ||||||
|
|
||||||
| - DVC can keep track of image files produced as [plot outputs] from the | ||||||
| training/evaluation scripts. | ||||||
|
|
||||||
| - [DVCLive] integrations can produce plots automatically during training. | ||||||
|
|
||||||
| [plot outputs]: | ||||||
| /doc/user-guide/project-structure/pipelines-files#metrics-and-plots-outputs | ||||||
| [dvclive]: /doc/dvclive/dvclive-with-dvc | ||||||
Uh oh!
There was an error while loading. Please reload this page.