Skip to content

Commit

Permalink
1692 iterative graph not showing in docs (#3592)
Browse files Browse the repository at this point in the history
* Shows two graphs, one empty one filled

* Made it only print out one graph

* Updated docstring

* test to see if .show() makes tests slow

* release notes update

* testing to see if returning the figure works

* Trying to make the parameter false.

* show_iteration_plot is now default false

* Added testing and removed redundant code

* Added Becca's changes

* Added check so that tests don't take hours

* Edited some ipynb to reflect change

* Documentation fixes

* Deleted un-needed test
  • Loading branch information
MichaelFu512 authored Jul 7, 2022
1 parent 426f2b3 commit 26896e9
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 28 deletions.
6 changes: 3 additions & 3 deletions docs/source/demos/cost_benefit_matrix.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
"from evalml import AutoMLSearch\n",
"automl = AutoMLSearch(X_train=X_train, y_train=y_train, problem_type='binary', objective='log loss binary',\n",
" max_iterations=5, verbose=True)\n",
"automl.search()\n",
"automl.search(interactive_plot=False)\n",
"\n",
"ll_pipeline = automl.best_pipeline\n",
"ll_pipeline.score(X_holdout, y_holdout, ['log loss binary'])"
Expand Down Expand Up @@ -175,7 +175,7 @@
"source": [
"automl = AutoMLSearch(X_train=X_train, y_train=y_train, problem_type='binary', objective=cost_benefit_matrix,\n",
" max_iterations=5, verbose=True)\n",
"automl.search()\n",
"automl.search(interactive_plot=False)\n",
"\n",
"cbm_pipeline = automl.best_pipeline"
]
Expand Down Expand Up @@ -274,4 +274,4 @@
},
"nbformat": 4,
"nbformat_minor": 4
}
}
4 changes: 2 additions & 2 deletions docs/source/demos/fraud.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
" optimize_thresholds=True,\n",
" verbose=True)\n",
"\n",
"automl.search()"
"automl.search(interactive_plot=False)"
]
},
{
Expand Down Expand Up @@ -219,7 +219,7 @@
" optimize_thresholds=True,\n",
" verbose=True)\n",
"\n",
"automl_auc.search()"
"automl_auc.search(interactive_plot=False)"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions docs/source/demos/lead_scoring.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
" max_batches=3,\n",
" verbose=True)\n",
"\n",
"automl.search()"
"automl.search(interactive_plot=False)"
]
},
{
Expand Down Expand Up @@ -247,7 +247,7 @@
" max_batches=3,\n",
" verbose=True)\n",
"\n",
"automl_auc.search()"
"automl_auc.search(interactive_plot=False)"
]
},
{
Expand Down Expand Up @@ -329,4 +329,4 @@
},
"nbformat": 4,
"nbformat_minor": 4
}
}
6 changes: 3 additions & 3 deletions docs/source/demos/text_input.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
" optimize_thresholds=True,\n",
" verbose=True)\n",
"\n",
"automl.search()"
"automl.search(interactive_plot=False)"
]
},
{
Expand Down Expand Up @@ -362,7 +362,7 @@
" optimize_thresholds=True,\n",
" verbose=True)\n",
"\n",
"automl_no_text.search()"
"automl_no_text.search(interactive_plot=False)"
]
},
{
Expand Down Expand Up @@ -455,4 +455,4 @@
},
"nbformat": 4,
"nbformat_minor": 4
}
}
1 change: 1 addition & 0 deletions docs/source/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Release Notes
**Future Releases**
* Enhancements
* Fixes
* Fixed iterative graphs not appearing in documentation :pr:`3592`
* Updated the `load_diabetes()` method to account for scikit-learn 1.1.1 changes to the dataset :pr:`3591`
* Changes
* Documentation Changes
Expand Down
8 changes: 5 additions & 3 deletions docs/source/start.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,16 @@
"metadata": {},
"outputs": [],
"source": [
"automl.search()"
"automl.search(interactive_plot=False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If you would like to suppress stdout output, set `verbose=False`. This is also the default behavior for `AutoMLSearch` if `verbose` is not specified."
"If you would like to suppress stdout output, set `verbose=False`. This is also the default behavior for `AutoMLSearch` if `verbose` is not specified. \n",
"\n",
"Also, if you would like to see the interactive plot update dynamically over time as the search progresses, either remove the parameter or set `interactive_plot=True`. This is the default setting for `search()` if `interactive_plot` is not specified (it is set to False here due to documentation workaround)."
]
},
{
Expand Down Expand Up @@ -266,4 +268,4 @@
},
"nbformat": 4,
"nbformat_minor": 4
}
}
18 changes: 9 additions & 9 deletions docs/source/user_guide/automl.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
"outputs": [],
"source": [
"automl = evalml.automl.AutoMLSearch(X_train=X_train, y_train=y_train, problem_type='binary', verbose=True)\n",
"automl.search()"
"automl.search(interactive_plot=False)"
]
},
{
Expand Down Expand Up @@ -645,7 +645,7 @@
" ensembling=True,\n",
" automl_algorithm='iterative',\n",
" verbose=True)\n",
"automl_with_ensembling.search()"
"automl_with_ensembling.search(interactive_plot=False)"
]
},
{
Expand Down Expand Up @@ -716,7 +716,7 @@
"source": [
"from evalml import AutoMLSearch\n",
"auto_iterative = AutoMLSearch(X_train=X, y_train=y, problem_type='binary', automl_algorithm='iterative', verbose=True)\n",
"auto_iterative.search()"
"auto_iterative.search(interactive_plot=False)"
]
},
{
Expand Down Expand Up @@ -780,7 +780,7 @@
"source": [
"from evalml import AutoMLSearch\n",
"auto_default = AutoMLSearch(X_train=X, y_train=y, problem_type='binary', automl_algorithm='default', ensembling=True, verbose=True)\n",
"auto_default.search()"
"auto_default.search(interactive_plot=False)"
]
},
{
Expand Down Expand Up @@ -858,7 +858,7 @@
" problem_type=\"binary\",\n",
" allowed_model_families=[ModelFamily.LINEAR_MODEL],\n",
" engine=\"cf_threaded\")\n",
"automl_cf_threaded.search(show_iteration_plot = False)\n",
"automl_cf_threaded.search(interactive_plot = False)\n",
"automl_cf_threaded.close_engine()"
]
},
Expand Down Expand Up @@ -888,7 +888,7 @@
" problem_type=\"binary\",\n",
" allowed_model_families=[ModelFamily.LINEAR_MODEL],\n",
" engine=cf_engine)\n",
"automl_cf_threaded.search(show_iteration_plot = False)\n",
"automl_cf_threaded.search(interactive_plot = False)\n",
"automl_cf_threaded.close_engine()"
]
},
Expand All @@ -906,7 +906,7 @@
"automl_cf_process = AutoMLSearch(X_train=X, y_train=y,\n",
" problem_type=\"binary\",\n",
" engine=\"cf_process\")\n",
"automl_cf_process.search(show_iteration_plot = False)\n",
"automl_cf_process.search(interactive_plot = False)\n",
"automl_cf_process.close_engine()\n",
"```"
]
Expand Down Expand Up @@ -935,7 +935,7 @@
" problem_type=\"binary\",\n",
" allowed_model_families=[ModelFamily.LINEAR_MODEL],\n",
" engine=dask_engine_p2)\n",
"automl_dask_p2.search(show_iteration_plot = False)\n",
"automl_dask_p2.search(interactive_plot = False)\n",
"\n",
"# Explicitly shutdown the automl object's LocalCluster\n",
"automl_dask_p2.close_engine()"
Expand All @@ -953,7 +953,7 @@
" problem_type=\"binary\",\n",
" allowed_model_families=[ModelFamily.LINEAR_MODEL],\n",
" engine=dask_engine_t4)\n",
"automl_dask_t4.search(show_iteration_plot = False)\n",
"automl_dask_t4.search(interactive_plot = False)\n",
"automl_dask_t4.close_engine()"
]
},
Expand Down
18 changes: 13 additions & 5 deletions evalml/automl/automl_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import numpy as np
import pandas as pd
from dask import distributed as dd
from plotly import io as pio
from sklearn.model_selection import BaseCrossValidator
from skopt.space import Categorical

