Skip to content

SKL2RiverClassifier

Compatibility layer from scikit-learn to River for classification.

Parameters

  • estimator

    Typesklearn_base.ClassifierMixin

    A scikit-learn regressor which has a partial_fit method.

  • classes

    Typelist

Examples

from river import compat
from river import evaluate
from river import metrics
from river import preprocessing
from river import stream
from sklearn import linear_model
from sklearn import datasets

dataset = stream.iter_sklearn_dataset(
    dataset=datasets.load_breast_cancer(),
    shuffle=True,
    seed=42
)

model = preprocessing.StandardScaler()
model |= compat.convert_sklearn_to_river(
    estimator=linear_model.SGDClassifier(
        loss='log_loss',
        eta0=0.01,
        learning_rate='constant'
    ),
    classes=[False, True]
)

metric = metrics.LogLoss()

evaluate.progressive_val_score(dataset, model, metric)
LogLoss: 0.198029

Methods

learn_many
learn_one

Update the model with a set of features x and a label y.

Parameters

  • x
  • y

predict_many
predict_one

Predict the label of a set of features x.

Parameters

  • x

Returns

The predicted label.

predict_proba_many
predict_proba_one

Predict the probability of each label for a dictionary of features x.

Parameters

  • x

Returns

A dictionary that associates a probability which each label.