khalib 0.3__tar.gz → 0.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {khalib-0.3 → khalib-0.4}/PKG-INFO +1 -1
- {khalib-0.3 → khalib-0.4}/pyproject.toml +1 -1
- {khalib-0.3 → khalib-0.4}/src/khalib/main.py +48 -28
- {khalib-0.3 → khalib-0.4}/src/khalib.egg-info/PKG-INFO +1 -1
- {khalib-0.3 → khalib-0.4}/LICENSE.md +0 -0
- {khalib-0.3 → khalib-0.4}/README.md +0 -0
- {khalib-0.3 → khalib-0.4}/setup.cfg +0 -0
- {khalib-0.3 → khalib-0.4}/src/khalib/__init__.py +0 -0
- {khalib-0.3 → khalib-0.4}/src/khalib.egg-info/SOURCES.txt +0 -0
- {khalib-0.3 → khalib-0.4}/src/khalib.egg-info/dependency_links.txt +0 -0
- {khalib-0.3 → khalib-0.4}/src/khalib.egg-info/requires.txt +0 -0
- {khalib-0.3 → khalib-0.4}/src/khalib.egg-info/top_level.txt +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "khalib"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.4"
|
|
8
8
|
description = "Classifier Calibration with Khiops"
|
|
9
9
|
authors = [{ name = "Felipe Olmos", email = "luisfelipe.olmosmarchant@orange.com" }]
|
|
10
10
|
requires-python = ">=3.11"
|
|
@@ -233,9 +233,6 @@ class Histogram:
|
|
|
233
233
|
do_data_preparation_only=True,
|
|
234
234
|
)
|
|
235
235
|
results = kh.read_analysis_results_file(f"{work_dir}/report.khj")
|
|
236
|
-
# import shutil
|
|
237
|
-
|
|
238
|
-
# shutil.copy(f"{work_dir}/report.khj", "tmp.khj")
|
|
239
236
|
|
|
240
237
|
# Initialize the histogram
|
|
241
238
|
if y is not None:
|
|
@@ -287,10 +284,13 @@ class Histogram:
|
|
|
287
284
|
else:
|
|
288
285
|
if use_finest:
|
|
289
286
|
histogram_index = -1
|
|
290
|
-
|
|
287
|
+
elif 100 in score_stats.modl_histograms.information_rates:
|
|
291
288
|
histogram_index = (
|
|
292
289
|
score_stats.modl_histograms.information_rates.index(100)
|
|
293
290
|
)
|
|
291
|
+
else:
|
|
292
|
+
assert len(score_stats.modl_histograms.information_rates) == 1
|
|
293
|
+
histogram_index = 0
|
|
294
294
|
breakpoints = score_stats.modl_histograms.histograms[
|
|
295
295
|
histogram_index
|
|
296
296
|
].bounds
|
|
@@ -954,31 +954,11 @@ def build_reliability_diagram(
|
|
|
954
954
|
fig.subplots_adjust(hspace=0)
|
|
955
955
|
fig.suptitle("Reliability Diagram")
|
|
956
956
|
|
|
957
|
-
# Build a unsupervised histogram
|
|
957
|
+
# Build a unsupervised histogram
|
|
958
958
|
uhist_y_scores = Histogram.from_data(y_scores, use_finest=True)
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
):
|
|
963
|
-
dirac_indexes.append(True)
|
|
964
|
-
else:
|
|
965
|
-
dirac_indexes.append(False)
|
|
966
|
-
for i in range(1, uhist_y_scores.n_bins - 1):
|
|
967
|
-
cur_left, cur_right = uhist_y_scores.bins[i]
|
|
968
|
-
if (
|
|
969
|
-
uhist_y_scores.freqs[i - 1] == 0
|
|
970
|
-
and uhist_y_scores.freqs[i + 1] == 0
|
|
971
|
-
and (cur_right - cur_left < dirac_threshold)
|
|
972
|
-
):
|
|
973
|
-
dirac_indexes.append(True)
|
|
974
|
-
else:
|
|
975
|
-
dirac_indexes.append(False)
|
|
976
|
-
if uhist_y_scores.freqs[-2] == 0 and (
|
|
977
|
-
uhist_y_scores.bins[-1][1] - uhist_y_scores.bins[-1][0] < dirac_threshold
|
|
978
|
-
):
|
|
979
|
-
dirac_indexes.append(True)
|
|
980
|
-
else:
|
|
981
|
-
dirac_indexes.append(False)
|
|
959
|
+
|
|
960
|
+
# Compute the dirac mass indexes
|
|
961
|
+
dirac_indexes = compute_dirac_indexes(uhist_y_scores, dirac_threshold)
|
|
982
962
|
|
|
983
963
|
# Compute the supervised score histogram
|
|
984
964
|
hist_y_scores = Histogram.from_data(y_scores, y)
|
|
@@ -1091,3 +1071,43 @@ def build_reliability_diagram(
|
|
|
1091
1071
|
)
|
|
1092
1072
|
|
|
1093
1073
|
return fig, axs
|
|
1074
|
+
|
|
1075
|
+
|
|
1076
|
+
def compute_dirac_indexes(uhist, dirac_threshold):
|
|
1077
|
+
"""Computes the dirac mass indexes of a histogram
|
|
1078
|
+
|
|
1079
|
+
We declare a dirac mass bin if:
|
|
1080
|
+
|
|
1081
|
+
- it is surrounded by empty bins.
|
|
1082
|
+
- its length is less than ``dirac_threshold``
|
|
1083
|
+
|
|
1084
|
+
"""
|
|
1085
|
+
dirac_indexes = []
|
|
1086
|
+
if (
|
|
1087
|
+
len(uhist.freqs) > 1
|
|
1088
|
+
and uhist.freqs[1] == 0
|
|
1089
|
+
and (uhist.bins[0][1] - uhist.bins[0][0] < dirac_threshold)
|
|
1090
|
+
):
|
|
1091
|
+
dirac_indexes.append(True)
|
|
1092
|
+
else:
|
|
1093
|
+
dirac_indexes.append(False)
|
|
1094
|
+
for i in range(1, uhist.n_bins - 1):
|
|
1095
|
+
cur_left, cur_right = uhist.bins[i]
|
|
1096
|
+
if (
|
|
1097
|
+
uhist.freqs[i - 1] == 0
|
|
1098
|
+
and uhist.freqs[i + 1] == 0
|
|
1099
|
+
and (cur_right - cur_left < dirac_threshold)
|
|
1100
|
+
):
|
|
1101
|
+
dirac_indexes.append(True)
|
|
1102
|
+
else:
|
|
1103
|
+
dirac_indexes.append(False)
|
|
1104
|
+
if (
|
|
1105
|
+
len(uhist.freqs) > 2
|
|
1106
|
+
and uhist.freqs[-2] == 0
|
|
1107
|
+
and (uhist.bins[-1][1] - uhist.bins[-1][0] < dirac_threshold)
|
|
1108
|
+
):
|
|
1109
|
+
dirac_indexes.append(True)
|
|
1110
|
+
else:
|
|
1111
|
+
dirac_indexes.append(False)
|
|
1112
|
+
|
|
1113
|
+
return dirac_indexes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|