Expand Down Expand Up @@ -857,11 +858,11 @@ def _handle_keyboard_interrupt(self):
else:
leading_char = ""

def search(self, show_iteration_plot=True):
def search(self, interactive_plot=True):
"""Find the best pipeline for the data set.
Args:
show_iteration_plot (boolean, True): Shows an iteration vs. score plot in Jupyter notebook.
interactive_plot (boolean, True): Shows an iteration vs. score plot in Jupyter notebook.
Disabled by default in non-Jupyter enviroments.
Raises:
Expand All @@ -874,11 +875,11 @@ def search(self, show_iteration_plot=True):
return

# don't show iteration plot outside of a jupyter notebook
if show_iteration_plot:
if interactive_plot:
try:
get_ipython
except NameError:
show_iteration_plot = False
interactive_plot = False

log_title(self.logger, "Beginning pipeline search")
self.logger.info("Optimizing for %s. " % self.objective.name)
Expand Down Expand Up @@ -909,7 +910,7 @@ def search(self, show_iteration_plot=True):
self.search_iteration_plot = None
if self.plot and self.verbose:
self.search_iteration_plot = self.plot.search_iteration_plot(
interactive_plot=show_iteration_plot
interactive_plot=interactive_plot
)

self._start = time.time()
Expand Down Expand Up @@ -1006,6 +1007,13 @@ def search(self, show_iteration_plot=True):
f"Best pipeline {self.objective.name}: {best_pipeline['validation_score']:3f}"
)
self._searched = True
if self.search_iteration_plot is not None:
if self.verbose and not interactive_plot:
self.search_iteration_plot = self.plot.search_iteration_plot(
interactive_plot=interactive_plot
)
if pio.renderers.default != "browser":
self.search_iteration_plot.show()

def _find_best_pipeline(self):
"""Finds the best pipeline in the rankings If self._best_pipeline already exists, check to make sure it is different from the current best pipeline before training and thresholding."""
Expand Down

0 comments on commit 26896e9

Please sign in to comment.