Skip to main content

Online machine learning in Python

Project description


river_logo


tests documentation roadmap pypi pepy bsd_3_license


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.

>>> from pprint import pprint
>>> from river import datasets

>>> dataset = datasets.Phishing()

>>> for x, y in dataset:
...     pprint(x)
...     print(y)
...     break
{'age_of_domain': 1,
 'anchor_from_other_domain': 0.0,
 'empty_server_form_handler': 0.0,
 'https': 0.0,
 'ip_in_url': 1,
 'is_popular': 0.5,
 'long_url': 1.0,
 'popup_window': 0.0,
 'request_from_other_domain': 0.0}
True

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.

>>> from river import compose
>>> from river import linear_model
>>> from river import metrics
>>> from river import preprocessing

>>> model = compose.Pipeline(
...     preprocessing.StandardScaler(),
...     linear_model.LogisticRegression()
... )

>>> metric = metrics.Accuracy()

>>> for x, y in dataset:
...     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

>>> metric
Accuracy: 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.

🛠 Installation

River is intended to work with Python 3.8 or above. Installation can be done with pip:

pip install river

There are wheels available for Linux, MacOS, and Windows, which means that you most probably won't have to build River from source.

You can install the latest development version from GitHub as so:

pip install git+https://github.com/online-ml/river --upgrade

Or, through SSH:

pip install git+ssh://git@github.com/online-ml/river.git --upgrade

🔮 Features

  • Linear models with a wide array of optimizers
  • Nearest neighbors, decision trees, naïve Bayes
  • Anomaly detection
  • Drift detection
  • Recommender systems
  • Time series forecasting
  • Imbalanced learning
  • Clustering
  • Feature extraction and selection
  • Online statistics and metrics
  • Built-in datasets
  • Progressive model validation
  • Model pipelines as a first-class citizen
  • Check out the API for a comprehensive overview

🤔 Should I be using River?

You should ask yourself if you need online machine learning. The answer is likely no. Most of the time batch learning does the job just fine. An online approach might fit the bill if:

  • You want a model that can learn from new data without having to revisit past data.
  • You want a model which is robust to concept drift.
  • You want to develop your model in a way that is closer to what occurs in a production context, which is usually event-based.

Some specificities of River are that:

  • It focuses on clarity and user experience, more so than performance.
  • It's very fast at processing one sample at a time. Try it, you'll see.
  • It plays nicely with the rest of Python ecosystem.

🔗 Useful links

👍 Contributing

Feel free to contribute in any way you like, we're always open to new ideas and approaches.

  • Open a discussion if you have any question or enquiry whatsoever. It's more useful to ask your question in public rather than sending us a private email. It's also encouraged to open a discussion before contributing, so that everyone is aligned and unnecessary work is avoided.
  • Feel welcome to open an issue if you think you've spotted a bug or a performance issue.
  • Our roadmap is public. Feel free to work on anything that catches your eye, or to make suggestions. Simpler tasks are listed here.

Please check out the contribution guidelines if you want to bring modifications to the code base.

🤝 Affiliations

Sponsors

sponsors

Collaborating institutions and groups

collaborations

💬 Citation

If River has been useful to you and you would like to cite it in an scientific publication, please refer to the paper published at JMLR:

@article{montiel2021river,
  title={River: machine learning for streaming data in Python},
  author={Montiel, Jacob and Halford, Max and Mastelini, Saulo Martiello and Bolmier, Geoffrey and Sourty, Raphael and Vaysse, Robin and Zouitine, Adil and Gomes, Heitor Murilo and Read, Jesse and Abdessalem, Talel and others},
  year={2021}
}

📝 License

River is free and open-source software licensed under the 3-clause BSD license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

