Coverage for mlos_viz/mlos_viz/dabl.py: 100%
22 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-10-07 01:52 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-10-07 01:52 +0000
1#
2# Copyright (c) Microsoft Corporation.
3# Licensed under the MIT License.
4#
5"""Small wrapper functions for dabl plotting functions via mlos_bench data."""
6import warnings
7from typing import Dict, Literal, Optional
9import dabl
10import pandas
12from mlos_bench.storage.base_experiment_data import ExperimentData
13from mlos_viz.util import expand_results_data_args
16def plot(
17 exp_data: Optional[ExperimentData] = None,
18 *,
19 results_df: Optional[pandas.DataFrame] = None,
20 objectives: Optional[Dict[str, Literal["min", "max"]]] = None,
21) -> None:
22 """
23 Plots the Experiment results data using dabl.
25 Parameters
26 ----------
27 exp_data : ExperimentData
28 The ExperimentData (e.g., obtained from the storage layer) to plot.
29 results_df : Optional["pandas.DataFrame"]
30 Optional results_df to plot.
31 If not provided, defaults to exp_data.results_df property.
32 objectives : Optional[Dict[str, Literal["min", "max"]]]
33 Optional objectives to plot.
34 If not provided, defaults to exp_data.objectives property.
35 """
36 (results_df, obj_cols) = expand_results_data_args(exp_data, results_df, objectives)
37 for obj_col in obj_cols:
38 dabl.plot(X=results_df, target_col=obj_col)
41def ignore_plotter_warnings() -> None:
42 """Add some filters to ignore warnings from the plotter."""
43 # pylint: disable=import-outside-toplevel
44 warnings.filterwarnings("ignore", category=FutureWarning)
45 warnings.filterwarnings(
46 "ignore",
47 module="dabl",
48 category=UserWarning,
49 message="Could not infer format",
50 )
51 warnings.filterwarnings(
52 "ignore",
53 module="dabl",
54 category=UserWarning,
55 message="(Dropped|Discarding) .* outliers",
56 )
57 warnings.filterwarnings(
58 "ignore",
59 module="dabl",
60 category=UserWarning,
61 message="Not plotting highly correlated",
62 )
63 warnings.filterwarnings(
64 "ignore",
65 module="dabl",
66 category=UserWarning,
67 message="Missing values in target_col have been removed for regression",
68 )
69 from sklearn.exceptions import UndefinedMetricWarning
71 warnings.filterwarnings(
72 "ignore",
73 module="sklearn",
74 category=UndefinedMetricWarning,
75 message="Recall is ill-defined",
76 )
77 warnings.filterwarnings(
78 "ignore",
79 category=DeprecationWarning,
80 message="is_categorical_dtype is deprecated and will be removed in a future version.",
81 )
82 warnings.filterwarnings(
83 "ignore",
84 category=DeprecationWarning,
85 module="sklearn",
86 message="is_sparse is deprecated and will be removed in a future version.",
87 )
88 from matplotlib._api.deprecation import MatplotlibDeprecationWarning
90 warnings.filterwarnings(
91 "ignore",
92 category=MatplotlibDeprecationWarning,
93 module="dabl",
94 message="The legendHandles attribute was deprecated in Matplotlib 3.7 and will be removed",
95 )