From 79aa7cf041d51fbe801578919811c3979fd98763 Mon Sep 17 00:00:00 2001 From: Mario Graff Date: Thu, 27 Feb 2025 17:07:59 +0000 Subject: [PATCH 1/2] sort dataframe --- CompStats/__init__.py | 2 +- CompStats/utils.py | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CompStats/__init__.py b/CompStats/__init__.py index 48a6219..8c23749 100644 --- a/CompStats/__init__.py +++ b/CompStats/__init__.py @@ -11,7 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -__version__ = '0.1.9' +__version__ = '0.1.10' from CompStats.bootstrap import StatisticSamples from CompStats.measurements import CI, SE, difference_p_value from CompStats.performance import performance, difference, all_differences, plot_performance, plot_difference diff --git a/CompStats/utils.py b/CompStats/utils.py index 0eac043..85d8ef0 100644 --- a/CompStats/utils.py +++ b/CompStats/utils.py @@ -63,15 +63,18 @@ def dataframe(instance, value_name:str='Score', perf_names:list=None): """Dataframe""" import pandas as pd + statistic = instance.statistic + if not isinstance(statistic, dict): + iter = instance.statistic_samples.keys() + else: + iter = statistic if isinstance(instance.best, str): - df = pd.DataFrame(dict(instance.statistic_samples.calls.items())) + calls = instance.statistic_samples.calls + df = pd.DataFrame({k: calls[k] + for k in iter if k in calls}) return df.melt(var_name=alg_legend, value_name=value_name) df = pd.DataFrame() - if not isinstance(instance.statistic, dict): - iter = instance.statistic_samples.keys() - else: - iter = instance.statistic for key in iter: data = instance.statistic_samples[key] _df = pd.DataFrame(data, From 1ff52414bdf2a2b5fea1b2edeb5cf544e283ca6e Mon Sep 17 00:00:00 2001 From: Mario Graff Date: Thu, 27 Feb 2025 17:21:01 +0000 Subject: [PATCH 2/2] value_name is overwritten --- CompStats/interface.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/CompStats/interface.py b/CompStats/interface.py index b1e2ee0..f1143a3 100644 --- a/CompStats/interface.py +++ b/CompStats/interface.py @@ -159,7 +159,7 @@ def __repr__(self): desc_se = [f'{k:0.4f}' for k in self.se] desc_se = ', '.join(desc_se) return f"<{self.__class__.__name__}({arg}={func_name}, statistic=[{desc}], se=[{desc_se}])>" - + def __str__(self): """Prediction statistics with standard error in parenthesis""" if not isinstance(self.statistic, dict): @@ -358,10 +358,11 @@ def plot(self, value_name:str=None, >>> perf.plot() """ import seaborn as sns - if self.score_func is not None: - value_name = 'Score' - else: - value_name = 'Error' + if value_name is None: + if self.score_func is not None: + value_name = 'Score' + else: + value_name = 'Error' df = self.dataframe(value_name=value_name, var_name=var_name, alg_legend=alg_legend, perf_names=perf_names) if var_name not in df.columns: