Skip to content

Commit 53ec51d

Browse files
author
mata
committed
Brought changes in line with flake8 formatting
1 parent 917c06b commit 53ec51d

File tree

3 files changed

+29
-13
lines changed

3 files changed

+29
-13
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.PHONY: tests doc build
22

33
lint:
4-
flake8 . --exclude=doc
4+
flake8 . --exclude=doc mapieenv
55

66
type-check:
77
mypy mapie

mapie/classification.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,13 @@ class MapieClassifier(BaseEstimator, ClassifierMixin):
167167
[False False True]]
168168
"""
169169

170-
valid_methods_ = ["naive", "score", "cumulated_score", "top_k", "raps","mondrian"]
170+
valid_methods_ = ["naive",
171+
"score",
172+
"cumulated_score",
173+
"top_k",
174+
"raps",
175+
"mondrian"
176+
]
171177
fit_attributes = [
172178
"single_estimator_",
173179
"estimators_",
@@ -1230,7 +1236,7 @@ def predict(
12301236
check_alpha_and_n_samples(alpha_np, n)
12311237

12321238
if self.method == "naive":
1233-
self.quantiles_ = 1 - alpha_np
1239+
self.quantiles_ = 1 - alpha_np
12341240
else:
12351241
if (cv == "prefit") or (agg_scores in ["mean"]):
12361242
if self.method == "raps":
@@ -1267,15 +1273,15 @@ def predict(
12671273
self.quantiles_ = compute_quantiles(
12681274
self.conformity_scores_,
12691275
alpha_np,
1270-
mondrian = True
1276+
mondrian=True
12711277
)
12721278
else:
1273-
1279+
12741280
self.quantiles_ = compute_quantiles(
12751281
self.conformity_scores_,
12761282
alpha_np
12771283
)
1278-
1284+
12791285
else:
12801286
self.quantiles_ = (n + 1) * (1 - alpha_np)
12811287

@@ -1368,15 +1374,14 @@ def predict(
13681374
- y_pred_proba_last,
13691375
-EPSILON
13701376
)
1371-
elif self.method == "mondrian": #TODO:
1372-
self.quantiles_ = np.transpose(self.quantiles_,[1,0])
1377+
elif self.method == "mondrian":
1378+
self.quantiles_ = np.transpose(self.quantiles_, [1, 0])
13731379

13741380
prediction_sets = np.greater_equal(
1375-
y_pred_proba - (1 - self.quantiles_), -EPSILON
1381+
y_pred_proba - (1 - self.quantiles_),
1382+
-EPSILON
13761383
)
1377-
1378-
1379-
1384+
13801385
else:
13811386
raise ValueError(
13821387
"Invalid method. "

mapie/tests/test_classification.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from mapie.metrics import classification_coverage_score
2323
from mapie.utils import check_alpha
2424

25-
METHODS = ["score", "cumulated_score", "raps"]
25+
METHODS = ["score", "cumulated_score", "raps","mondrian"]
2626
WRONG_METHODS = ["scores", "cumulated", "test", "", 1, 2.5, (1, 2)]
2727
WRONG_INCLUDE_LABELS = ["randomised", "True", "False", "other", 1, 2.5, (1, 2)]
2828
Y_PRED_PROBA_WRONG = [
@@ -263,6 +263,17 @@
263263
agg_scores="mean"
264264
)
265265
),
266+
"mondrian": (
267+
Params(
268+
method="mondrian",
269+
cv="prefit",
270+
random_state=None
271+
),
272+
ParamsPredict(
273+
include_last_label="randomized",
274+
agg_scores="mean"
275+
)
276+
),
266277
}
267278

268279
COVERAGES = {

0 commit comments

Comments
 (0)