river-0.11.0.tar.gz (848.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

river-0.11.0-cp310-cp310-win_amd64.whl (1.2 MB view details)

Uploaded CPython 3.10Windows x86-64

river-0.11.0-cp310-cp310-win32.whl (1.2 MB view details)

Uploaded CPython 3.10Windows x86

river-0.11.0-cp310-cp310-musllinux_1_1_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.10musllinux: musl 1.1+ x86-64

river-0.11.0-cp310-cp310-musllinux_1_1_i686.whl (2.0 MB view details)

Uploaded CPython 3.10musllinux: musl 1.1+ i686

river-0.11.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

river-0.11.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (1.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ i686manylinux: glibc 2.5+ i686

river-0.11.0-cp310-cp310-macosx_10_9_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

river-0.11.0-cp39-cp39-win_amd64.whl (1.2 MB view details)

Uploaded CPython 3.9Windows x86-64

river-0.11.0-cp39-cp39-win32.whl (1.2 MB view details)

Uploaded CPython 3.9Windows x86

river-0.11.0-cp39-cp39-musllinux_1_1_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.9musllinux: musl 1.1+ x86-64

river-0.11.0-cp39-cp39-musllinux_1_1_i686.whl (2.0 MB view details)

Uploaded CPython 3.9musllinux: musl 1.1+ i686

river-0.11.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

river-0.11.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (2.0 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ i686manylinux: glibc 2.5+ i686

river-0.11.0-cp39-cp39-macosx_10_9_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

river-0.11.0-cp38-cp38-win_amd64.whl (1.2 MB view details)

Uploaded CPython 3.8Windows x86-64

river-0.11.0-cp38-cp38-win32.whl (1.2 MB view details)

Uploaded CPython 3.8Windows x86

river-0.11.0-cp38-cp38-musllinux_1_1_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.8musllinux: musl 1.1+ x86-64

river-0.11.0-cp38-cp38-musllinux_1_1_i686.whl (2.0 MB view details)

Uploaded CPython 3.8musllinux: musl 1.1+ i686

river-0.11.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

river-0.11.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (2.0 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ i686manylinux: glibc 2.5+ i686

river-0.11.0-cp38-cp38-macosx_10_9_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

File details

Details for the file river-0.11.0.tar.gz.

File metadata

  • Download URL: river-0.11.0.tar.gz
  • Upload date:
  • Size: 848.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.13

File hashes

Hashes for river-0.11.0.tar.gz
Algorithm Hash digest
SHA256 9b52bfa8f9ad08df8ee5994200161cc2b0a0786c1021e11e96e35db890407065
MD5 8be09779a3ae3b99e1b0fbb0c577e550
BLAKE2b-256 2b006436a5e591a1907510083123ed0314484e81989de90324659978303742a7

See more details on using hashes here.

File details

Details for the file river-0.11.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: river-0.11.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.13

File hashes

Hashes for river-0.11.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 0a0206f46d5c84048a4c1aa78341d99854b411a2746465aff430ca2fb1ee9ccb
MD5 12fe2699e2997c2fa1ebbf46f963747e
BLAKE2b-256 a161741d8276070502e69e6913834779299a67a221b4c5b697d7a26bad8b4e8a

See more details on using hashes here.

File details

Details for the file river-0.11.0-cp310-cp310-win32.whl.

File metadata

  • Download URL: river-0.11.0-cp310-cp310-win32.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: CPython 3.10, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.13

File hashes

Hashes for river-0.11.0-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 913aef9ae03415e16a9ebd2d29bc0cb2fdbd83d765a8f01ae5e54efaf3be481e
MD5 541e4ae68729d9a3c6a0ab35fb5b78d1
BLAKE2b-256 20b3931c851d417f13c61503e29726f036bc59414dd82bc45150088766a6519f

See more details on using hashes here.

File details

Details for the file river-0.11.0-cp310-cp310-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for river-0.11.0-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 81486caa0137b86bc0b691f19bf2bb7c163acdcfbce0d34479186f6d3d5246b1
MD5 4451955225e09a8b7c4749e029529b4e
BLAKE2b-256 aec2d335389ab03f98207a3d80fdda56b1ea478b7e7ed34dcca59816f9ea802a

See more details on using hashes here.

File details

Details for the file river-0.11.0-cp310-cp310-musllinux_1_1_i686.whl.

File metadata

File hashes

Hashes for river-0.11.0-cp310-cp310-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 40bd1ab2d84d0a7a7ea7626cfb725075c6d71b4e8d906d5d5c4798db33aac163
MD5 b9548d66bb6deea558d37aaffe2f248c
BLAKE2b-256 6b0f8508884deb41c7d8039376e8e65ee71d9ffad497d4004ac02737675f739a

See more details on using hashes here.

File details

Details for the file river-0.11.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for river-0.11.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ef02980e69379751edb68efcb2ba107711ab0e61af2c82ea8257ef3d31b3ad51
MD5 79216cd5f84226118b07f1791b795606
BLAKE2b-256 c279489b6fb824efed0aa6407a7673aa8045ef78551d7e2a3faeaabeddf214eb

See more details on using hashes here.

File details

Details for the file river-0.11.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for river-0.11.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 d79ec037df2ee5e2f84a877bf6d01c46c4366f472e086f25c49b3cef3b7c882a
MD5 fef52753f23ab38f55053b829d06da39
BLAKE2b-256 c95cb9e3d0c590ab0e933dac4a569e4ee140131a867c68c0cef40acf3c10a42c

See more details on using hashes here.

File details

Details for the file river-0.11.0-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for river-0.11.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8c66b83247bb1fd60e71df9cd600908ac8ee0d0c951832ded510afa83164bdb2
MD5 a10844d20a797e86371b7cab36a9cd52
BLAKE2b-256 f5b4d6ca57ca22dcb379885f1a57d3e96082005847cbd85ab0740f5402e20f85

See more details on using hashes here.

File details

Details for the file river-0.11.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: river-0.11.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.13

File hashes

Hashes for river-0.11.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 94592393a05009750a194fff35d00943aee81b48724ca9793d3b2395adb9cee8
MD5 1db10c8b215a038333026e746d73d05c
BLAKE2b-256 12de3f6ec5e8858709e56b7ef9125965c93895290e5b760250732dd898d76d97

See more details on using hashes here.

File details

Details for the file river-0.11.0-cp39-cp39-win32.whl.

File metadata

  • Download URL: river-0.11.0-cp39-cp39-win32.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: CPython 3.9, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.13

File hashes

Hashes for river-0.11.0-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 ddf829620b5444ba5a5a4dee03ada3fd93cdd35158185aefca2a2dc4ba17f05d
MD5 ee28057e8cce55c6a0a0e5704843fb20
BLAKE2b-256 9fadd111cca8521c5f4c59cdc6c324f9847f4e5cd71b865c839655043184e0ea

See more details on using hashes here.

File details

Details for the file river-0.11.0-cp39-cp39-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for river-0.11.0-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 89d006720e93fec4ed8be3a2d7b685b6560fdbc5fd6a5d6e9b974bac6d152dfe
MD5 41154f322518c4f375aa77d94e2f9a95
BLAKE2b-256 bb9536805e52e03d1334d3ec0983e61d038d5e198b4960dab9568690053d9c9e

See more details on using hashes here.

File details

Details for the file river-0.11.0-cp39-cp39-musllinux_1_1_i686.whl.

File metadata

File hashes

Hashes for river-0.11.0-cp39-cp39-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 312497b52881cbac5f8bc98c5c078832ce798dffb5252861df3135224b8a6808
MD5 e9e69274869c1437ca0c8f8ecc562195
BLAKE2b-256 8f385921e5a62a8aa6b3c1e18a22e1484cc7c9dc72ebe5885bf159ceef6565be

See more details on using hashes here.

File details

Details for the file river-0.11.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for river-0.11.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 18f6ad9b1fe81c52657d023bfdb191cdc3e7023481075166937bdcfe10d35b0b
MD5 1aefd96ba1f6f3915b0a8741d5cca9c2
BLAKE2b-256 4508097d4a51564ce21d90b527b2366c71c997bf45652113110d009d3dc3ea02

See more details on using hashes here.

File details

Details for the file river-0.11.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for river-0.11.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 ab74e61481916d1f4dc577bf0a0934d2021be86f0cec4cf897505ad516c44960
MD5 b3e849f5e31542fda1974efa0addf290
BLAKE2b-256 f44699409be5b817c1a3b739aed618c1365a04fd52333f6cd3c257b7289d5fbf

See more details on using hashes here.

File details

Details for the file river-0.11.0-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for river-0.11.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 858a1cf2a17b5050e043fbdb0d67492b13dadd96e5ad2b459396e9da4eb924cf
MD5 88a57a2d4ae942bca5ba13d7a007cc3e
BLAKE2b-256 0ff4ecb8efee45ec2546d461e2c43cd1e9de69d95206cd60963715ba5b70102a

See more details on using hashes here.

File details

Details for the file river-0.11.0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: river-0.11.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.13

File hashes

Hashes for river-0.11.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 ce3d45f008d04facf831e4e24e611593df9b3540f36b91b01c3dfd5de4ae4605
MD5 2b55f16fe87abd9d8c950ac054a17707
BLAKE2b-256 2c254c1f1caf25229d7b50671460a4453da3a805f4c008388bf97f221f86f33a

See more details on using hashes here.

File details

Details for the file river-0.11.0-cp38-cp38-win32.whl.

File metadata

  • Download URL: river-0.11.0-cp38-cp38-win32.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: CPython 3.8, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.13

File hashes

Hashes for river-0.11.0-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 388c9c0a2bf28e58884dea69c7497300c33aaeef54d7b85fe390515199dc0133
MD5 b85addbb3dd7f13bca5b2d94b38aee03
BLAKE2b-256 26668e279628bb9852e273f37f6b3884c841610bb00bab9c33e4088ca0b2a3e4

See more details on using hashes here.

File details

Details for the file river-0.11.0-cp38-cp38-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for river-0.11.0-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 0914f2596cfc80a4b9ca6ee38c22538c3127c966bdc481860292ffd2e19071fc
MD5 f213788cf3e27f7d66de00ab20feaf90
BLAKE2b-256 893a352525289ddfacc5b168e184e5e11493d06c8b6787a3d759959e15c69b80

See more details on using hashes here.

File details

Details for the file river-0.11.0-cp38-cp38-musllinux_1_1_i686.whl.

File metadata

File hashes

Hashes for river-0.11.0-cp38-cp38-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 fc59d285877d6e9a12f72d784d3bbebba0110b44146507db908099490b78fc9e
MD5 c77b9e6b1bda09281af00b581bbf872b
BLAKE2b-256 be8d1b6c3ea531e555a1ccf5dde7e2f090ccb5bbacf989f83aac7b4a2d9a6e31

See more details on using hashes here.

File details

Details for the file river-0.11.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for river-0.11.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1493e049fbea4ef79a9a8b0570222bdbdca5376abad1c6db30c25e3d4561a199
MD5 d4dddf543aa711c5fde10f66b23d3d43
BLAKE2b-256 4aba86934f5602f238e58ea8501e1cbc1cbe0fd625a6920e95f3b1fba04b8566

See more details on using hashes here.

File details

Details for the file river-0.11.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for river-0.11.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 81c97aab87901f4879cf6faf713b071a57a991c4c2fd92b101c06169f2742185
MD5 18254da183eb2da5780341a16044c8c3
BLAKE2b-256 334c81429786c5e6299e405a0a56982b00c5b9a62864c690c0b3a9eb9d601e71

See more details on using hashes here.

File details

Details for the file river-0.11.0-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for river-0.11.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a55b4be5998e4d568ebb0d2101632ca01167f00eb2dd7d9895cb45560b39f897
MD5 a08a3512b759ff9f61a4137d506e6353
BLAKE2b-256 27f986fbb2d0a9005cc44d8482d5e18b649c2a7f539a3f9206b273224b26ce14

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page