Skip to content

Commit 5c9992f

Browse files
author
mata
committed
Brought changes in line with flake8 formatting
1 parent 12e7229 commit 5c9992f

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
@@ -178,7 +178,13 @@ class MapieClassifier(BaseEstimator, ClassifierMixin):
178178
[False False True]]
179179
"""
180180

181-
valid_methods_ = ["naive", "score", "cumulated_score", "top_k", "raps","mondrian"]
181+
valid_methods_ = ["naive",
182+
"score",
183+
"cumulated_score",
184+
"top_k",
185+
"raps",
186+
"mondrian"
187+
]
182188
fit_attributes = [
183189
"single_estimator_",
184190
"estimators_",
@@ -1241,7 +1247,7 @@ def predict(
12411247
check_alpha_and_n_samples(alpha_np, n)
12421248

12431249
if self.method == "naive":
1244-
self.quantiles_ = 1 - alpha_np
1250+
self.quantiles_ = 1 - alpha_np
12451251
else:
12461252
if (cv == "prefit") or (agg_scores in ["mean"]):
12471253
if self.method == "raps":
@@ -1278,15 +1284,15 @@ def predict(
12781284
self.quantiles_ = compute_quantiles(
12791285
self.conformity_scores_,
12801286
alpha_np,
1281-
mondrian = True
1287+
mondrian=True
12821288
)
12831289
else:
1284-
1290+
12851291
self.quantiles_ = compute_quantiles(
12861292
self.conformity_scores_,
12871293
alpha_np
12881294
)
1289-
1295+
12901296
else:
12911297
self.quantiles_ = (n + 1) * (1 - alpha_np)
12921298

@@ -1379,15 +1385,14 @@ def predict(
13791385
- y_pred_proba_last,
13801386
-EPSILON
13811387
)
1382-
elif self.method == "mondrian": #TODO:
1383-
self.quantiles_ = np.transpose(self.quantiles_,[1,0])
1388+
elif self.method == "mondrian":
1389+
self.quantiles_ = np.transpose(self.quantiles_, [1, 0])
13841390

13851391
prediction_sets = np.greater_equal(
1386-
y_pred_proba - (1 - self.quantiles_), -EPSILON
1392+
y_pred_proba - (1 - self.quantiles_),
1393+
-EPSILON
13871394
)
1388-
1389-
1390-
1395+
13911396
else:
13921397
raise ValueError(
13931398
"Invalid method. "

mapie/tests/test_classification.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from mapie._typing import ArrayLike, NDArray
2424

2525

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

269280
COVERAGES = {

0 commit comments

Comments
 (0)