DummyClassifier
DummyClassifier makes predictions that ignore the input features.
Quickstart
from sktime.classification.dummy import DummyClassifier
estimator = DummyClassifier(strategy='prior', random_state=None, constant=None)Parameters(3)
- strategy{“most_frequent”, “prior”, “stratified”, “uniform”, “constant”}, default=”prior”
Strategy to use to generate predictions.
“most_frequent”: the
predictmethod always returns the most frequent class label in the observedyargument passed tofit. Thepredict_probamethod returns the matching one-hot encoded vector.“prior”: the
predictmethod always returns the most frequent class label in the observedyargument passed tofit(like “most_frequent”).predict_probaalways returns the empirical class distribution ofyalso known as the empirical class prior distribution.“stratified”: the
predict_probamethod randomly samples one-hot vectors from a multinomial distribution parametrized by the empirical class prior probabilities. Thepredictmethod returns the class label which got probability one in the one-hot vector ofpredict_proba. Each sampled row of both methods is therefore independent and identically distributed.“uniform”: generates predictions uniformly at random from the list of unique classes observed in
y, i.e. each class has equal probability.“constant”: always predicts a constant label that is provided by the user. This is useful for metrics that evaluate a non-majority class.
- random_stateint, RandomState instance or None, default=None
Controls the randomness to generate the predictions when
strategy='stratified'orstrategy='uniform'. Pass an int for reproducible output across multiple function calls.- constantint or str or array-like of shape (n_outputs,), default=None
- The explicit constant as predicted by the “constant” strategy. This parameter is useful only for the “constant” strategy.
Examples
>>> from sktime.classification.dummy import DummyClassifier
>>> from sktime.datasets import load_unit_test
>>> X_train, y_train = load_unit_test (split = "train")
>>> X_test, y_test = load_unit_test (split = "test")
>>> classifier = DummyClassifier (strategy = "prior")
>>> classifier. fit (X_train, y_train) DummyClassifier()
>>> y_pred = classifier. predict (X_test)
>>> y_pred_proba = classifier. predict_proba (X_test)