Visitar URL original
DOC document gamma, bound, project_lambda, and signed_weights on Moment by SpiliosDimakopoulos · Pull Request #1751 · fairlearn/fairlearn · GitHub
Skip to content

DOC document gamma, bound, project_lambda, and signed_weights on Moment - #1751

Open
SpiliosDimakopoulos wants to merge 2 commits into
fairlearn:mainfrom
SpiliosDimakopoulos:doc/232-moment-method-docstrings
Open

SpiliosDimakopoulos wants to merge 2 commits into
fairlearn:mainfrom
SpiliosDimakopoulos:doc/232-moment-method-docstrings

Conversation

@SpiliosDimakopoulos

Copy link
Copy Markdown
Contributor

Refs #232.

The base Moment methods gamma, bound, project_lambda, and signed_weights only had one-line docstrings. I added Parameters and Returns sections describing what each method takes and returns, based on how ExponentiatedGradient uses them (the Lagrangian is error + sum(lambda * (gamma - bound)), and the sign of the summed signed weights picks the label for the cost-sensitive learning step).

No behavior change. Added a line to the v0.15.0 changelog.

The base class methods only had one-line docstrings without Parameters or
Returns sections. Describe what each method takes and returns, based on how
ExponentiatedGradient and GridSearch use them (fixes fairlearn#232).
Comment on lines +110 to +111
pandas.Series
Lagrange multipliers that are equivalent to `lambda_vec` for the

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Describe the non-decreasing Lagrangian guarantee

Could we say that the projected multipliers produce the same or a higher Lagrangian value, rather than an equivalent one? For example, with default DemographicParity() and two groups, projecting pd.Series(1.0, index=moment.index) returns all zeros. The constraint term changes from -0.04 to 0.0 because bound() is 0.01, even though the inner product with gamma is unchanged. This is expected behavior and matches the existing UtilityParity.project_lambda docstring. The equality implied here gives custom Moment implementations the wrong contract.

Comment on lines +129 to +132
One weight per sample. The reductions algorithms add the weights of the
objective and the constraints, use the sign of the sum to choose the label
for a cost-sensitive learning problem, and the absolute value as the
sample weight when calling the underlying estimator.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Distinguish regression weights from classification relabelling

Could we limit the relabelling description to ClassificationMoment and describe regression separately? For example, GridSearch with BoundedGroupLoss(SquareLoss(...)) keeps the original continuous y and uses these weights to reweight the samples. It does not choose new 0/1 labels from their signs. That path also skips adding objective weights when the objective is already in the constraint span. Since Moment is the base class for both classification and regression, the current description gives users implementing a regression moment the wrong picture.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants