From 1deb9a5c284aa14e0d9cab754a1d18bd14509140 Mon Sep 17 00:00:00 2001 From: DaniSanchezSantolaya Date: Fri, 24 May 2024 10:58:26 +0200 Subject: [PATCH 1/3] add linear combionations found when LinearCombinationsTest fails --- mercury/robust/data_tests.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mercury/robust/data_tests.py b/mercury/robust/data_tests.py index 2a2939e..cb42c71 100644 --- a/mercury/robust/data_tests.py +++ b/mercury/robust/data_tests.py @@ -134,7 +134,14 @@ def run(self, *args, **kwargs): ) if lin_combinations is not None: - raise FailedTestError("Test failed. Linear combinations for continuous features were encountered.") + # Create message with the linear combinations found + lin_combinations = np.around(lin_combinations, decimals=5) + lin_combs_found = [] + for i in range(lin_combinations.shape[0]): + lin_comb_idx = np.where(lin_combinations[i] != 0)[0] + lin_comb_cols = self.base_dataset.loc[:, numeric_feats].columns[lin_comb_idx].tolist() + lin_combs_found.append(lin_comb_cols) + raise FailedTestError(f"Test failed. Linear combinations for continuous features were encountered: {lin_combs_found}.") individually_redundant = CategoryStruct.individually_redundant(self.base_dataset, current_schema.categorical_feats) if len(individually_redundant) > 0: From 44f50c53deda4a0905b37b35bc3bb2397f99f3ae Mon Sep 17 00:00:00 2001 From: DaniSanchezSantolaya Date: Fri, 24 May 2024 11:00:37 +0200 Subject: [PATCH 2/3] unit test LinearCombinationsTest --- tests/test_data_tests.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test_data_tests.py b/tests/test_data_tests.py index 08e167e..3f136cb 100644 --- a/tests/test_data_tests.py +++ b/tests/test_data_tests.py @@ -857,4 +857,20 @@ def test_no_duplicated_test(): with pytest.raises(FailedTestError): test.run() +def test_lin_combinations_cont(): + df = pd.DataFrame() + df["f1"] = np.random.uniform(size=100) + df["f2"] = df["f1"] * 2 + df["f3"] = np.random.uniform(size=100) + df["f4"] = df["f1"] + df["f2"] + df["f5"] = np.random.uniform(size=100) + + df["f6"] = np.random.uniform(size=100) + df["f7"] = df["f6"] * 3 + df["f8"] = df["f6"] * 0.1 + + schma_reference = DataSchema().generate(df).calculate_statistics() + linear_comb_test = LinearCombinationsTest(df, dataset_schema=schma_reference) + with pytest.raises(FailedTestError, match="'f1', 'f2'"): + linear_comb_test.run() From b978e7b2349b81013207a563ae9d8061a2737981 Mon Sep 17 00:00:00 2001 From: DaniSanchezSantolaya Date: Tue, 28 May 2024 13:02:28 +0200 Subject: [PATCH 3/3] upgrade version --- .bumpversion.cfg | 2 +- README.md | 2 +- docs/index.md | 2 +- mercury/robust/__init__.py | 2 +- pyproject.toml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 4844392..f5f6d74 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.0.2 +current_version = 0.0.3 parse = (?P\d+)\.(?P\d+)\.(?P\d+)(-(?P\w+)\.(?P\d+))? serialize = {major}.{minor}.{patch}-{release}.{build} diff --git a/README.md b/README.md index bc21161..769341c 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # mercury-robust [![](https://github.com/BBVA/mercury-robust/actions/workflows/test.yml/badge.svg)](https://github.com/BBVA/mercury-robust) -![](https://img.shields.io/badge/latest-0.0.2-blue) +![](https://img.shields.io/badge/latest-0.0.3-blue) ## Mercury project at BBVA diff --git a/docs/index.md b/docs/index.md index fb15234..77795e7 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,7 +1,7 @@ # mercury-robust [![](https://github.com/BBVA/mercury-robust/actions/workflows/test.yml/badge.svg)](https://github.com/BBVA/mercury-robust) -![](https://img.shields.io/badge/latest-0.0.2-blue) +![](https://img.shields.io/badge/latest-3-blue) ***mercury-robust*** is a library to perform robust testing on models and/or datasets. diff --git a/mercury/robust/__init__.py b/mercury/robust/__init__.py index 49b2ada..8d089c9 100644 --- a/mercury/robust/__init__.py +++ b/mercury/robust/__init__.py @@ -4,6 +4,6 @@ Top-level package for mercury robust. """ -__version__ = '0.0.2' +__version__ = '0.0.3' from .suite import TestSuite # noqa: 402 diff --git a/pyproject.toml b/pyproject.toml index bd99c16..592f2f5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta" [project] name = "mercury-robust" license = {file = "LICENSE.txt"} -version = "0.0.2" +version = "0.0.3" authors = [ { name="Mercury Team", email="mercury.group@bbva.com" }, ]