<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Max Halford on Medium]]></title>
        <description><![CDATA[Stories by Max Halford on Medium]]></description>
        <link>https://medium.com/@maxhalford25?source=rss-aff4365c3dba------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*zG9AnWlqq3KvoKSdS_GeoQ.jpeg</url>
            <title>Stories by Max Halford on Medium</title>
            <link>https://medium.com/@maxhalford25?source=rss-aff4365c3dba------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 01:37:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@maxhalford25/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Automated document processing at Alan]]></title>
            <link>https://medium.com/alan/automated-document-processing-at-alan-918308234390?source=rss-aff4365c3dba------2</link>
            <guid isPermaLink="false">https://medium.com/p/918308234390</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[healthcare]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[automation]]></category>
            <dc:creator><![CDATA[Max Halford]]></dc:creator>
            <pubDate>Thu, 10 Jun 2021 14:37:41 GMT</pubDate>
            <atom:updated>2021-07-01T09:55:55.359Z</atom:updated>
            <content:encoded><![CDATA[<p>Alan is mostly known for its digital health insurance product. The purpose of a health insurer is to cover users for their health expenses. The health insurer needs to be informed that user A went to doctor B and spent amount X. In France, this happens mostly automatically when the user swipes their social security card. Still, there are many cases where documents need to be sent by the users themselves. Alan users can send their health insurance documents via their mobile app. We receive thousands of them every day.</p><p>Behind the scenes, Alan takes care of processing the document and determining how much to reimburse the user. Our goal is to delight the user and reimburse them the correct amount as fast as possible. This provides many opportunities for automation. In particular, our data science team works on parsing the necessary information from the documents automatically.</p><h3>The life of a document</h3><p>Processing a health insurance document automatically can be broken down into a sequence of steps. First we have to convert the document to a text representation so that the computer can read it. This allows us to extract particular pieces of information with natural language processing techniques. Once this is done, we can determine how much to reimburse the user who uploaded the document.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*an7hZ7afuD58Qex1" /><figcaption>The sequence of steps to process a health insurance document</figcaption></figure><h3><strong>Uploading the document</strong></h3><p>The first step is to ask the user to take a picture and provide them with a good UX to do so. This may seem obvious, but this has a very large impact on the quality of the document and thus our ability to parse it. We can’t do much if the user takes a bad picture. In other words: <em>garbage in, garbage out</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ClhCN5NtMEZKBEEp" /><figcaption>A typical osteopathy invoice we process every day</figcaption></figure><p>The image above is a typical example of an osteopathy invoice we might receive from a user. The pieces of information that matter are: the invoice amount (55 euros), the date the care was delivered (1st of June 2021), the name of the doctor (here we’ve anonymised it), and the name of the patient (anonymised too). Of course, extracting this information is easy for a human, but it’s quite difficult for a computer!</p><h3><strong>Optical character recognition</strong></h3><p>Document processing is made up of many tasks that fall into the realm of natural language processing (NLP). But before we can do any of that, we have to convert the documents into text. For PDFs, <a href="https://github.com/pdfminer/pdfminer.six">PDFMiner</a> does the job very well. For images, an optical character recognition (OCR) system is necessary.</p><p>Like many other companies, we use third party OCR systems, namely Amazon Textract and Google Cloud Vision. We use both because we noticed that they exhibit different strengths and weaknesses. For instance, we found that <a href="https://aws.amazon.com/fr/textract/">Amazon Textract </a>was better at recognising handwritten text. Meanwhile, the OCR from <a href="https://cloud.google.com/vision">Google Cloud Vision</a> is more accurate at placing bounding boxes around words.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/905/0*7-AvSIu7nKuIeQ9p" /><figcaption>The output of the OCR</figcaption></figure><p>Third party OCRs are controversial because the documents they process may contain personal and sensitive information. Of course, we have signed legally binding contracts to ensure these third parties cannot exploit the contents of the documents, even if it’s just for training their models. We have the ambition to build our own OCR technology one day, but at the moment it doesn’t make sense for us to pour resources into such an endeavour.</p><h3><strong>Document classification</strong></h3><p>Before extracting information from a document, we need to determine what type of document we’re looking at. Indeed, the type of the document determines what information is necessary.</p><p>We found that using a straightforward <a href="https://www.wikiwand.com/en/Tf%E2%80%93idf">TFIDF</a> + multinomial regression pipeline does the trick. Indeed, the health insurance documents are usually easy to classify. A typical osteopathy invoice includes the words “osteopathy” or “osteopathe”. A pharmacy prescription is likely to contain “mg” for “milligram”. The precision of our model is well above 98% and the recall is very high too.</p><p>With regards to model deployment, we opted for a simple and yet often overlooked approach. We don’t introduce additional servers and APIs to serve our models. We simply load each model in memory side-by-side with our website application. We lighten the memory usage of the model by <a href="https://maxhalford.github.io/blog/sklearn-text-classifier-memory-footprint-reduction/">pruning the model</a> of its non-significant parts. We like to keep things simple.</p><h3><strong>Information extraction</strong></h3><p>The next step is to extract specific pieces of information from the text. This task is called <a href="https://www.wikiwand.com/en/Information_extraction">information extraction</a>. We have a bunch of text and want to extract dates, identifiers, currency amounts, etc. The text we have is noisy because OCRs make mistakes, especially on handwritten text. Moreover, we can’t really use a supervised approach such as <a href="https://www.wikiwand.com/en/Named-entity_recognition">named-entity recognition</a> because it would be too expensive to label the contents of our documents.</p><p>We decided on an unsupervised rule-based approach. We start by defining a list of regular expressions where each expression focuses on a specific pattern. For dates, one pattern will look for DD/MM/YYYY, another will look for DD/MM and assume the year is the current year, <em>et cetera</em>.</p><p>Sometimes the OCR might misinterpret a slash “/” as a “1” or a “l”. Likewise “rn” might become “m”. These are called <a href="https://www.wikiwand.com/en/Homoglyph">homoglyphs</a>. Our extractors are designed to handle these kind of mistakes. The goal is to establish a list of pattern extractors that together have a high recall. We have a historical database of manual parsings made by humans, so we can measure the performance of our extraction process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zU1uxC2Namz_OGXN" /><figcaption>The necessary information has been located</figcaption></figure><p>We run many patterns to find pieces of information in the text. This generates a list of candidates. We then need some mechanism to decide which candidate is the correct one. Indeed, we might find multiple dates, and only one of them is the date where the document was issued. Likewise for currency amounts.</p><p>We use heuristics that are validated empirically to choose between different candidates. For instance, we know that 95% of the time an osteopathy invoice amount is a round number between 40 and 90 euros. Therefore, amounts that do not satisfy these criteria are discarded. If multiple candidates remain, we ask a human to make the final decision. For dates, we’ll select the ones that are closest to the date the document was uploaded at, and will ask for human help if there are multiple likely dates.</p><p>In the case of osteopathy invoices, we are able to extract all the necessary information with no human intervention in 50% of cases. For the other half, the OCR struggles to decipher the doctor’s handwriting.</p><h3><strong>Reimbursing the user</strong></h3><p>Once we’ve extracted the necessary information, we can decide how much to reimburse the user. This depends not only on the amount(s) specified on the document, but also on the user’s coverage plan, their age, the kind of doctor they’ve consulted, etc. All this is determined in our <a href="https://medium.com/alan/alans-claim-engine-technical-design-principles-e8b4760e72c8">claim engine</a>. The latter spits out an amount that will be wired to the user’s bank account, and a notification will be sent to the user’s phone once this has happened.</p><p>Most of the time it takes less than a minute to go from the moment a user uploads a document to the moment they get reimbursed. This creates a wow effect that delights our users, and they don’t shy away from telling us!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/0*r5f13HRhpB3SSIuY" /><figcaption>Our users are delighted by the speed at which we reimburse them!</figcaption></figure><h3><strong>What’s next?</strong></h3><p>Document processing is and will continue to be an important topic at Alan. There are still many types of documents that we have yet to automate. Some have complex structures and require more sophistication. Whatsmore, we are opening up our health insurance offer to more countries, which implies new kinds of documents to parse.</p><p>This is a challenging technical topic. There are many opportunities to apply various kinds of artificial intelligence algorithms. We made the bet to start simple and productionalize our work as fast as possible to obtain learnings. So far this has proved successful and has yielded results. Now we want to iterate and build a more advanced document processing system that is able to deal with many more documents.</p><p>We’re definitely looking to expand our expertise in this area. If this post has piqued your interest, please consider <a href="https://jobs.lever.co/alan">applying</a> for a job!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=918308234390" width="1" height="1" alt=""><hr><p><a href="https://medium.com/alan/automated-document-processing-at-alan-918308234390">Automated document processing at Alan</a> was originally published in <a href="https://medium.com/alan">Alan Product and Technical Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Machine learning for streaming data with creme]]></title>
            <link>https://medium.com/data-science/machine-learning-for-streaming-data-with-creme-dacf5fb469df?source=rss-aff4365c3dba------2</link>
            <guid isPermaLink="false">https://medium.com/p/dacf5fb469df</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[streaming]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Max Halford]]></dc:creator>
            <pubDate>Thu, 26 Mar 2020 15:53:30 GMT</pubDate>
            <atom:updated>2020-03-26T15:53:30.863Z</atom:updated>
            <content:encoded><![CDATA[<h4>Online machine learning can change the way you think about data science in production</h4><figure><img alt="A stream of data and some decision trees" src="https://cdn-images-1.medium.com/max/1024/0*yyg8h0LmwH2kqmP6" /><figcaption>Photo by <a href="https://unsplash.com/@jfobranco?utm_source=medium&amp;utm_medium=referral">Joao Branco</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Motivation</h3><p>Deploying machine learning models into a production environment is a difficult task. Currently, the common practice is to have an offline phase where the model is trained on a dataset. The model is afterwards deployed online to make predictions on new data. Therefore, the model is treated as a static object. In order to learn from new data, the model has to be retrained from scratch. This deployment pattern is sometimes referred to as the <a href="https://www.wikiwand.com/en/Lambda_architecture">lambda architecture</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*Q8ppT82LZYv1j680gcJ-6w.png" /><figcaption>Model lifecycle with the lambda architecture, source: <a href="https://maxhalford.github.io/slides/the-benefits-of-online-learning/#1">The Benefits of Online Machine Learning</a></figcaption></figure><p>The lambda architecture is so ubiquitous that it has transpired throughout the industry. In fact, AutoML platforms such as <a href="https://www.datarobot.com/">DataRobot</a> and <a href="https://www.h2o.ai/">H2O</a> do exactly this. You give them data, and they provide you with an API behind which a model is sitting. The same goes for tools with less automation such as <a href="https://mlflow.org/">MLflow</a><a href="https://aws.amazon.com/fr/sagemaker/">, Amazon Sagemaker,</a> <a href="https://www.cubonacci.com/">Cubonacci</a>, and <a href="https://www.alteryx.com/">Alteryx</a>. This is also the approach taken by lesser known projects such as <a href="https://github.com/cortexlabs/cortex">Cortex</a> and <a href="https://github.com/ucbrise/clipper">Clipper</a>. I’m not knocking these tools; in fact I all find them wonderful, and they’re providing healthy competition to each other.</p><p>Machine learning models are deployed in such a manner because they are limited by the learning capacity of the model. Indeed, machine learning algorithms usually assume that all the training data is available at once. This is referred to as <em>batch learning </em>in the litterature. Historically, statisticians and ML researchers have mostly been interested in “fitting” a model to a dataset and leave it at that. Only a small subset of research has delved into designing models that are able to update themselves whenever new data is available.</p><p>Wouldn’t it be nice to have models that are able to learn incrementally? Think about it: take a student who goes to classes at college every day. When a class begins, the student has accumulated knowledge from all past classes. The teacher doesn’t start back from the first class every time he wants his students to learn a new idea. That would be crazy, right? Well, that’s exactly what a lot of machine learning practictioners are doing right now.</p><p>It turns out that batch learning has a lesser known sister called <em>online learning</em>. As you might have guessed, online learning encompasses all models which are able with one observation at a time. <strong>Online learning is a paradigm shift because it allows to change the way we think about machine learning deployment</strong>. In addition to making predictions for new data, an online model is also able to learn from it. Indeed, the predictions and learning phases of an online can be interleaved into what is sometimes called the <a href="https://milinda.pathirage.org/kappa-architecture.com/">kappa architecture</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*QwdL3ia1NXUTHr9EKv_HRQ.png" /><figcaption>Model lifecycle with the kappa architecture, source: <a href="https://maxhalford.github.io/slides/the-benefits-of-online-learning/#1">The Benefits of Online Machine Learning</a></figcaption></figure><p>With the kappa architecture, the data is treated as a stream. Once a model has been updated with a new piece of data, then that piece of data can effectively be discarded. In other words, <strong>you don’t have to store a historical training set and retrain your model every so often</strong>. Another benefit is that <strong>your model is always up-to-date</strong>. The natural consequence is that <strong>your model is able to deal with </strong><a href="https://www.wikiwand.com/en/Concept_drift"><strong>concept drift</strong></a>, which happens when the data’s distribution evolves as time goes on. Moreover, the model lifecycle is easier to think about because the learning and prediction steps both process one input at a time. Meanwhile batch models have to be retrained as often as possible to cope with concept drift. This requires contant monitoring and makes maintenance more difficult. With batch learning you also have to ensure that the features you’ve used for training the model are also accessible in production.</p><p>Batch machine learning is great, and it works fine in many cases. However, online machine learning is a more adequate solution for some usecases. It just makes sense for applications where new data is constantly arriving: spam filtering, recommender systems, IoT sensors, financial transactions, etc. As we just mentioned, online models especially shine when the patterns in the data are evolving and require the model to adapt. In my experience, many practioners try to fit a square peg into a round hole: batch machine learning isn’t made to be used in a streaming environment. I’ve seen batch models plummet in production because they were not able to learn from new data.</p><p>Using an online machine learning model can also lower your operational costs, both in terms of compute power and human intervention. First of all, you don’t need powerful hardware in order to process a streaming dataset, because only one element of the stream lives in memory at a time. In fact, online machine learning can effectively be deployed on a Raspberry Pi. Secondly, your data scientists can spend less time dealing with model retraining because model updates are baked into online machine learning, and can therefore spend more time on tasks with more added value.</p><p>So why aren’t we all using online machine learning? Well, some of us are. Big players — you know who I mean — are using online models for <a href="https://research.google/pubs/pub41159/">ad click-through rate prediction</a> as well as <a href="https://www.microsoft.com/en-us/research/blog/real-world-interactive-learning-cusp-enabling-new-class-applications/">news feed recommendations</a>. Online machine learning just isn’t a mainstream notion. The culprits are easy to find. <a href="https://www.kaggle.com/">Kaggle</a> competitions present data science as a scientific experiment where the data is split into a training set and a test set. University courses and MOOCs teach students the most popular machine learning algorithms, which are mostly batch algorithms. Finally, popular libraries such as <a href="https://scikit-learn.org/stable/">scikit-learn</a> encourage users to think in terms of rectangular datasets that hold in memory, not in terms of streaming data.</p><p>In my honest opinion, the main reason why people aren’t using online machine learning is simply because there isn’t a lot of available tooling to do so. There are great tools to analyze streaming data, such as <a href="http://samza.apache.org/">Samza</a> and <a href="https://flink.apache.org/">Flink,</a> but they don’t allow to do any serious machine learning. There are also tools to learn from large datasets, such as <a href="https://spark.apache.org/">Spark</a>, <a href="https://vowpalwabbit.org/">Vowpal Wabbit</a>, <a href="https://dask.org/">Dask</a>, and <a href="https://vaex.readthedocs.io/en/latest/">Vaex</a>. However, these tools don’t fully embrace the online paradigm, and mostly still assume that you are working with a static dataset, albeit one that doesn’t fit in memory.</p><h3>Introducing the creme library</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/447/1*pcmgR0niQxWW-vrpnHhkvQ.png" /></figure><p>I discovered online machine learning some 15 months ago. Since then it’s been a bit of a revelation and I’ve been working hard to share my view. In order to do so, I started writing a Python library called <a href="https://github.com/creme-ml/creme">creme</a>. The name comes from <em>incremental learning</em>, which is a synonym for online learning. Next, some friends of mine joined me: <a href="https://github.com/gbolmier">Geoffrey Bolmier</a> (who is currently being payed to work on scikit-learn), <a href="https://github.com/raphaelsty">Raphaël Sourty</a>, <a href="https://github.com/VaysseRobin">Robin Vaysse</a>, and <a href="https://github.com/AdilZouitine">Adil Zouitine</a>. We’ve recently released version 0.5 and have started to see it being used in a few companies for proof of concepts.</p><p>creme is a general-purpose library, and as such covers many areas of machine learning, including feature extraction and model selection. <strong>You can think of creme as the scikit-learn of online machine learning</strong> — we realize how ambitious that may sound.</p><p>As a very simple introductory example, let’s say you want to compute the average of a sequence of values. The natural way to proceed is to accumulate all the values and divide the total by the number of values. However, there is an online algorithm which is exact and doesn’t even need to know the number of values before it starts. It’s called the <a href="http://www.nowozin.net/sebastian/blog/streaming-mean-and-variance-computation.html">West algorithm</a> and is trivial to implement. An online mean can be computed in creme as so:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/53c9daea20152b4979224e0e03d3e80a/href">https://medium.com/media/53c9daea20152b4979224e0e03d3e80a/href</a></iframe><p>Calculating a running average might not seem like much of as feat, but it opens the door to more advanced techniques such as target encoding:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c48248e3ebe438f8e9a96ff31a1f26f/href">https://medium.com/media/7c48248e3ebe438f8e9a96ff31a1f26f/href</a></iframe><p>You’ll notice in the previous snippet that TargetAgg has two methods: fit_one, which updates the model, and transform_one, which converts the input into features. In this case, TargetAgg has a transform_one method because it’s a transformer (duh). Other estimators, such as linear_model.LinearRegression, have methods fit_one and predict_one. Classifiers, such as tree.DecisionTreeClassifier, also have a predict_proba_one method.</p><p>The other thing to know with creme is that features are stored inside dictionaries. Dictionaries are practical because they are implicitely sparse: 0 values are simply not included in the dictionary. This allows to scale to large datasets with millions of features. Moreover, dictionaries do not have a fixed length, which means that <strong>creme models will function even if you add or remove features</strong>. Finally, using dictionaries means that each feature has a name, which is a human-friendly design. Note that we don’t use numpy or pandas, although creme supports both formats. Instead, we mostly rely on Python’s standard library, which provides great native support for working with dictionaries. As we will see later on, this doesn’t impact performance, quite the contrary in fact.</p><p>Now for the serious stuff: let’s train a classifier on a stream of data. As an example, we’ll use the <a href="http://archive.ics.uci.edu/ml/datasets/Website+Phishing">Website Phishing</a> dataset, which describes web pages and indicates if they are phishing attempts or not. We’ll use a logistic regression from the linear_model module. We’ll measure the performance of the model by using an instance of metrics.Accuracy, which, as you already have guessed, can be updated online.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/73f9111b7d14473ff1ed86b3c46aceb4/href">https://medium.com/media/73f9111b7d14473ff1ed86b3c46aceb4/href</a></iframe><p>As you can see in the above snippet, the prediction and learning steps are interleaved. In this case, we’re streaming over a dataset in sequential order, but you have full control on how to set this up. By using online machine learning, and in particular creme, you’re not hindered anymore by the fact that you need all the data at once in order to train a model. The other thing to notice is that we’ve used a pipeline to compose a standard scaling step with the logistic regression. <strong>Pipelines are a first-class citizen in creme</strong>, and we strongly encourage their use. You can check out our <a href="https://creme-ml.github.io/notebooks/the-art-of-using-pipelines.html">user guide</a> for more examples. In creme, pipelines have convenience methods such as model.draw() :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/144/1*P1QCG_tNBi8QsFxoOrkjyA.png" /><figcaption>Graph representation of the Website Phishing pipeline</figcaption></figure><p>Note that not all algorithms have an online equivalent. For instance, kernel SVMs are impossible to fit on a streaming dataset. Likewise, CART and ID3 decision trees can’t be trained online. However, lesser known online approximations exist, such as <a href="https://people.eecs.berkeley.edu/~brecht/papers/07.rah.rec.nips.pdf">random Fourier features</a> for SVMs and <a href="https://homes.cs.washington.edu/~pedrod/papers/kdd00.pdf">Hoeffding trees</a> for decision trees. creme has many things to offer, and we strongly encourage you to check out it’s <a href="https://github.com/creme-ml/creme">GitHub page</a> and the <a href="https://creme-ml.github.io/">online documentation</a>. Here are a few highlights:</p><ul><li>The reco module contains algorithms for recommender systems, much like <a href="https://github.com/NicolasHug/Surprise">surprise</a>, but online.</li><li>Time series forecasting, with the time_series module.</li><li>You can do online model selection with SuccessiveHalvingRegressor and SuccessiveHalvingClassifier from the model_selection module. We also have plans for integrating multi-armed bandit algorithms.</li><li>Online imbalanced learning.</li><li>Progressive validation, which is the online counterpart of cross-validation.</li><li>Decision trees and random forests.</li><li>Linear models with a wide array of optimizers.</li></ul><p>The main criticism of online learning is that it is slower than batch learning. Indeed, because the data is processed one element at time, we can’t make the most of vectorization. One solution is mini-batching, which is effectively a compromise between online learning and batch learning. However, with creme we have decided to only work with one element at a time because it is easier to reason about and drastically simplifies model deployment. Because of this design choice, <strong>creme is in fact much faster than scikit-learn, Keras, and Tensorflow in an online learning scenario</strong>. The following table summarizes the results for a linear regression implemented in different libraries:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/44d9163dd2241a7414626c5af94b8b8a/href">https://medium.com/media/44d9163dd2241a7414626c5af94b8b8a/href</a></iframe><p>You can find the code used to run the benchmarks <a href="https://github.com/creme-ml/creme/blob/master/benchmarks/Linear%20regression.ipynb">here</a>. This doesn’t mean that creme can process a dataset faster than other libraries, it means that creme is faster when the data is processed one element at a time. Other libraries cater to batch learning scenarios, not online learning. Depending on your data science experience, this might seem like a niche case. However, processing data in such a manner makes model deployment and maintenance a breeze in comparison with batch learning.</p><h3>Deployment</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*IFQ8RS4u_yX-l5Z4qStRHQ.png" /></figure><p>Once you’ve designed an online machine learning model, deploying it is relatively straightforward. Assuming that you want to interact with your model via web requests, then the API you have to implement is very simple. Essentially, you need a route to update the model, and another route to make predictions. You also might want to implement some routes to monitor the performance of the model. That’s really it: you don’t need to think about model retraining and worry about your model not being enough up-to-date. That’s the beauty of the lambda architecture. Treating your data as a stream brings many benefits to the table. On top of that, creme is a great fit because it consumes dictionaries, which easily translates to and from JSON, which is the <em>lingua franca</em> of APIs.</p><p>To demonstrate how simple it is to deploy a model built with creme, we’ve implemented a small tool called <a href="https://github.com/creme-ml/chantilly">chantilly</a>. This tool is nothing more than a Flask app which provides the necessary routes for uploading a model, making it learn, obtaining predictions, and monitoring metrics. It also provides a live dashboard which is currently very plain. chantilly is still in it’s infancy, and we have <a href="https://github.com/creme-ml/chantilly#roadmap">plans</a> to make it even more enjoyable and simple to use.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgfycat.com%2Fifr%2Fvacantclumsyhousefly&amp;display_name=Gfycat&amp;url=https%3A%2F%2Fgfycat.com%2Fvacantclumsyhousefly&amp;image=https%3A%2F%2Fthumbs.gfycat.com%2FVacantClumsyHousefly-size_restricted.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=gfycat" width="600" height="370" frameborder="0" scrolling="no"><a href="https://medium.com/media/4abb9cf4d25ddf7206c5c379fad3dd14/href">https://medium.com/media/4abb9cf4d25ddf7206c5c379fad3dd14/href</a></iframe><p>The chantilly repository contains an <a href="https://github.com/creme-ml/chantilly/tree/master/examples/taxis">example</a> based on the New York City taxis dataset. The dataset contrains taxi trips details along with their duration. The goal is to predict how long the trip will take. In a nutshell, we are able to take this historical dataset and simulate a stream of events in exactly the same way as it happened. Therefore we are able to establish a trustworthy benchmark and a reliable idea of our model would have performed. This is very important: being able to correctly reproduce a production scenario helps to build trust in your model. With batch models you’re never quite sure how your model is going to perform. Sure you can do cross-validation, but it isn’t exactly mimicking a production scenario locally.</p><p>Note that we don’t intend for chantilly to be a one-size-fits-all tool. We realize that every data science team has it’s own particular way of doing model deployment. Therefore, chantilly is mostly intended to be a simple and readable example of how to implement the lamda architecture for machine learning models. Nonetheless, we will keep working on chantilly and provide ways to co-operate with existing infrastucture. For instance, chantilly currently provides a streaming API to monitor metric updates. This allows you to write a short script to send these updates to, say, an InfluxDB database which is connected to your Grafana dashboard.</p><h3>Going further</h3><p>creme is a young library, and yet we’re already getting some great feedback from data science teams who are using it for proof of concepts. Here are the key take-aways:</p><ul><li>Online models can learn with one instance at a time.</li><li>Online models do not have be retrained, as they learn on the fly.</li><li>Online machine learning simplifies model deployment and maintenance.</li></ul><p>If you want to know more about creme, we encourage you to check out the <a href="https://github.com/creme-ml/creme">GitHub repository</a> as well the <a href="https://creme-ml.github.io/content/user-guide.html">user guides</a> and the <a href="https://creme-ml.github.io/content/api.html">API reference</a>. <a href="https://github.com/creme-ml/creme/stargazers">Starring us on GitHub</a> also helps us gain exposure to a wider audience.</p><p>We’re very interested in onboarding new contributors. If creme has peaked your interest and you want to be part of the team, then feel welcome to get in touch!</p><p>We’re also happy to (freely) work hand-in-hand with data science teams to see if creme suits your needs, and in what ways we can improve it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dacf5fb469df" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/machine-learning-for-streaming-data-with-creme-dacf5fb469df">Machine learning for streaming data with creme</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>