Online machine learning in Python
Project description
creme
is a Python library for online machine learning. All the tools in the library can be updated with a single observation at a time, and can therefore be used to learn from streaming data.
⚡️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 creme import datasets
>>> X_y = datasets.Phishing() # this is a generator
>>> for x, y in X_y:
... 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 creme import compose
>>> from creme import linear_model
>>> from creme import metrics
>>> from creme import preprocessing
>>> model = compose.Pipeline(
... preprocessing.StandardScaler(),
... linear_model.LogisticRegression()
... )
>>> metric = metrics.Accuracy()
>>> for x, y in X_y:
... y_pred = model.predict_one(x) # make a prediction
... metric = metric.update(y, y_pred) # update the metric
... model = model.fit_one(x, y) # make the model learn
>>> metric
Accuracy: 89.20%
🛠 Installation
creme
is intended to work with Python 3.6 or above. Installation can be done with pip
:
pip install creme
There are wheels available for Linux, MacOS, and Windows, which means that in most cases you won't have to build creme
from source.
You can install the latest development version from GitHub as so:
pip install git+https://github.com/creme-ml/creme --upgrade
Or, through SSH:
pip install git+ssh://git@github.com/creme-ml/creme.git --upgrade
🧠 Philosophy
Machine learning is often done in a batch setting, whereby a model is fitted to a dataset in one go. This results in a static model which has to be retrained in order to learn from new data. In many cases, this isn't elegant nor efficient, and usually incurs a fair amount of technical debt. Indeed, if you're using a batch model, then you need to think about maintaining a training set, monitoring real-time performance, model retraining, etc.
With creme
, we encourage a different approach, which is to continuously learn a stream of data. This means that the model process one observation at a time, and can therefore be updated on the fly. This allows to learn from massive datasets that don't fit in main memory. Online machine learning also integrates nicely in cases where new data is constantly arriving. It shines in many use cases, such as time series forecasting, spam filtering, recommender systems, CTR prediction, and IoT applications. If you're bored with retraining models and want to instead build dynamic models, then online machine learning (and therefore creme
!) might be what you're looking for.
Here are some benefits of using creme
(and online machine learning in general):
- Incremental: models can update themselves in real-time.
- Adaptive: models can adapt to concept drift.
- Production-ready: working with data streams makes it simple to replicate production scenarios during model development.
- Efficient: models don't have to be retrained and require little compute power, which lowers their carbon footprint
- Fast: when the goal is to learn and predict with a single instance at a time, then
creme
is a order of magnitude faster than PyTorch, Tensorflow, and scikit-learn.
🔥 Features
- Linear models with a wide array of optimizers
- Nearest neighbors, decision trees, naïve Bayes
- Progressive model validation
- Model pipelines as a first-class citizen
- Anomaly detection
- Recommender systems
- Time series forecasting
- Imbalanced learning
- Clustering
- Feature extraction and selection
- Online statistics and metrics
- Built-in datasets
- And much more
🔗 Useful links
💬 Media
- PyData Amsterdam 2019 presentation (slides, video)
- Toulouse Data Science presentation
- Online/Incremental Learning with Keras and Creme on pyimagesearch
- Machine learning for streaming data with creme on Medium
👍 Contributing
Feel free to contribute in any way you like, we're always open to new ideas and approaches. If you want to contribute to the code base please check out the CONTRIBUTING.md file. Also take a look at the issue tracker and see if anything takes your fancy.
This project follows the all-contributors specification. Again, contributions of any kind are welcome!
Max Halford 📆 💻 |
AdilZouitine 💻 |
Raphael Sourty 💻 |
Geoffrey Bolmier 💻 |
vincent d warmerdam 💻 |
VaysseRobin 💻 |
Lygon Bowen-West 💻 |
Florent Le Gac 💻 |
Adrian Rosebrock 📝 |
Jovan Veljanoski 💻 |
Dimitri 💻 |
Gaurav Sharma 💻 |
📝 License
creme
is free and open-source software licensed under the 3-clause BSD license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for creme-0.6.1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 973777139abcfb4a2dfe5a2807c37f588fffa389b82a5eaab48bcd4417801210 |
|
MD5 | 7ddff7b61a4c76ffde96d6ad8f3b6dc6 |
|
BLAKE2b-256 | 268b849310ff69bfc82d26436a06c82cc6c5ccfd4069daa1af0c74eb3290be3d |
Hashes for creme-0.6.1-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b0301fdcd7fe238c3b2fe93154fce3229b1b4b00d93eb56c12f3d248c446800 |
|
MD5 | 4600b9b1a364c32924a67d4637b71c84 |
|
BLAKE2b-256 | 1958a310b0a12860a0ea6643586e5de186235494d0e47f57954e2749584de392 |
Hashes for creme-0.6.1-cp38-cp38-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9532a9624828a12c783e87ae043d5459e6039c8db94df49b99b6e415860f71b0 |
|
MD5 | 3a24c803b347c1a6ebfc7f8526c27d07 |
|
BLAKE2b-256 | 9d512bc925cfda0f0c751eb450d66365f725751c27a0402053a00cf10b0f03d4 |
Hashes for creme-0.6.1-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a6badac4564f33512ac939a2401e6dcf288422ba13fe355d73fd59936a6c62c |
|
MD5 | 8e42c9e26b6e32239d060c0094bf7e87 |
|
BLAKE2b-256 | 6332c652a8e8d79f4d3a1830462fede5a061581c02ee0ac59249d7293038f6a5 |
Hashes for creme-0.6.1-cp38-cp38-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | febe182c988973e5f9a10ab9a95e9da8fd51dc93258ec62d050f3cb9744847de |
|
MD5 | adc446d652fdd083d9c8a280d9384b4f |
|
BLAKE2b-256 | f4a2f8b9da138a079596e28cc0fec87ecdf5a61f20a3f7d732d2aa3411a14117 |
Hashes for creme-0.6.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 574fd301c6c14a8a142162d5cd4b4982795cb5d88fadd07a9e06562aba9dad99 |
|
MD5 | 2e6ef8dbfaa870ba9dc4c434be43e018 |
|
BLAKE2b-256 | 68733c8ed2087c2ba63ca219e1620fcfe947f9bfb361e857bd04ff75a9a46f3a |
Hashes for creme-0.6.1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 132981223b1228da711300d162ad32e5b7d9c5bf2e31cc60653e115abdbaee29 |
|
MD5 | b6416223f8d4289d32043cf0d39697de |
|
BLAKE2b-256 | 8099a1ea01d9d36e185daa1860d0bf7c9b5deeb3b86db26fc33e5db89a2d281b |
Hashes for creme-0.6.1-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30fdc6141305e29dd66a757603b48d0b0e6324c58f0fa9a8d97ba26c3a52af40 |
|
MD5 | 73a1e7c32fac512b127b7e04fda50298 |
|
BLAKE2b-256 | 9e61372d68113d047c3095e9f5e0772119d8666ff620ed59ac346e7ef3b0d671 |
Hashes for creme-0.6.1-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f212bc7529cf065be6937465110bd2ec76ffd7602648166a6f54be8e595eb0ac |
|
MD5 | 16eb73ba7cec3245a6ee770721128b98 |
|
BLAKE2b-256 | bc88e31aab6aca8d0a83ffe5f23d029ba9866c4e2a606c45f74bacd59192e31b |
Hashes for creme-0.6.1-cp37-cp37m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c0726a8a496f41657f122c7ddc3e7e1c47126b7d7e8e69c03d490a169866faa |
|
MD5 | de269cc96ac858fa2631b2e24b96769e |
|
BLAKE2b-256 | cf6f709866bda0277b31196cba04a3ba2dee05de7694772ff7b7ab76e582e893 |
Hashes for creme-0.6.1-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a665efa102b9cc79cd29623dca09168882145a2eac334412d225bf6458a3439 |
|
MD5 | 7c6027e3661b27dcf28bc1661a2578df |
|
BLAKE2b-256 | e87c1055c546e9dd1cd3a8d5fd6e1543899cbe44f29cf5c45deb663f13c43d27 |
Hashes for creme-0.6.1-cp37-cp37m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60bcc8484929526b2b5f75eded1fc26e780f886e0d04748a0e620e0890960f79 |
|
MD5 | 1b7f495fd470e7d6a5cba3352d5ca273 |
|
BLAKE2b-256 | d8126dd4fd4fc0ac4a49b6d374cf50e02280b994d412ac728bd838287bd1205a |
Hashes for creme-0.6.1-cp37-cp37m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53f38054939a0d581ef80f1ea07c0d184769aa44afc5335b2cc72ce92ee40f2f |
|
MD5 | b690acf09ebe0d9268b4e574751b1c07 |
|
BLAKE2b-256 | db87ace48647ab276fe43e10188558922e508046040aa05f7aa17f0ed21363f8 |
Hashes for creme-0.6.1-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6bd007a59f34e8ba0518fb9f46036d694a4a9ab7f3ffdc64a51f1dc35a88ff7 |
|
MD5 | 970f796cf001889c42b6a7d5becdbbd3 |
|
BLAKE2b-256 | b21c664cd2f7b8de26f2f5fb2f353eeac7dcb2ab0b40cc84c12d56acab2f8056 |
Hashes for creme-0.6.1-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57b0a0c9cffb5e4736a138eda4c04a943fffe8eae3912398a734ec2e2c7d8470 |
|
MD5 | e064cd86a5b58c5e61caea1b298df02c |
|
BLAKE2b-256 | 2e4ec6c593619dcb1d48bf06c204350de7da1260e0a10f31ec71dc8119c72699 |
Hashes for creme-0.6.1-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37da19b56c943dfbe9c70fc2f83602beeccb0de8355bd1091f22adb76dcbe804 |
|
MD5 | 32a09924060e6630e7d2106e018bf0ae |
|
BLAKE2b-256 | ce8f95044edac0127f71251a187ae1be0fe0e9bab24050cd6ab29210f078b179 |
Hashes for creme-0.6.1-cp36-cp36m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42f8a7f520312189ca252df783dcf6d712dd0c54d762f67119c7a39250d78633 |
|
MD5 | 15081f65a78845f5f8ca0715e2fad80c |
|
BLAKE2b-256 | 6267cfccc269983437a33a6c2c75a50ac431667a00f8d5c1f50a2177543a3907 |
Hashes for creme-0.6.1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e5459b8f3c8bd6ed2040c57eeb7ba9892506ce29c0079f16f859f3ec5b1f955 |
|
MD5 | 009fe3ac63cff40d35d823c6b4b02c45 |
|
BLAKE2b-256 | 60c903ad65f9b701c100bf6c9fa69d995e98b6e009869a8542d0a8cfcbcd545b |
Hashes for creme-0.6.1-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b2f2e60fe97246fc722da66443b9edd49ec9112772c5b98d9862eb177673642 |
|
MD5 | 87442f17559a930c662a84ad602aa594 |
|
BLAKE2b-256 | e72252cd3fa6f4a466f98d4f3db3a586885837449899993df19a1b167daf1ca1 |
Hashes for creme-0.6.1-cp36-cp36m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | afcc9d148537c632041d028618dd1f71ac52e7c38028e93a920888f00cf66e29 |
|
MD5 | ac055bd84eb667e91b106d815b04353a |
|
BLAKE2b-256 | e533d028cf13ed17302c16c711a45ce4a863ea37d8f5a9a718544bea11d42e4f |