CapyMOAClassifier#

class skactiveml.classifier.CapyMOAClassifier(estimator_class, estimator_param_dict=None, classes=None, missing_label=nan, cost_matrix=None, random_state=None)[source]#

Bases: SkactivemlClassifier

CapyMOA Classifier

Implementation of a wrapper class for CapyMOA [1] classifiers such that missing labels can be handled and the interfaces are compatible with scikit-activeml. Therefore, samples with missing labels are filtered.

Parameters:
estimator_classcapymoa.base.MOAClassifier.__class__

The capymoa classifier class that is used to initialize the capymoa classifier.

estimator_param_dictdict, default=None

Additional arguments for capymoa.base.MOAClassifier. If estimator_param_dict is None, no additional arguments are added. schema is not allowed in this dictionary and will be created internally.

classesarray-like of shape (n_classes,), default=None

Holds the label for each class. If None, the classes are determined during fit.

missing_labelscalar or string or np.nan or None, default=np.nan

Value to represent a missing label.

cost_matrixarray-like of shape (n_classes, n_classes)

Cost matrix with cost_matrix[i,j] indicating cost of predicting class classes[j] for a sample of class classes[i]. Can be only set, if classes is not None.

random_stateint or RandomState instance or None, default=None

Determines random number for predict method. Pass an int for reproducible results across multiple method calls.

Attributes:
classes_numpy.ndarray of shape (n_classes,)

Holds the label for each class after fitting.

cost_matrix_numpy.ndarray of shape (classes, classes)

Cost matrix with cost_matrix_[i,j] indicating cost of predicting class classes_[j] for a sample of class classes_[i].

estimator_capymoa.base.MOAClassifier

initialized MOAClassifier whose predictions and training are wrapped.

References

[1]

Gomes, H.M., Lee, A., Gunasekara, N., Sun, Y., Cassales, G.W., Liu, J., Heyden, M., Cerqueira, V., Bahri, M., Koh, Y.S. and Pfahringer, B., 2025. Capymoa: Efficient machine learning for data streams in python. arXiv preprint arXiv:2502.07432.

Methods

fit(X, y)

Fit the module with (re-)initialization using X as training data and y as class labels.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

partial_fit(X, y)

Fit the module without re-initialization.

predict(X, **kwargs)

Return class label predictions for the test samples X.

predict_proba(X)

Return probability estimates for the input data X.

score(X, y[, sample_weight])

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

set_fit_request(*[, sample_weight])

Configure whether metadata should be requested to be passed to the fit method.

set_params(**params)

Set the parameters of this estimator.

set_score_request(*[, sample_weight])

Configure whether metadata should be requested to be passed to the score method.

fit(X, y)[source]#

Fit the module with (re-)initialization using X as training data and y as class labels. The model is reinitialized from scratch when using fit

Parameters:
Xmatrix-like, shape (n_samples, n_features)

Training data set, usually complete, i.e. including the labeled and unlabeled samples

yarray-like of shape (n_samples, )

Labels of the training data set (possibly including unlabeled ones indicated by self.missing_label)

Returns:
self: CapyMOAClassifier,

CapyMOAClassifier object fitted on the training data.

get_metadata_routing()#

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Returns:
routingMetadataRequest

A MetadataRequest encapsulating routing information.

get_params(deep=True)#

Get parameters for this estimator.

Parameters:
deepbool, default=True

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns:
paramsdict

Parameter names mapped to their values.

partial_fit(X, y)[source]#

Fit the module without re-initialization. If the module was already initialized, by calling partial_fit or fit, the module will not be re-initialized again.

Parameters:
Xmatrix-like, shape (n_samples, n_features)

Training data set, usually complete, i.e. including the labeled and unlabeled samples

yarray-like of shape (n_samples, )

Labels of the training data set (possibly including unlabeled ones indicated by self.missing_label)

Returns:
self: CapyMOAClassifier

CapyMOAClassifier object fitted on the training data.

predict(X, **kwargs)#

Return class label predictions for the test samples X.

Parameters:
Xarray-like of shape (n_samples, n_features)

Input samples.

Returns:
ynumpy.ndarray of shape (n_samples,)

Predicted class labels of the test samples X.

predict_proba(X)[source]#

Return probability estimates for the input data X.

Parameters:
Xarray-like of shape (n_samples, …)

Input samples.

Returns:
Parray-like of shape (n_samples, classes)

The class probabilities of the input samples. Classes are ordered according to the attribute self.classes_.

score(X, y, sample_weight=None)#

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

Parameters:
Xarray-like of shape (n_samples, n_features)

Test samples.

yarray-like of shape (n_samples,)

True labels for X.

sample_weightarray-like of shape (n_samples,), default=None

Sample weights.

Returns:
scorefloat

Mean accuracy of self.predict(X) regarding y.

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

Configure whether metadata should be requested to be passed to the fit method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the 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.

Parameters:
sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for sample_weight parameter in fit.

Returns:
selfobject

The updated object.

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:
**paramsdict

Estimator parameters.

Returns:
selfestimator instance

Estimator instance.

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

Configure whether metadata should be requested to be passed to the score method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the 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.

Parameters:
sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for sample_weight parameter in score.

Returns:
selfobject

The updated object.