doubleml.utils.GlobalClassifier#

class doubleml.utils.GlobalClassifier(base_estimator)#

A global classifier that ignores the attribute sample_weight when being fit to ensure a global fit.

Parameters:
  • base_estimator (classifier implementing fit() and predict_proba())

  • fit() (Classifier that is used when)

  • called. (predict() and predict_proba() are being)

Methods

fit(X, y[, sample_weight])

Fits the classifier provided in base_estimator.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

predict(X)

Predicts using the classifier provided in base_estimator.

predict_proba(X)

Probability estimates using the classifier provided in base_estimator.

score(X, y[, sample_weight])

Return the mean accuracy on the given test data and labels.

set_fit_request(*[, sample_weight])

Request metadata passed to the fit method.

set_params(**params)

Set the parameters of this estimator.

set_score_request(*[, sample_weight])

Request metadata passed to the score method.

GlobalClassifier.fit(X, y, sample_weight=None)#

Fits the classifier provided in base_estimator. Ignores sample_weight.

Parameters:
  • X (array-like of shape (n_samples, n_features))

  • data. (Training)

  • y (array-like of shape (n_samples,) or (n_samples, n_targets))

  • classes. (Target)

  • sample_weight (array-like of shape (n_samples,).)

  • Ignored. (Individual weights for each sample.)

GlobalClassifier.get_metadata_routing()#

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Returns:

routing – A MetadataRequest encapsulating routing information.

Return type:

MetadataRequest

GlobalClassifier.get_params(deep=True)#

Get parameters for this estimator.

Parameters:

deep (bool, default=True) – If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns:

params – Parameter names mapped to their values.

Return type:

dict

GlobalClassifier.predict(X)#

Predicts using the classifier provided in base_estimator.

Parameters:
  • X (array-like of shape (n_samples, n_features))

  • Samples.

GlobalClassifier.predict_proba(X)#

Probability estimates using the classifier provided in base_estimator. The returned estimates for all classes are ordered by the label of classes.

Parameters:
  • X (array-like of shape (n_samples, n_features))

  • scored. (Samples to be)

GlobalClassifier.score(X, y, sample_weight=None)#

Return the mean accuracy on the given test data and labels.

In multi-label classification, this is the subset accuracy which is a harsh metric since you require for each sample that each label set be correctly predicted.

Parameters:
  • X (array-like of shape (n_samples, n_features)) – Test samples.

  • y (array-like of shape (n_samples,) or (n_samples, n_outputs)) – True labels for X.

  • sample_weight (array-like of shape (n_samples,), default=None) – Sample weights.

Returns:

score – Mean accuracy of self.predict(X) w.r.t. y.

Return type:

float

GlobalClassifier.set_fit_request(*, sample_weight: bool | None | str = '$UNCHANGED$') GlobalClassifier#

Request metadata passed to the fit method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to fit if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to fit.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters:

sample_weight (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for sample_weight parameter in fit.

Returns:

self – The updated object.

Return type:

object

GlobalClassifier.set_params(**params)#

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters:

**params (dict) – Estimator parameters.

Returns:

self – Estimator instance.

Return type:

estimator instance

GlobalClassifier.set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') GlobalClassifier#

Request metadata passed to the score method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to score if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to score.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters:

sample_weight (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for sample_weight parameter in score.

Returns:

self – The updated object.

Return type:

object