RecTools icon indicating copy to clipboard operation
RecTools copied to clipboard

Feature/dual metrics widget

Open Gooogr opened this issue 9 months ago • 3 comments

Description

Add a Plotly scatterplot widget for metrics visualization, enabling support for visualizing data per fold or their average values. Closes #93

Type of change

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [ ] Optimization

How Has This Been Tested?

Before submitting a PR, please check yourself against the following list. It would save us quite a lot of time.

  • Have you read the contribution guide?
  • Have you updated the relevant docstrings? We're using Numpy format, please double-check yourself
  • Does your change require any new tests?
  • Have you updated the changelog file?

Gooogr avatar May 16 '24 20:05 Gooogr

  • Update CHANGELOG.md
  • Update poetry files
  • Update code according to the comments above

Gooogr avatar May 19 '24 21:05 Gooogr

Updated the code based on feedback and added docstrings. Remaining tasks:

  • Create a Jupyter notebook example
  • Update the poetry lock file and get last updates from master branch

Gooogr avatar May 20 '24 21:05 Gooogr

Changed the principle of widget design, now it relies on go.WidgetFigure. Also switch from plotly express to plotly graph object scatter chart, because WidgetFigure doesn't support express wrapper. TODO:

  • Simplify display method
  • Expand MetricsApp documentation
  • Add MetricsApp to compat.py
  • Probably add width and height as optional parameters again.

Currently, support for plotly_kwargs has been removed due to the large amount of customization inside the display method. But the users would be able to customize the chart appearance at the static rendering stage. Add example in jupyter notebook.

Gooogr avatar May 22 '24 21:05 Gooogr

Update MetricsApp

  • Refactor display method
  • Add jupyter example
  • Add docstring example
  • Update tests

Add optional parameters support from plotly.go.Layout

Gooogr avatar May 23 '24 17:05 Gooogr

Let's add explicit info for new users about the use of MetricsApp in 2_cross_validation.ipynb:

  1. "And let's visualuze metrics" -> In RecTools we have interactive MetricsApp for detailed analysis of metrics trade-off between different models. visuals extension is required to run the path of code below. You can install it with pip install rectools[visuals]

  2. models_metrics.rename(columns={"model": Columns.Model, "i_split": Columns.Split}) - this we can drop, the names are already the same

  3. app = MetricsApp.construct(pd.DataFrame(cv_results["metrics"])) for one line of code instead of two

  4. Before app screenshot: "If you run this notebook, you will get interactive widgets with active buttons to select metrics and folds. For offline presentation we keep static screenshots of the actual app."

  5. After app screenshot: "If you want to save static image from your app, you can access plotly.graph_objs.Figure and render it as an image. Make sure you have kaleido package to process rendering. You can install it with pip install kaleido==0.2.1 and restart the kernel.

blondered avatar May 24 '24 21:05 blondered