<p>Fairlearn maintainer here. The answer is yes, you can use <code>fairlearn.reductions.Moment</code>, or more precisely <code>fairlearn.reductions.ClassificationMoment</code>, to implement any constraints of the form described in the paper &quot;<a href="https://arxiv.org/pdf/1803.02453.pdf" rel="nofollow noreferrer">A Reductions Approach to Fair Classification</a>&quot;. Apologies for the mistake in the documentation. We should replace &quot;parity constraints&quot; by &quot;constraints&quot;.</p>
<p>If you want to implement this kind of constraint or something more generic along the lines you describe, please open a GitHub issue, and we can help you along! Currently the internal API around creation of new Moment classes is not very well documented.</p>
Can you use fairlearn for non-parity constraints? (binned monotonicity)
<p>I'd like to use fairlearn to encode a binned monotonicity constraint on a binned continuous feature, e.g. income. That is, for input x, model h, and income groups {G_1...G_k}, I'd like to enforce:</p>
<p>E[h(x) | x \in G_i] &lt;=  E[h(x) | x \in G_i+1] for i from 0 to k-1.</p>
<p>This constraint fits into the form required in the Fair Reductions paper, where we have our vector mu, which is</p>
<p>mu_j=E[h(x)|x \in G_j] for all j,</p>
<p>and our matrix M which has M_i,i=1 and M_i,(i+1)=-1, and zeros elsewhere.</p>
<p>I was about to try to make an implementation of the Moment class to make a moment for this binned monotonicity constraint, but the documentation for other parts of the code has me worried that fairlearn is only implemented for parity constraints in particular.</p>
<p>For example, in the documentation the _Lagrangian class fairlearn, in fairlearn/fairlearn/reductions/_exponentiated_gradient/_lagrangian.py, it says:</p>
<p>&quot;constraints : fairlearn.reductions.Moment
Object describing the <strong>parity</strong> constraints. This provides the reweighting
and relabelling.&quot;</p>
<p>Does this mean that even if find a way to write a moment class for binned monotonicity, I may still run into problems from the rest of the code being geared towards parity constraints only?</p>
<p>Additionally, is there any hope (or existing implementation?) of getting a general implementation of fairlearn where you input mu and M, as opposed to a pre-determined constraint?</p>