From 2df9102b59ecd691561574ecde55cd4f4edee337 Mon Sep 17 00:00:00 2001 From: Stefan Bluecher Date: Tue, 16 Jan 2024 13:40:59 +0100 Subject: [PATCH] import from hoocs --- src/hoocs/approximate_shapley_values.py | 6 +++--- src/hoocs/base_explainer.py | 4 ++-- src/hoocs/derived_explainer_targeted.py | 6 +++--- src/hoocs/helper_kernelshap.py | 1 - src/hoocs/imputers/color_sampling_imputer.py | 2 +- src/hoocs/imputers/opencv_inpainting.py | 2 +- src/hoocs/imputers/simple_imputers.py | 4 ++-- src/hoocs/kernelshap.py | 10 +++++----- src/hoocs/preddiff.py | 6 +++--- src/hoocs/shapley.py | 8 ++++---- tests/helper.py | 4 ++-- tests/test_approximate_shapley_values.py | 4 ++-- tests/test_helper_base.py | 2 +- tests/test_helper_kernelshap.py | 2 +- tests/test_kernelshap.py | 4 ++-- tests/test_preddiff.py | 6 +++--- tests/test_shapley.py | 4 ++-- tests/test_simple_imputers.py | 4 ++-- 18 files changed, 39 insertions(+), 40 deletions(-) diff --git a/src/hoocs/approximate_shapley_values.py b/src/hoocs/approximate_shapley_values.py index 67b39c1..6df0fec 100644 --- a/src/hoocs/approximate_shapley_values.py +++ b/src/hoocs/approximate_shapley_values.py @@ -4,9 +4,9 @@ from typing import Callable, Dict, List, Set from numpy.typing import NDArray -from src.hoocs.base_explainer import BaseExplainer -from src.hoocs.imputers.abstract_imputer import Imputer -from src.hoocs.shapley import ShapleyValues +from hoocs.base_explainer import BaseExplainer +from hoocs.imputers.abstract_imputer import Imputer +from hoocs.shapley import ShapleyValues def shapley_normalization(n_features: int, cardinality: int) -> float: diff --git a/src/hoocs/base_explainer.py b/src/hoocs/base_explainer.py index 8c00090..a35242a 100644 --- a/src/hoocs/base_explainer.py +++ b/src/hoocs/base_explainer.py @@ -5,8 +5,8 @@ from numpy.typing import NDArray -from src.hoocs.imputers.abstract_imputer import Imputer -from src.hoocs import helper_base +from hoocs.imputers.abstract_imputer import Imputer +from hoocs import helper_base from abc import ABC, abstractmethod diff --git a/src/hoocs/derived_explainer_targeted.py b/src/hoocs/derived_explainer_targeted.py index f3c4a5d..ee333c7 100644 --- a/src/hoocs/derived_explainer_targeted.py +++ b/src/hoocs/derived_explainer_targeted.py @@ -3,9 +3,9 @@ from abc import abstractmethod -from src.hoocs.imputers.abstract_imputer import Imputer -from src.hoocs.base_explainer import BaseExplainer -from src.hoocs.base_explainer import ModelFn, DictAttributions +from hoocs.imputers.abstract_imputer import Imputer +from hoocs.base_explainer import BaseExplainer +from hoocs.base_explainer import ModelFn, DictAttributions from typing import List, Set from numpy.typing import NDArray diff --git a/src/hoocs/helper_kernelshap.py b/src/hoocs/helper_kernelshap.py index 31eac70..f5a86f8 100644 --- a/src/hoocs/helper_kernelshap.py +++ b/src/hoocs/helper_kernelshap.py @@ -1,4 +1,3 @@ -import numpy import numpy as np from scipy.special import binom diff --git a/src/hoocs/imputers/color_sampling_imputer.py b/src/hoocs/imputers/color_sampling_imputer.py index e366ad5..1a26d23 100644 --- a/src/hoocs/imputers/color_sampling_imputer.py +++ b/src/hoocs/imputers/color_sampling_imputer.py @@ -1,6 +1,6 @@ import numpy as np -from src.hoocs.imputers.abstract_imputer import Imputer +from hoocs.imputers.abstract_imputer import Imputer from numpy.typing import NDArray diff --git a/src/hoocs/imputers/opencv_inpainting.py b/src/hoocs/imputers/opencv_inpainting.py index b35d6f3..76a0906 100644 --- a/src/hoocs/imputers/opencv_inpainting.py +++ b/src/hoocs/imputers/opencv_inpainting.py @@ -1,7 +1,7 @@ import numpy as np import cv2 -from src.hoocs.imputers.abstract_imputer import Imputer +from hoocs.imputers.abstract_imputer import Imputer from typing import Callable from numpy.typing import NDArray diff --git a/src/hoocs/imputers/simple_imputers.py b/src/hoocs/imputers/simple_imputers.py index 995d21e..c459710 100644 --- a/src/hoocs/imputers/simple_imputers.py +++ b/src/hoocs/imputers/simple_imputers.py @@ -1,9 +1,9 @@ import numpy as np -from src.hoocs.imputers.abstract_imputer import create_clean_imputation +from hoocs.imputers.abstract_imputer import create_clean_imputation -from src.hoocs.imputers.abstract_imputer import Imputer +from hoocs.imputers.abstract_imputer import Imputer from numpy.typing import NDArray diff --git a/src/hoocs/kernelshap.py b/src/hoocs/kernelshap.py index 45bc955..17a598c 100644 --- a/src/hoocs/kernelshap.py +++ b/src/hoocs/kernelshap.py @@ -5,11 +5,11 @@ from typing import Callable, Dict, List, Set from numpy.typing import NDArray -from src.hoocs.base_explainer import BaseExplainer -from src.hoocs.imputers.abstract_imputer import Imputer -from src.hoocs.helper_kernelshap import shap_kernel_weight -from src.hoocs.helper_kernelshap import convert_coalitions_to_segmentation -from src.hoocs import helper_kernelshap +from hoocs.base_explainer import BaseExplainer +from hoocs.imputers.abstract_imputer import Imputer +from hoocs.helper_kernelshap import shap_kernel_weight +from hoocs.helper_kernelshap import convert_coalitions_to_segmentation +from hoocs import helper_kernelshap class KernelSHAP(BaseExplainer): diff --git a/src/hoocs/preddiff.py b/src/hoocs/preddiff.py index ffde499..4665cf0 100644 --- a/src/hoocs/preddiff.py +++ b/src/hoocs/preddiff.py @@ -1,9 +1,9 @@ from typing import Callable, List, Set from numpy.typing import NDArray -from src.hoocs.imputers.abstract_imputer import Imputer +from hoocs.imputers.abstract_imputer import Imputer -from src.hoocs import helper_methods -from src.hoocs.derived_explainer_targeted import TargetedAttributionsMethod +from hoocs import helper_methods +from hoocs.derived_explainer_targeted import TargetedAttributionsMethod class PredDiff(TargetedAttributionsMethod): diff --git a/src/hoocs/shapley.py b/src/hoocs/shapley.py index f58ee32..eb44126 100644 --- a/src/hoocs/shapley.py +++ b/src/hoocs/shapley.py @@ -2,11 +2,11 @@ from numpy.typing import NDArray from typing import Callable, List, Set -from src.hoocs.imputers.abstract_imputer import Imputer +from hoocs.imputers.abstract_imputer import Imputer -from src.hoocs import helper_kernelshap -from src.hoocs import helper_methods -from src.hoocs.derived_explainer_targeted import TargetedAttributionsMethod +from hoocs import helper_kernelshap +from hoocs import helper_methods +from hoocs.derived_explainer_targeted import TargetedAttributionsMethod def _get_unique_features(list_features: List[str]) -> NDArray: diff --git a/tests/helper.py b/tests/helper.py index 479b031..e1ed380 100644 --- a/tests/helper.py +++ b/tests/helper.py @@ -2,8 +2,8 @@ import numpy as np -from src.hoocs.derived_explainer_targeted import TargetedAttributionsMethod -from src.hoocs.imputers import simple_imputers +from hoocs.derived_explainer_targeted import TargetedAttributionsMethod +from hoocs.imputers import simple_imputers from tests import simple_models from numpy.testing import assert_allclose diff --git a/tests/test_approximate_shapley_values.py b/tests/test_approximate_shapley_values.py index 576f8bb..aa95221 100644 --- a/tests/test_approximate_shapley_values.py +++ b/tests/test_approximate_shapley_values.py @@ -1,7 +1,7 @@ import numpy as np -from src.hoocs.approximate_shapley_values import ApproximateShapleyValues, shapley_normalization -from src.hoocs.imputers import simple_imputers +from hoocs.approximate_shapley_values import ApproximateShapleyValues, shapley_normalization +from hoocs.imputers import simple_imputers from tests import simple_models from tests.test_kernelshap import check_efficiency diff --git a/tests/test_helper_base.py b/tests/test_helper_base.py index 93b6552..5ffb141 100644 --- a/tests/test_helper_base.py +++ b/tests/test_helper_base.py @@ -1,4 +1,4 @@ -from src.hoocs import helper_base +from hoocs import helper_base def test_organize_key(): diff --git a/tests/test_helper_kernelshap.py b/tests/test_helper_kernelshap.py index 34dd65d..5794144 100644 --- a/tests/test_helper_kernelshap.py +++ b/tests/test_helper_kernelshap.py @@ -1,6 +1,6 @@ import numpy as np -from src.hoocs import helper_kernelshap +from hoocs import helper_kernelshap from numpy.testing import assert_allclose diff --git a/tests/test_kernelshap.py b/tests/test_kernelshap.py index 31e8ffa..e6a9190 100644 --- a/tests/test_kernelshap.py +++ b/tests/test_kernelshap.py @@ -4,8 +4,8 @@ import numpy as np from numpy.testing import assert_allclose -from src.hoocs import kernelshap -from src.hoocs.imputers import simple_imputers +from hoocs import kernelshap +from hoocs.imputers import simple_imputers from tests import simple_models from typing import Dict, Set diff --git a/tests/test_preddiff.py b/tests/test_preddiff.py index ec90887..5495c09 100644 --- a/tests/test_preddiff.py +++ b/tests/test_preddiff.py @@ -12,9 +12,9 @@ """ import numpy as np -from src.hoocs import helper_methods -from src.hoocs import preddiff -from src.hoocs.imputers import simple_imputers +from hoocs import helper_methods +from hoocs import preddiff +from hoocs.imputers import simple_imputers from tests import simple_models, helper diff --git a/tests/test_shapley.py b/tests/test_shapley.py index 5a2ac4a..9f2cf1a 100644 --- a/tests/test_shapley.py +++ b/tests/test_shapley.py @@ -1,8 +1,8 @@ import numpy as np from numpy.testing import assert_allclose -from src.hoocs import shapley -from src.hoocs.imputers import simple_imputers +from hoocs import shapley +from hoocs.imputers import simple_imputers from tests import simple_models import pytest diff --git a/tests/test_simple_imputers.py b/tests/test_simple_imputers.py index d3ab248..05b94cd 100644 --- a/tests/test_simple_imputers.py +++ b/tests/test_simple_imputers.py @@ -1,7 +1,7 @@ import numpy as np -from src.hoocs.imputers import simple_imputers -from src.hoocs import helper_base +from hoocs.imputers import simple_imputers +from hoocs import helper_base class TestConstantValueImputer():