RecTools
RecTools copied to clipboard
Feature/dual metrics widget
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?
- Update CHANGELOG.md
- Update poetry files
- Update code according to the comments above
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
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
tocompat.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.
Update MetricsApp
- Refactor display method
- Add jupyter example
- Add docstring example
- Update tests
Add optional parameters support from plotly.go.Layout
Let's add explicit info for new users about the use of MetricsApp in 2_cross_validation.ipynb:
-
"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 withpip install rectools[visuals]
-
models_metrics.rename(columns={"model": Columns.Model, "i_split": Columns.Split})
- this we can drop, the names are already the same -
app = MetricsApp.construct(pd.DataFrame(cv_results["metrics"]))
for one line of code instead of two -
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."
-
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 havekaleido
package to process rendering. You can install it withpip install kaleido==0.2.1
and restart the kernel.