Skip to content

Commit

Permalink
WIP Mehestan
Browse files Browse the repository at this point in the history
  • Loading branch information
lenhoanglnh committed Jan 3, 2025
1 parent 2353f90 commit 170d95d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 28 deletions.
2 changes: 0 additions & 2 deletions solidago/src/solidago/pipeline/scaling/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
"""

from .base import Scaling
from .compose import ScalingCompose
from .no_scaling import NoScaling
from .mehestan import Mehestan
from .quantile_zero_shift import QuantileShift, QuantileZeroShift
from .standardize import Standardize
46 changes: 20 additions & 26 deletions solidago/src/solidago/pipeline/scaling/mehestan.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,17 @@

import numpy as np
import pandas as pd

import logging
import timeit
import logging

from .base import Scaling
from .no_scaling import NoScaling
logger = logging.getLogger(__name__)

from solidago.privacy_settings import PrivacySettings
from solidago.scoring_model import ScoringModel, ScaledScoringModel
from solidago.voting_rights import VotingRights
from solidago.primitives import qr_median, qr_uncertainty, lipschitz_resilient_mean
from solidago.primitives.pairs import UnorderedPairs
from solidago.state import *

from solidago.utils.pairs import UnorderedPairs


logger = logging.getLogger(__name__)
from .base import Scaling
from .no_scaling import NoScaling


class Mehestan(Scaling):
Expand All @@ -32,14 +27,16 @@ def __init__(
n_diffs_sample_max=1000,
error=1e-5
):
""" Mehestan performs Lipschitz-resilient ollaborative scaling.
A simplified version of Mehestan was published in
"Robust Sparse Voting", Youssef Allouah, Rachid Guerraoui, Lȩ Nguyên Hoang
and Oscar Villemaud, published at AISTATS 2024.
""" Mehestan performs Lipschitz-resilient collaborative scaling.
It is based on "Robust Sparse Voting", by Youssef Allouah,
Rachid Guerraoui, Lȩ Nguyên Hoang and Oscar Villemaud,
published at AISTATS 2024.
The inclusion of uncertainties is further detailed in
"Solidago: A Modular Pipeline for Collaborative Scoring"
"Solidago: A Modular Pipeline for Collaborative Scoring",
by Lê Nguyên Hoang, Romain Beylerian, Bérangère Colbois, Julien Fageot,
Louis Faucon, Aidan Jungo, Alain Le Noac'h, Adrien Matissart
and Oscar Villemaud.
Parameters
----------
Expand Down Expand Up @@ -69,14 +66,11 @@ def __init__(
self.n_diffs_sample_max = n_diffs_sample_max
self.error = error

def __call__(
self,
user_models: Mapping[int, ScoringModel],
users: pd.DataFrame,
entities: pd.DataFrame,
voting_rights: Optional[VotingRights] = None,
privacy: Optional[PrivacySettings] = None
) -> dict[int, ScaledScoringModel]:
def __call__(self,
users: Users,
entities: Entities,
user_models: UserModels,
) -> UserModels:
""" Returns scaled user models
Parameters
Expand Down Expand Up @@ -107,7 +101,7 @@ def __call__(
nonscalers = users[users["is_scaler"] == False]
if len(scalers) == 0:
logger.warning(" No user qualifies as a scaler. No scaling performed.")
return NoScaling()(user_models)
return user_models
end_step1 = timeit.default_timer()
logger.info(f"Mehestan 1. Terminated in {int(end_step1 - start)} seconds")

Expand Down

0 comments on commit 170d95d

Please sign in to comment.