River is a Python library for online machine learning. It aims to be the most user-friendly library for doing machine learning on streaming data. River is the result of a merger between creme and scikit-multiflow.
⚡️ Quickstart
As a quick example, we'll train a logistic regression to classify the website phishing dataset. Here's a look at the first observation in the dataset.
Now let's run the model on the dataset in a streaming fashion. We sequentially interleave predictions and model updates. Meanwhile, we update a performance metric to see how well the model is doing.
>>>fromriverimportcompose>>>fromriverimportlinear_model>>>fromriverimportmetrics>>>fromriverimportpreprocessing>>>model=compose.Pipeline(
... preprocessing.StandardScaler(),
... linear_model.LogisticRegression()
... )
>>>metric=metrics.Accuracy()
>>>forx, yindataset:
... y_pred=model.predict_one(x) # make a prediction
... metric=metric.update(y, y_pred) # update the metric
... model=model.learn_one(x, y) # make the model learn>>>metricAccuracy: 89.20%
Of course, this is just a contrived example. We welcome you to check the introduction section of the documentation for a more thorough tutorial.
请发表评论