fairlib.src.networks.INLP
fairlib.src.networks.INLP.__init__
fairlib.src.networks.INLP.classifier
fairlib.src.networks.INLP.debias
- fairlib.src.networks.INLP.debias.debias_by_specific_directions(directions: List[numpy.ndarray], input_dim: int)
the goal of this function is to perform INLP on a set of user-provided directiosn (instead of learning those directions). :param directions: list of vectors, as numpy arrays. :param input_dim: dimensionality of the vectors.
- fairlib.src.networks.INLP.debias.get_debiasing_projection(classifier_class, cls_params: Dict, num_classifiers: int, input_dim: int, is_autoregressive: bool, min_accuracy: float, X_train: numpy.ndarray, Y_train: numpy.ndarray, X_dev: numpy.ndarray, Y_dev: numpy.ndarray, by_class=True, Y_train_main=None, Y_dev_main=None, dropout_rate=0, importance_identifier=[]) numpy.ndarray
- Parameters
classifier_class – the sklearn classifier class (SVM/Perceptron etc.)
cls_params – a dictionary, containing the params for the sklearn classifier
num_classifiers – number of iterations (equivalent to number of dimensions to remove)
input_dim – size of input vectors
is_autoregressive – whether to train the ith classiifer on the data projected to the nullsapces of w1,…,wi-1
min_accuracy – above this threshold, ignore the learned classifier
X_train – ndarray, training vectors
Y_train – ndarray, training labels (protected attributes)
X_dev – ndarray, eval vectors
Y_dev – ndarray, eval labels (protected attributes)
by_class – if true, at each iteration sample one main-task label, and extract the protected attribute only from vectors from this class
T_train_main – ndarray, main-task train labels
Y_dev_main – ndarray, main-task eval labels
dropout_rate – float, default: 0 (note: not recommended to be used with autoregressive=True)
- Returns
P, the debiasing projection; rowspace_projections, the list of all rowspace projection; Ws, the list of all calssifiers.
- fairlib.src.networks.INLP.debias.get_projection_to_intersection_of_nullspaces(rowspace_projection_matrices: List[numpy.ndarray], input_dim: int)
Given a list of rowspace projection matrices P_R(w_1), …, P_R(w_n), this function calculates the projection to the intersection of all nullspasces of the matrices w_1, …, w_n. uses the intersection-projection formula of Ben-Israel 2013 http://benisrael.net/BEN-ISRAEL-NOV-30-13.pdf: N(w1)∩ N(w2) ∩ … ∩ N(wn) = N(P_R(w1) + P_R(w2) + … + P_R(wn)) :param rowspace_projection_matrices: List[np.array], a list of rowspace projections :param dim: input dim
- fairlib.src.networks.INLP.debias.get_rowspace_projection(W: numpy.ndarray) numpy.ndarray
- Parameters
W – the matrix over its nullspace to project
- Returns
the projection matrix over the rowspace