MulticlassStrategy#

class mlquantify.multiclass.MulticlassStrategy[source]#

Base class for multiclass decomposition strategies.

A strategy turns a binary quantifier into a multiclass one: it decomposes the problem, fits/predicts the binary sub-quantifiers, and recombines their outputs into per-class prevalences. Register new strategies (e.g. ECOC, hierarchical) with register_strategy and they become usable through the quantifier’s strategy attribute with no change to the dispatch.

Subclasses implement fit, predict, aggregate and fit_predict, returning prevalences before the shared validate_prevalences normalization applied by BinaryQuantifier.

aggregate(quantifier, classes, args_dict, n_jobs=None)[source]#

Return per-class prevalences from pre-computed predictions.

fit(quantifier, X, y, n_jobs=None, fit_args=None, fit_kwargs=None)[source]#

Return {key: fitted_binary_quantifier} for the decomposition.

fit_predict(quantifier, X, y, X_test, classes, n_jobs=None)[source]#

Fit on (X, y) and return per-class prevalences for X_test.

predict(quantifier, X, n_jobs=None)[source]#

Return per-class prevalences (dict or array) for X.