Skip to content

Commit 3095f98

Browse files
author
Jaime Céspedes Sisniega
authored
Merge pull request #158 from IFCA/fix-histogram-intersection-name
Fix HistogramIntersection to HINormalizedComplement
2 parents 3279c10 + 8bcbab1 commit 3095f98

File tree

9 files changed

+20
-20
lines changed

9 files changed

+20
-20
lines changed

docs/source/api_reference/detectors.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ The {mod}`frouros.detectors` module contains drift detection algorithms.
140140
BhattacharyyaDistance
141141
EMD
142142
HellingerDistance
143-
HistogramIntersection
143+
HINormalizedComplement
144144
JS
145145
KL
146146
MMD

docs/source/images/detectors.png

5.79 KB
Loading

frouros/detectors/data_drift/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
CVMTest,
77
EMD,
88
HellingerDistance,
9-
HistogramIntersection,
9+
HINormalizedComplement,
1010
JS,
1111
KL,
1212
KSTest,
@@ -23,7 +23,7 @@
2323
"CVMTest",
2424
"EMD",
2525
"HellingerDistance",
26-
"HistogramIntersection",
26+
"HINormalizedComplement",
2727
"IncrementalKSTest",
2828
"JS",
2929
"KL",

frouros/detectors/data_drift/batch/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
BhattacharyyaDistance,
55
EMD,
66
HellingerDistance,
7-
HistogramIntersection,
7+
HINormalizedComplement,
88
JS,
99
KL,
1010
PSI,
@@ -23,7 +23,7 @@
2323
"CVMTest",
2424
"EMD",
2525
"HellingerDistance",
26-
"HistogramIntersection",
26+
"HINormalizedComplement",
2727
"JS",
2828
"KL",
2929
"KSTest",

frouros/detectors/data_drift/batch/distance_based/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from .bhattacharyya_distance import BhattacharyyaDistance
44
from .emd import EMD
55
from .hellinger_distance import HellingerDistance
6-
from .histogram_intersection import HistogramIntersection
6+
from .hi_normalized_complement import HINormalizedComplement
77
from .js import JS
88
from .kl import KL
99
from .psi import PSI
@@ -13,7 +13,7 @@
1313
"BhattacharyyaDistance",
1414
"EMD",
1515
"HellingerDistance",
16-
"HistogramIntersection",
16+
"HINormalizedComplement",
1717
"JS",
1818
"KL",
1919
"PSI",

frouros/detectors/data_drift/batch/distance_based/histogram_intersection.py renamed to frouros/detectors/data_drift/batch/distance_based/hi_normalized_complement.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Histogram intersection module."""
1+
"""HI (Histogram intersection) normalized complement module."""
22

33
from typing import List, Optional, Union
44

@@ -10,8 +10,8 @@
1010
)
1111

1212

13-
class HistogramIntersection(DistanceBinsBasedBase):
14-
"""Histogram intersection [swain1991color]_ detector.
13+
class HINormalizedComplement(DistanceBinsBasedBase):
14+
"""HI (Histogram intersection) normalized complement [swain1991color]_ detector.
1515
1616
:References:
1717
@@ -33,7 +33,7 @@ def __init__(
3333
:type callbacks: Optional[Union[Callback, List[Callback]]]
3434
"""
3535
super().__init__(
36-
statistical_method=self._histogram_intersection,
36+
statistical_method=self._hi_normalized_complement,
3737
statistical_kwargs={
3838
"num_bins": num_bins,
3939
},
@@ -46,13 +46,13 @@ def _distance_measure_bins(
4646
X_ref: np.ndarray, # noqa: N803
4747
X: np.ndarray, # noqa: N803
4848
) -> float:
49-
no_intersection = self._histogram_intersection(
49+
intersection_normalized_complement = self._hi_normalized_complement(
5050
X=X_ref, Y=X, num_bins=self.num_bins
5151
)
52-
return no_intersection
52+
return intersection_normalized_complement
5353

5454
@staticmethod
55-
def _histogram_intersection(
55+
def _hi_normalized_complement(
5656
X: np.ndarray, # noqa: N803
5757
Y: np.ndarray,
5858
*,
@@ -68,6 +68,6 @@ def _histogram_intersection(
6868
X_hist = X_hist / X.shape[0] # noqa: N806
6969
Y_hist, _ = np.histogram(Y, bins=num_bins, range=hist_range) # noqa: N806
7070
Y_hist = Y_hist / Y.shape[0] # noqa: N806
71-
no_intersection = 1 - np.sum(np.minimum(X_hist, Y_hist))
71+
intersection_normalized_complement = 1 - np.sum(np.minimum(X_hist, Y_hist))
7272

73-
return no_intersection
73+
return intersection_normalized_complement

frouros/tests/integration/test_callback.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
CVMTest,
3636
EMD,
3737
HellingerDistance,
38-
HistogramIntersection,
38+
HINormalizedComplement,
3939
JS,
4040
KL,
4141
KSTest,
@@ -52,7 +52,7 @@
5252
(BhattacharyyaDistance, 0.55516059, 0.0),
5353
(EMD, 3.85346006, 0.0),
5454
(HellingerDistance, 0.74509099, 0.0),
55-
(HistogramIntersection, 0.78, 0.0),
55+
(HINormalizedComplement, 0.78, 0.0),
5656
(JS, 0.67010107, 0.0),
5757
(KL, np.inf, 0.0),
5858
(MMD, 0.71529206, 0.0),

frouros/tests/integration/test_data_drift.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
BhattacharyyaDistance,
1111
EMD,
1212
HellingerDistance,
13-
HistogramIntersection,
13+
HINormalizedComplement,
1414
PSI,
1515
JS,
1616
KL,
@@ -61,7 +61,7 @@ def test_batch_distance_based_categorical(
6161
(EMD(), 3.85346006),
6262
(JS(), 0.67010107),
6363
(KL(), np.inf),
64-
(HistogramIntersection(), 0.78),
64+
(HINormalizedComplement(), 0.78),
6565
],
6666
)
6767
def test_batch_distance_based_univariate(

images/detectors.png

5.79 KB
Loading

0 commit comments

Comments
 (0)