Skip to content

Commit

Permalink
import from hoocs
Browse files Browse the repository at this point in the history
  • Loading branch information
bluecher31 committed Jan 16, 2024
1 parent 942a346 commit 2df9102
Show file tree
Hide file tree
Showing 18 changed files with 39 additions and 40 deletions.
6 changes: 3 additions & 3 deletions src/hoocs/approximate_shapley_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions src/hoocs/base_explainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions src/hoocs/derived_explainer_targeted.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/hoocs/helper_kernelshap.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import numpy
import numpy as np
from scipy.special import binom

Expand Down
2 changes: 1 addition & 1 deletion src/hoocs/imputers/color_sampling_imputer.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
2 changes: 1 addition & 1 deletion src/hoocs/imputers/opencv_inpainting.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/hoocs/imputers/simple_imputers.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
10 changes: 5 additions & 5 deletions src/hoocs/kernelshap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions src/hoocs/preddiff.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
8 changes: 4 additions & 4 deletions src/hoocs/shapley.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions tests/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/test_approximate_shapley_values.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/test_helper_base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from src.hoocs import helper_base
from hoocs import helper_base


def test_organize_key():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_helper_kernelshap.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
4 changes: 2 additions & 2 deletions tests/test_kernelshap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests/test_preddiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions tests/test_shapley.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/test_simple_imputers.py
Original file line number Diff line number Diff line change
@@ -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():
Expand Down

0 comments on commit 2df9102

Please sign in to comment.