Skip to content

Commit e58faff

Browse files
MTN - End support of some already deprecated functionalities (#693)
* MTN: remove deprecated ConformityScore (used for regression) * MTN: remove deprecated path conformity_scores.residual_conformity_scores * MTN: remove deprecated size_raps parameter from _MapieClassifier * MTN: remove import deprecation for get_true_label_position, that shouldn't be public anyway * DOC: update migration guide * MTN: remove deprecated path to import EnsembleRegressor, that is not public anyway * MTN: remove incorrect deprecation and clarify the issue in docstring
1 parent 70e7e8a commit e58faff

13 files changed

+36
-420
lines changed

doc/theoretical_description_conformity_scores.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Note: in theoretical parts of the documentation, we use the following terms empl
1313

1414
1515

16-
The :class:`mapie.conformity_scores.ConformityScore` class implements various
16+
The :class:`mapie.conformity_scores.BaseRegressionScore` class implements various
1717
methods to compute conformity scores for regression.
1818
We give here a brief theoretical description of the scores included in the module.
1919
Note that it is possible for the user to create any conformal scores that are not

doc/v1_migration_guide.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ Parameter specific to APS or RAPS conformity scores in classification.
170170
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
171171
Parameter specific to the RAPS conformity score in classification.
172172

173-
- **v0.x**: This parameter is passed to the ``fit`` method of ``MapieClassifier``.
173+
- **v0.x**: Passing this parameter to the ``fit`` method of ``MapieClassifier`` is deprecated.
174174
- **v1**: This parameter must now be passed to the ``conformity_score`` argument at initialization. Ex: ``SplitConformalClassifier(conformity_score=RAPSConformityScore(size_raps=0.3))``
175175

176176
None defaults
@@ -466,6 +466,17 @@ Now only one version exists (``regression_coverage_score``), that corresponds to
466466
- **v0.x**: Took ``alpha`` as input.
467467
- **v1**: Now takes ``confidence_level`` as input (``confidence_level`` is equivalent to ``1 - alpha``).
468468

469+
Conformity scores
470+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
471+
472+
The import of ``AbsoluteConformityScore``, ``GammaConformityScore`` and ``ResidualNormalisedScore`` from ``mapie.conformity_scores.residual_conformity_scores`` was deprecated and is now unsupported.
473+
474+
You can now import those scores from ``mapie.conformity_scores.bounds`` or simply ``mapie.conformity_scores``.
475+
476+
The usage of ``ConformityScore`` was deprecated and is now unsupported. The new class to use is ``BaseRegressionScore``, that can be found in ``mapie.conformity_scores.regression``.
477+
478+
We may clarify the ``conformity_scores`` package structure in the future.
479+
469480
Python, scikit-learn and NumPy versions support
470481
--------------------------------------------------------------------------
471482

mapie/classification.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from mapie.conformity_scores import BaseClassificationScore
2222
from mapie.conformity_scores.sets.raps import RAPSConformityScore
2323
from mapie.conformity_scores.utils import (
24-
check_depreciated_size_raps, check_classification_conformity_score,
24+
check_classification_conformity_score,
2525
check_target, check_and_select_conformity_score,
2626
)
2727
from mapie.estimator.classifier import EnsembleClassifier
@@ -816,7 +816,6 @@ def _check_fit_parameter(
816816
y: ArrayLike,
817817
sample_weight: Optional[ArrayLike] = None,
818818
groups: Optional[ArrayLike] = None,
819-
size_raps: Optional[float] = None,
820819
):
821820
"""
822821
Perform several checks on class parameters.
@@ -842,11 +841,9 @@ def _check_fit_parameter(
842841
y_enc = self.label_encoder_.transform(y)
843842

844843
cs_estimator = check_classification_conformity_score(self.conformity_score)
845-
check_depreciated_size_raps(size_raps)
846844
cs_estimator.set_external_attributes(
847845
classes=self.classes_,
848846
label_encoder=self.label_encoder_,
849-
size_raps=size_raps,
850847
random_state=self.random_state
851848
)
852849
if (
@@ -881,7 +878,6 @@ def fit(
881878
X: ArrayLike,
882879
y: ArrayLike,
883880
sample_weight: Optional[ArrayLike] = None,
884-
size_raps: Optional[float] = None,
885881
groups: Optional[ArrayLike] = None,
886882
**kwargs: Any
887883
) -> _MapieClassifier:
@@ -905,12 +901,6 @@ def fit(
905901
906902
By default ``None``.
907903
908-
size_raps: Optional[float]
909-
Percentage of the data to be used for choosing lambda_star and
910-
k_star for the RAPS method.
911-
912-
By default ``None``.
913-
914904
groups: Optional[ArrayLike] of shape (n_samples,)
915905
Group labels for the samples used while splitting the dataset into
916906
train/test set.
@@ -942,7 +932,7 @@ def fit(
942932
y_enc,
943933
sample_weight,
944934
groups) = self._check_fit_parameter(
945-
X, y, sample_weight, groups, size_raps
935+
X, y, sample_weight, groups
946936
)
947937

948938
# Cast

mapie/conformity_scores/conformity_scores.py

Lines changed: 0 additions & 165 deletions
This file was deleted.

mapie/conformity_scores/residual_conformity_scores.py

Lines changed: 0 additions & 34 deletions
This file was deleted.

mapie/conformity_scores/utils.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from typing import Optional, no_type_check
2-
import warnings
32

43
from sklearn.utils.multiclass import (
54
check_classification_targets,
@@ -97,29 +96,6 @@ def check_regression_conformity_score(
9796
)
9897

9998

100-
def check_depreciated_size_raps(
101-
size_raps: Optional[float]
102-
) -> None:
103-
"""
104-
Check if the parameter ``size_raps`` is used. If so, raise a warning.
105-
106-
Raises
107-
------
108-
Warning
109-
If ``size_raps`` is not ``None``.
110-
"""
111-
if not (size_raps is None):
112-
warnings.warn(
113-
"WARNING: Deprecated parameter. "
114-
"The parameter `size_raps` is deprecated. "
115-
"In the next release, `RAPSConformityScore` takes precedence over "
116-
"`_MapieClassifier` for setting the size used. "
117-
"Prefer to define `size_raps` in `RAPSConformityScore` rather "
118-
"than in the `fit` method of `_MapieClassifier`.",
119-
DeprecationWarning
120-
)
121-
122-
12399
def check_target(
124100
conformity_score: BaseClassificationScore,
125101
y: ArrayLike

mapie/conformity_scores/utils_classification_conformity_scores.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

mapie/estimator/estimator.py

Lines changed: 0 additions & 12 deletions
This file was deleted.

mapie/estimator/regressor.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from joblib import Parallel, delayed
77
from sklearn.base import RegressorMixin, clone
88
from sklearn.model_selection import BaseCrossValidator
9-
from sklearn.utils import _safe_indexing, deprecated
9+
from sklearn.utils import _safe_indexing
1010
from sklearn.utils.validation import _num_samples, check_is_fitted
1111

1212
from numpy.typing import ArrayLike, NDArray
@@ -405,11 +405,6 @@ def predict_calib(
405405

406406
return y_pred
407407

408-
@deprecated(
409-
"WARNING: EnsembleRegressor.fit is deprecated."
410-
"Instead use EnsembleRegressor.fit_single_estimator"
411-
"then EnsembleRegressor.fit_multi_estimators"
412-
)
413408
def fit(
414409
self,
415410
X: ArrayLike,
@@ -419,6 +414,11 @@ def fit(
419414
**fit_params
420415
) -> EnsembleRegressor:
421416
"""
417+
Note to developer: this fit method has been broken down into
418+
fit_single_estimator and fit_multi_estimators,
419+
but we kept it so that EnsembleRegressor passes sklearn.check_is_fitted.
420+
Prefer using fit_single_estimator and fit_multi_estimators.
421+
422422
Fit the base estimator under the ``single_estimator_`` attribute.
423423
Fit all cross-validated estimator clones
424424
and rearrange them into a list, the ``estimators_`` attribute.

0 commit comments

Comments
 (0)