aif360.sklearn.preprocessing.ReweighingMeta¶
-
class
aif360.sklearn.preprocessing.ReweighingMeta(estimator, reweigher=Reweighing())[source]¶ A meta-estimator which wraps a given estimator with a reweighing preprocessing step.
This is necessary for use in a Pipeline, etc.
Variables: - estimator (sklearn.BaseEstimator) – The fitted underlying estimator.
- reweigher – The fitted underlying reweigher.
Parameters: - estimator (sklearn.BaseEstimator) – Estimator to be wrapped.
- reweigher – Preprocessor which returns new sample weights from
transform().
Methods
fitPerforms self.reweigher_.fit_transform(X, y, sample_weight)and thenself.estimator_.fit(X, y, sample_weight)using the reweighed samples.get_paramsGet parameters for this estimator. predictPredict class labels for the given samples using self.estimator_.predict_log_probaLog of probability estimates from self.estimator_.predict_probaProbability estimates from self.estimator_.scoreReturns the output of the estimator’s score function on the given test data and labels. set_paramsSet the parameters of this estimator. -
__init__(estimator, reweigher=Reweighing())[source]¶ Parameters: - estimator (sklearn.BaseEstimator) – Estimator to be wrapped.
- reweigher – Preprocessor which returns new sample weights from
transform().
-
fit(X, y, sample_weight=None)[source]¶ Performs
self.reweigher_.fit_transform(X, y, sample_weight)and thenself.estimator_.fit(X, y, sample_weight)using the reweighed samples.Parameters: - X (pandas.DataFrame) – Training samples.
- y (array-like) – Training labels.
- sample_weight (array-like, optional) – Sample weights.
Returns: self
-
predict(X)[source]¶ Predict class labels for the given samples using
self.estimator_.Parameters: X (array-like) – Test samples. Returns: array – Predicted class label per sample.
-
predict_log_proba(X)[source]¶ Log of probability estimates from
self.estimator_.The returned estimates for all classes are ordered by the label of classes.
Parameters: X (array-like) – Test samples. Returns: array – Returns the log-probability of the sample for each class in the model, where classes are ordered as they are in self.classes_.
-
predict_proba(X)[source]¶ Probability estimates from
self.estimator_.The returned estimates for all classes are ordered by the label of classes.
Parameters: X (array-like) – Test samples. Returns: array – Returns the probability of the sample for each class in the model, where classes are ordered as they are in self.classes_.
-
score(X, y, sample_weight=None)[source]¶ Returns the output of the estimator’s score function on the given test data and labels.
Parameters: - X (array-like) – Test samples.
- y (array-like) – True labels for X.
- sample_weight (array-like, optional) – Sample weights.
Returns: float –
self.estimator.score(X, y, sample_weight)