Skip to content

Commit

Permalink
UPD: remove obsolete 'method' attribute and methods in conformity score
Browse files Browse the repository at this point in the history
  • Loading branch information
Thibault Cordier committed Jul 4, 2024
1 parent 7d053b7 commit 15b31ff
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 95 deletions.
1 change: 0 additions & 1 deletion mapie/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,6 @@ def _check_fit_parameter(
method=self.method
)
cs_estimator.set_external_attributes(
method=self.method,
classes=self.classes_,
random_state=self.random_state
)
Expand Down
8 changes: 0 additions & 8 deletions mapie/conformity_scores/sets/aps.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@ class APS(Naive):
Attributes
----------
method: str
Method to choose for prediction interval estimates.
This attribute is for compatibility with ``MapieClassifier``
which previously used a string instead of a score class.
Methods available in this class: ``aps``, ``raps`` and ``naive``.
By default, ``aps`` for APS method.
classes: Optional[ArrayLike]
Names of the classes.
Expand Down
15 changes: 0 additions & 15 deletions mapie/conformity_scores/sets/lac.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@ class LAC(BaseClassificationScore):
Attributes
----------
method: str
Method to choose for prediction interval estimates.
This attribute is for compatibility with ``MapieClassifier``
which previously used a string instead of a score class.
By default, ``lac`` for LAC method.
classes: Optional[ArrayLike]
Names of the classes.
Expand All @@ -49,7 +42,6 @@ def __init__(self) -> None:

def set_external_attributes(
self,
method: str = 'lac',
classes: Optional[ArrayLike] = None,
random_state: Optional[Union[int, np.random.RandomState]] = None,
**kwargs
Expand All @@ -59,12 +51,6 @@ def set_external_attributes(
Parameters
----------
method: str
Method to choose for prediction interval estimates.
Methods available in this class: ``lac``.
By default ``lac`` for LAC method.
classes: Optional[ArrayLike]
Names of the classes.
Expand All @@ -74,7 +60,6 @@ def set_external_attributes(
Pseudo random number generator state.
"""
super().set_external_attributes(**kwargs)
self.method = method
self.classes = classes
self.random_state = random_state

Expand Down
16 changes: 0 additions & 16 deletions mapie/conformity_scores/sets/naive.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@ class Naive(BaseClassificationScore):
Attributes
----------
method: str
Method to choose for prediction interval estimates.
This attribute is for compatibility with ``MapieClassifier``
which previously used a string instead of a score class.
Methods available in this class: ``aps``, ``raps`` and ``naive``.
By default, ``aps`` for APS method.
classes: Optional[ArrayLike]
Names of the classes.
Expand All @@ -43,7 +35,6 @@ def __init__(self) -> None:

def set_external_attributes(
self,
method: str = 'naive',
classes: Optional[ArrayLike] = None,
random_state: Optional[Union[int, np.random.RandomState]] = None,
**kwargs
Expand All @@ -53,12 +44,6 @@ def set_external_attributes(
Parameters
----------
method: str
Method to choose for prediction interval estimates.
Methods available in this class: ``aps``, ``raps`` and ``naive``.
By default ``aps`` for APS method.
classes: Optional[ArrayLike]
Names of the classes.
Expand All @@ -68,7 +53,6 @@ def set_external_attributes(
Pseudo random number generator state.
"""
super().set_external_attributes(**kwargs)
self.method = method
self.classes = classes
self.random_state = random_state

Expand Down
41 changes: 1 addition & 40 deletions mapie/conformity_scores/sets/raps.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from mapie.estimator.classifier import EnsembleClassifier

from mapie._machine_precision import EPSILON
from mapie._typing import ArrayLike, NDArray
from mapie._typing import NDArray
from mapie.metrics import classification_mean_width_score
from mapie.utils import check_alpha_and_n_samples, compute_quantiles

Expand Down Expand Up @@ -39,14 +39,6 @@ class RAPS(APS):
Attributes
----------
method: str
Method to choose for prediction interval estimates.
This attribute is for compatibility with ``MapieClassifier``
which previously used a string instead of a score class.
Methods available in this class: ``aps``, ``raps`` and ``naive``.
By default, ``aps`` for APS method.
classes: Optional[ArrayLike]
Names of the classes.
Expand All @@ -60,37 +52,6 @@ class RAPS(APS):
def __init__(self) -> None:
super().__init__()

def set_external_attributes(
self,
method: str = 'raps',
classes: Optional[ArrayLike] = None,
random_state: Optional[Union[int, np.random.RandomState]] = None,
**kwargs
) -> None:
"""
Set attributes that are not provided by the user.
Parameters
----------
method: str
Method to choose for prediction interval estimates.
Methods available in this class: ``aps``, ``raps`` and ``naive``.
By default ``aps`` for APS method.
classes: Optional[ArrayLike]
Names of the classes.
By default ``None``.
random_state: Optional[Union[int, RandomState]]
Pseudo random number generator state.
"""
super().set_external_attributes(**kwargs)
self.method = method
self.classes = classes
self.random_state = random_state

@staticmethod
def _regularize_conformity_score(
k_star: NDArray,
Expand Down
15 changes: 0 additions & 15 deletions mapie/conformity_scores/sets/topk.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,6 @@ class TopK(BaseClassificationScore):
Attributes
----------
method: str
Method to choose for prediction interval estimates.
This attribute is for compatibility with ``MapieClassifier``
which previously used a string instead of a score class.
By default, ``top_k`` for Top-K method.
classes: Optional[ArrayLike]
Names of the classes.
Expand All @@ -53,7 +46,6 @@ def __init__(self) -> None:

def set_external_attributes(
self,
method: str = 'top_k',
classes: Optional[int] = None,
random_state: Optional[Union[int, np.random.RandomState]] = None,
**kwargs
Expand All @@ -63,12 +55,6 @@ def set_external_attributes(
Parameters
----------
method: str
Method to choose for prediction interval estimates.
Methods available in this class: ``top_k``.
By default ``top_k`` for Top-K method.
classes: Optional[ArrayLike]
Names of the classes.
Expand All @@ -78,7 +64,6 @@ def set_external_attributes(
Pseudo random number generator state.
"""
super().set_external_attributes(**kwargs)
self.method = method
self.classes = classes
self.random_state = random_state

Expand Down

0 comments on commit 15b31ff

Please sign in to comment.