Skip to content
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

Update Model_Understanding documentation for plotly use on Jupyter Lab #1108

Merged
merged 27 commits into from Sep 3, 2020

Conversation

bchen1116
Copy link
Contributor

@bchen1116 bchen1116 commented Aug 26, 2020

Fix #1040

Plots doesn't show up on Jupyter Lab

Fixed the documentation for this to let users know the necessary installations for Jupyter Lab to work with plotly.

@codecov
Copy link

codecov bot commented Aug 26, 2020

Codecov Report

Merging #1108 into main will decrease coverage by 0.00%.
The diff coverage is 99.02%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1108      +/-   ##
==========================================
- Coverage   99.91%   99.91%   -0.01%     
==========================================
  Files         195      195              
  Lines       11159    11257      +98     
==========================================
+ Hits        11150    11247      +97     
- Misses          9       10       +1     
Impacted Files Coverage Δ
evalml/utils/gen_utils.py 98.91% <92.85%> (-1.09%) ⬇️
evalml/model_understanding/graphs.py 100.00% <100.00%> (ø)
evalml/pipelines/pipeline_base.py 100.00% <100.00%> (ø)
...lml/tests/model_understanding_tests/test_graphs.py 100.00% <100.00%> (ø)
evalml/tests/pipeline_tests/test_graphs.py 100.00% <100.00%> (ø)
evalml/tests/utils_tests/test_gen_utils.py 100.00% <100.00%> (ø)
evalml/utils/__init__.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 312ae65...bec9cd1. Read the comment docs.

@bchen1116 bchen1116 self-assigned this Aug 27, 2020
@bchen1116 bchen1116 marked this pull request as ready for review Aug 27, 2020
@bchen1116 bchen1116 requested review from angela97lin and dsherry Aug 27, 2020
@@ -105,6 +105,7 @@ def graph_precision_recall_curve(y_true, y_pred_proba, title_addition=None):
plotly.Figure representing the precision-recall plot generated
"""
_go = import_or_raise("plotly.graph_objects", error_msg="Cannot find dependency plotly.graph_objects")
import_or_raise("ipywidgets", error_msg="Cannot find dependency ipywidgets")
Copy link
Contributor

@jeremyliweishih jeremyliweishih Aug 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might limit the use of our graphs for only notebook environments - not too sure if this is an issue but I can see use cases where we need to return the ploty figures and display them in a web environment. I think maybe the doc edit is good enough for users that want to use our graphs in a notebook environment.

Copy link
Contributor Author

@bchen1116 bchen1116 Aug 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah great point. Thanks @jeremyliweishih, I'll update this.

Copy link
Contributor

@freddyaboulton freddyaboulton Aug 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can try to use get_ipython like we do in AutoMLSearch to decide whether or not to surface this error? Maybe we also don't need to raise, we can just issue a warning about possible missing dependencies? @jeff-hernandez was not seeing any plots show up in Jupyter Lab and it's really confusing when it happens (See this PR).

Copy link
Contributor Author

@bchen1116 bchen1116 Aug 31, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My current implementation uses a jupyter_check function that does a try-except with get_ipython, which would return True if the call succeeds, or if it throws an exception, False. Unfortunately, I'm not able to test whether this call works through unittests since I cannot patch get_ipython -- I get the following error: ModuleNotFoundError: No module named 'Ipython'. Because of this, I can't test whether or not ipywidgets is installed or not properly, since I only make this call if jupyter_check returns True.

@freddyaboulton suggested that we could get coverage for this if we add ipython to test-requirements.txt, but we weren't sure if this is the best course of action.

docs/source/release_notes.rst Outdated Show resolved Hide resolved
@bchen1116 bchen1116 changed the title Fix Plotly Error for JupyterLab Update Model_Understanding documentation for plotly use on Jupyter Lab Aug 28, 2020
Copy link
Contributor

@freddyaboulton freddyaboulton left a comment

@bchen1116 I think this is almost ready for merge! I have a couple of suggestions for how to increase test coverage.

evalml/tests/pipeline_tests/test_graphs.py Show resolved Hide resolved
evalml/pipelines/pipeline_base.py Outdated Show resolved Hide resolved
evalml/tests/pipeline_tests/test_graphs.py Show resolved Hide resolved
evalml/tests/utils_tests/test_gen_utils.py Show resolved Hide resolved
"""
try:
get_ipython()
return True
Copy link
Contributor

@freddyaboulton freddyaboulton Sep 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can get to a point where this is the only line that's not covered by unit tests.

Copy link
Contributor

@freddyaboulton freddyaboulton left a comment

@bchen1116 This looks good to merge! The only thing I can suggest is to remove the category=ImportWarning so that the warning is displayed to the user.

For those following, I think it's ok to merge this PR without passing the codecov check because only one line is not covered and we can cover it if we add IPython as a test requirement (so that we can mock the get_ipython function) but I'm not sure if we need to add such a big dependency.

I verified this works as expected in Jupyter Lab (once we remove the warning category)!

image

evalml/utils/gen_utils.py Outdated Show resolved Hide resolved
evalml/utils/gen_utils.py Outdated Show resolved Hide resolved
@freddyaboulton freddyaboulton merged commit ccdae9c into main Sep 3, 2020
@bchen1116 bchen1116 deleted the bc_1040_graph branch Sep 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

evalml plots don't show up in Jupyter Lab
4 participants