// Make another component representing the vectors that should not be
// de-biased: the original space times (1 - applicability).
result = frame.mul(1 - applicability, axis=0)
// The sum of these two components is the de-biased space, where de-biasing
// applies to each row proportional to its applicability.
np.add(result.values, modified_component.values, out=result.values)
del modified_component
// L_2-normalize the resulting rows in-place.
normalize(result.values, norm="l2", copy=False)
return result
def de_bias_category(frame, category_examples, bias_examples):
After Change
// Make another component representing the vectors that should not be
// de-biased: the original space times (1 - applicability).
np.multiply(1 - applicability.reshape((len(frame), 1)), frame.values,
out=frame.values)
// The sum of these two components is the de-biased space, where de-biasing