@@ -1379,7 +1379,7 @@ def plot_results(
13791379 min_score = None ,
13801380 show_scores = None ,
13811381 show_choices = None ,
1382- show_times = True ,
1382+ show_times = None ,
13831383 ):
13841384 """Create a parallel coordinate plot of the cross-validation results.
13851385
@@ -1407,38 +1407,34 @@ def plot_results(
14071407 (e.g. "alpha" in ``choose_float(0.0, 1.0, name="alpha")``).
14081408 By default all are shown.
14091409
1410- show_times : bool, optional, default=True
1411- Whether to show fit and score time or not.
1410+ show_times : list of str, optional
1411+ List of durations to show. Available times are ["fit", "score"].
1412+ By default both are shown.
14121413
14131414 Returns
14141415 -------
14151416 Plotly Figure
14161417 """
14171418
1418- # Check that requested show_scores and show_choices (if any) are available
1419-
1420- if isinstance (show_scores , str ):
1421- show_scores = [show_scores ]
1422- if show_scores is not None :
1423- available_scores = self ._get_score_names ()
1424- missing_scores = set (show_scores ).difference (available_scores )
1425- if missing_scores :
1426- raise ValueError (
1427- "The following scores were requested in show_scores "
1428- f"but do not exist in the results:\n { missing_scores } .\n "
1429- f"The available scores are:\n { available_scores } ."
1430- )
1431- if isinstance (show_choices , str ):
1432- show_choices = [show_choices ]
1433- if show_choices is not None :
1434- available_choices = self ._get_choice_names ()
1435- missing_choices = set (show_choices ).difference (available_choices )
1436- if missing_choices :
1437- raise ValueError (
1438- "The following choices (params) were requested in show_choices "
1439- f"but do not exist in the results:\n { missing_choices } .\n "
1440- f"The available choices are: { available_choices } ."
1441- )
1419+ # Check that requested show_scores, show_choices, and show_times
1420+ # (if any) are available
1421+
1422+ def _check (requested , available , name ):
1423+ if isinstance (requested , str ):
1424+ requested = [requested ]
1425+ if requested is not None :
1426+ missing = set (requested ).difference (available )
1427+ if missing :
1428+ raise ValueError (
1429+ f"The following { name } were requested in show_{ name } "
1430+ f"but do not exist in the results:\n { missing } .\n "
1431+ f"The available { name } are:\n { available } ."
1432+ )
1433+ return requested
1434+
1435+ show_scores = _check (show_scores , self ._get_score_names (), "scores" )
1436+ show_choices = _check (show_choices , self ._get_choice_names (), "choices" )
1437+ show_times = _check (show_times , ["fit" , "score" ], "times" )
14421438
14431439 # Prepare the figure data
14441440
@@ -1461,8 +1457,11 @@ def plot_results(
14611457 if col_meta ["type" ] == "choice" :
14621458 if show_choices is not None and col_meta ["name" ] not in show_choices :
14631459 to_drop .add (col_name )
1464- time_cols = {"mean_fit_time" , "mean_score_time" }
1465- to_drop = (to_drop - time_cols ) if show_times else (to_drop | time_cols )
1460+ for meth in ["fit" , "score" ]:
1461+ if show_times is None or meth in show_times :
1462+ to_drop .discard (f"mean_{ meth } _time" )
1463+ else :
1464+ to_drop .add (f"mean_{ meth } _time" )
14661465 to_show = set (cv_results .columns ) - to_drop
14671466
14681467 # Find rows to show based on min_score
0 commit comments