odtlearn.fair_oct
#
Module Contents#
Classes#
Helper class that provides a standard way to create an ABC using |
|
Helper class that provides a standard way to create an ABC using |
|
Helper class that provides a standard way to create an ABC using |
|
Helper class that provides a standard way to create an ABC using |
|
Helper class that provides a standard way to create an ABC using |
|
Helper class that provides a standard way to create an ABC using |
|
Helper class that provides a standard way to create an ABC using |
- class odtlearn.fair_oct.FairConstrainedOCT(solver, _lambda, depth, time_limit, num_threads, verbose)[source]#
Bases:
odtlearn.constrained_oct.ConstrainedOCT
Helper class that provides a standard way to create an ABC using inheritance.
- fit(X, y, protect_feat, legit_factor)[source]#
- Parameters:
- X{array-like, sparse matrix}, shape (n_samples, n_features)
The training input samples.
- yarray-like, shape (n_samples,)
The target values (class labels in classification).
- protect_featarray-like, shape (n_samples,1) or (n_samples, n_p)
The protected feature columns (Race, gender, etc); Can have one or more columns
- legit_factorarray-like, shape (n_samples,)
The legitimate factor column(e.g., prior number of criminal acts)
- Returns:
- selfobject
Returns self.
- class odtlearn.fair_oct.FairSPOCT(solver, positive_class, depth=1, time_limit=60, _lambda=0, obj_mode='acc', fairness_bound=1, num_threads=None, verbose=False)[source]#
Bases:
FairConstrainedOCT
Helper class that provides a standard way to create an ABC using inheritance.
- calc_metric(protect_feat, y)[source]#
This function returns the statistical parity value for any given protected level and outcome value
- Parameters:
protect_feat – array-like, shape (n_samples,1) or (n_samples, n_p) The protected feature columns (Race, gender, etc); We could have one or more columns
y – array-like, shape (n_samples,) The target values (class labels in classification).
- Return sp_dict:
a dictionary with key =(p,t) and value = P(Y=t|P=p)
where p is a protected level and t is an outcome value
- class odtlearn.fair_oct.FairCSPOCT(solver, positive_class, depth=1, time_limit=60, _lambda=0, obj_mode='acc', fairness_bound=1, num_threads=None, verbose=False)[source]#
Bases:
FairConstrainedOCT
Helper class that provides a standard way to create an ABC using inheritance.
- calc_metric(protect_feat, legit_factor, y)[source]#
Returns the conditional statistical parity value for any given protected level, legitimate feature value and outcome value
- Parameters:
protect_feat – array-like, shape (n_samples,1) or (n_samples, n_p) The protected feature columns (Race, gender, etc); We could have one or more columns
legit_fact – array-like, shape (n_samples,) The legitimate factor column(e.g., prior number of criminal acts)
y – array-like, shape (n_samples,) The target values (class labels in classification).
- Return csp_dict:
a dictionary with key =(p, f, t) and value = P(Y=t|P=p, L=f) where p is a protected level and t is an outcome value and l is the value of the legitimate feature
- class odtlearn.fair_oct.FairPEOCT(solver, positive_class, depth=1, time_limit=60, _lambda=0, obj_mode='acc', fairness_bound=1, num_threads=None, verbose=False)[source]#
Bases:
FairConstrainedOCT
Helper class that provides a standard way to create an ABC using inheritance.
- calc_metric(protect_feat, y, y_pred)[source]#
This function returns the false positive and true positive rate value for any given protected level, outcome value and prediction value
- Parameters:
protect_feat – array-like, shape (n_samples,1) or (n_samples, n_p) The protected feature columns (Race, gender, etc); We could have one or more columns
y – array-like, shape (n_samples,) The true target values (class labels in classification).
y_pred – array-like, shape (n_samples,) The predicted values (class labels in classification).
- Return eq_dict:
a dictionary with key =(p, t, t_pred) and value = P(Y_pred=t_pred|P=p, Y=t)
- class odtlearn.fair_oct.FairEOppOCT(solver, positive_class, depth=1, time_limit=60, _lambda=0, obj_mode='acc', fairness_bound=1, num_threads=None, verbose=False)[source]#
Bases:
FairConstrainedOCT
Helper class that provides a standard way to create an ABC using inheritance.
- class odtlearn.fair_oct.FairEOddsOCT(solver, positive_class, depth=1, time_limit=60, _lambda=0, obj_mode='acc', fairness_bound=1, num_threads=None, verbose=False)[source]#
Bases:
FairConstrainedOCT
Helper class that provides a standard way to create an ABC using inheritance.
- class odtlearn.fair_oct.FairOCT(solver, positive_class, _lambda=0, depth=1, obj_mode='acc', fairness_type=None, fairness_bound=1, time_limit=60, num_threads=None, verbose=False)[source]#
Bases:
odtlearn.flow_oct_ms.FlowOCTMultipleSink
Helper class that provides a standard way to create an ABC using inheritance.
- fit(X, y, protect_feat, legit_factor)[source]#
- Parameters:
- X{array-like, sparse matrix}, shape (n_samples, n_features)
The training input samples.
- yarray-like, shape (n_samples,)
The target values (class labels in classification).
- protect_featarray-like, shape (n_samples,1) or (n_samples, n_p)
The protected feature columns (Race, gender, etc); Can have one or more columns
- legit_factorarray-like, shape (n_samples,)
The legitimate factor column(e.g., prior number of criminal acts)
- Returns
- ——-
- selfobject
Returns self.
- predict(X)[source]#
Classify test points using the FairTree classifier Parameters ———- X : array-like, shape (n_samples, n_features)
The input samples.
Returns#
- yndarray, shape (n_samples,)
The label for each sample is the label of the closest sample seen during fit.
- get_SP(protect_feat, y)[source]#
This function returns the statistical parity value for any given protected level and outcome value
- Parameters:
protect_feat – array-like, shape (n_samples,1) or (n_samples, n_p) The protected feature columns (Race, gender, etc); We could have one or more columns
y – array-like, shape (n_samples,) The target values (class labels in classification).
- Return sp_dict:
a dictionary with key =(p,t) and value = P(Y=t|P=p)
where p is a protected level and t is an outcome value
- get_CSP(protect_feat, legit_factor, y)[source]#
This function returns the conditional statistical parity value for any given protected level, legitimate feature value and outcome value
- Parameters:
protect_feat – array-like, shape (n_samples,1) or (n_samples, n_p) The protected feature columns (Race, gender, etc); We could have one or more columns
legit_fact – array-like, shape (n_samples,) The legitimate factor column(e.g., prior number of criminal acts)
y – array-like, shape (n_samples,) The target values (class labels in classification).
- Return csp_dict:
a dictionary with key =(p, f, t) and value = P(Y=t|P=p, L=f) where p is a protected level and t is an outcome value and l is the value of the legitimate feature
- get_EqOdds(protect_feat, y, y_pred)[source]#
This function returns the false positive and true positive rate value for any given protected level, outcome value and prediction value
- Parameters:
protect_feat – array-like, shape (n_samples,1) or (n_samples, n_p) The protected feature columns (Race, gender, etc); We could have one or more columns
y – array-like, shape (n_samples,) The true target values (class labels in classification).
y_pred – array-like, shape (n_samples,) The predicted values (class labels in classification).
- Return eq_dict:
a dictionary with key =(p, t, t_pred) and value = P(Y_pred=t_pred|P=p, Y=t)
- get_CondEqOdds(protect_feat, legit_factor, y, y_pred)[source]#
This function returns the conditional false negative and true positive rate value for any given protected level, outcome value, prediction value and legitimate feature value
- Parameters:
protect_feat – array-like, shape (n_samples,1) or (n_samples, n_p) The protected feature columns (Race, gender, etc); We could have one or more columns
legit_factor – array-like, shape (n_samples,) The legitimate factor column(e.g., prior number of criminal acts)
y – array-like, shape (n_samples,) The true target values (class labels in classification).
y_pred – array-like, shape (n_samples,) The predicted values (class labels in classification).
- Return ceq_dict:
a dictionary with key =(p, f, t, t_pred) and value = P(Y_pred=t_pred|P=p, Y=t, L=f)