Skip to content

Commit

Permalink
Fixed docs for debias and renamed variables in tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Семенов Андрей Максимович committed Aug 5, 2024
1 parent 6130ab6 commit be6bcca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
13 changes: 5 additions & 8 deletions rectools/metrics/debias.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
@attr.s(frozen=True)
class DebiasConfig:
"""
Config with debias method parameters.
Config for debiasing method parameters.
Parameters
----------
iqr_coef : float, default 1.5
The interquartile range coefficient (IQR), which is needed to calculate the maximum boundary
(Q3 + iqr_coef * IQR) at which popular items will be removed from test interactions.
The interquartile range (IQR) coefficient required to calculate the maximum accepted popularity border
(Q3 + iqr_coef * IQR), which is necessary to down-sample every item to a value that does not exceed it.
random_state : int, optional, default None
Pseudorandom number generator state to control the down-sampling.
"""
Expand All @@ -46,10 +46,7 @@ class DebiasConfig:
@attr.s
class DebiasableMetrikAtK(MetricAtK):
"""
Debias metric base class.
Warning: This class should not be used directly.
Use derived classes instead.
Debiasing metric base class.
Warning: This class should not be used directly.
Use derived classes instead.
Expand Down Expand Up @@ -77,7 +74,7 @@ def _check_debias(self, is_debiased: bool, obj_name: str) -> None:

def debias_interactions(interactions: pd.DataFrame, config: DebiasConfig) -> pd.DataFrame:
"""
Downsample the size of interactions, excluding some interactions with popular items.
Down-sample the size of interactions, excluding some interactions with popular items.
Algorithm:
Expand Down
4 changes: 2 additions & 2 deletions tests/metrics/test_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ def test_calc(self, metric: ClassificationMetric) -> None:
debiased_metric = copy(metric)
debiased_metric.debias_config = DEBIAS_CONFIG

downsample_interactions = debias_interactions(INTERACTIONS, config=DEBIAS_CONFIG)
expected_metric_per_user = metric.calc_per_user(RECO, downsample_interactions, CATALOG)
debiased_interactions = debias_interactions(INTERACTIONS, config=DEBIAS_CONFIG)
expected_metric_per_user = metric.calc_per_user(RECO, debiased_interactions, CATALOG)

actual_metric_per_user = debiased_metric.calc_per_user(RECO, INTERACTIONS, CATALOG)
actual_metric = debiased_metric.calc(RECO, INTERACTIONS, CATALOG)
Expand Down

0 comments on commit be6bcca

Please sign in to comment.