Skip to content

Commit

Permalink
Upgrade/hiplot (#75)
Browse files Browse the repository at this point in the history
* Updated gitignore, example nb

* Added axes ordering
  • Loading branch information
Kamil A. Kaczmarek authored Mar 4, 2020
1 parent b2eb7d6 commit e040d5b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# dist
VERSION
neptune_lib.egg-info/
neptune_contrib.egg-info/
dist/

# tests
Expand All @@ -21,5 +21,5 @@ tests/.pytest_cache
docs/_build
docs/_templates

# nbooks
# notebooks
*.ipynb_checkpoints
13 changes: 7 additions & 6 deletions docs/examples/hiplot_visualizations.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,27 @@
"1. Setup the visualization to your liking.\n",
"1. Inspect experiments lineage.\n",
"\n",
"## Before we start, make sure that you have dependencies installed\n",
"### Before we start, make sure that you have dependencies installed\n",
"* `neptune-client`\n",
"* `neptune-contrib[viz]`\n",
"* `hiplot`\n",
"\n",
"## Example notebooks in Neptune\n",
"### Example notebooks in Neptune\n",
"* [credit-default-prediction](https://ui.neptune.ai/neptune-ai/credit-default-prediction/n/parallel-plot-04e5c379-0837-42ff-a11c-a8861ca4a408/c486644a-a356-4317-b397-6cdae86b7575)\n",
"* [example-project](https://ui.neptune.ai/USERNAME/example-project/n/parallel-plot-cb5394cc-edce-41e3-9a25-7970865c66ad/59377976-6651-40ed-b3c3-eb0fa5aa79bc)\n",
"\n",
"These notebooks are tracked in Neptune public projects. You are free to play with the plots - they are interactive.\n",
"\n",
"## Remember to set the project before you call visualization function\n",
"For example: `neptune.init('USERNAME/example-project')`"
"### Learn more\n",
"Check integration [documentation](https://neptune-contrib.readthedocs.io/user_guide/viz/parallel_coordinates_plot.html) for more details."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Set project"
"## Set project\n",
"Remember to set the project before you call visualization function"
]
},
{
Expand Down Expand Up @@ -133,7 +134,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.9"
"version": "3.6.8"
}
},
"nbformat": 4,
Expand Down
21 changes: 19 additions & 2 deletions neptunecontrib/viz/parallel_coordinates_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ def make_parallel_coordinates_plot(html_file_path=None,
You can also inspect the lineage of experiments.
**See** `example <https://neptune-contrib.readthedocs.io/examples/hiplot_visualizations.html>`_
**for full use case.**
**for the full use case.**
Axes are ordered as follows: first axis is neptune ``experiment id``,
second is experiment ``owner``,
then ``params`` and ``properties`` in alphabetical order.
Finally, ``metrics`` on the right side (alphabetical order as well).
This visualization it built using `HiPlot <https://facebookresearch.github.io/hiplot/index.html>`_.
It is a library published by the Facebook AI group.
Expand Down Expand Up @@ -197,6 +202,18 @@ def make_parallel_coordinates_plot(html_file_path=None,
df = df.sort_values(by='neptune_exp_number', ascending=True)
df = df.drop(columns='neptune_exp_number')

# Prepare order of axes, where 'neptune_id' is first, metrics to the right.
all_axes = df.columns.to_list()
if metrics:
metric_names = [j[1] for j in metrics]
metric_names.sort()
for metric in metric_names:
all_axes.remove(metric)
all_axes.sort()
all_axes.sort(reverse=True, key='owner'.__eq__)
all_axes.sort(reverse=True, key='neptune_id'.__eq__)
all_axes = all_axes + metric_names

# Prepare HiPlot visualization
input_to_hiplot = df.T.to_dict().values()
hiplot_vis = hip.Experiment().from_iterable(input_to_hiplot)
Expand All @@ -212,7 +229,7 @@ def make_parallel_coordinates_plot(html_file_path=None,
hiplot_vis.to_html(html_file_path)
hiplot_vis.display_data(hip.Displays.PARALLEL_PLOT).update({'categoricalMaximumValues': df.shape[0],
'hide': ['uid', 'from_uid'],
'order': ['neptune_id']})
'order': all_axes})
return hiplot_vis.display()


Expand Down

0 comments on commit e040d5b

Please sign in to comment.