<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Julien Kervizic</title>
    <description>The latest articles on Forem by Julien Kervizic (@julienkervizic).</description>
    <link>https://forem.com/julienkervizic</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F204174%2Fda7c2063-bda3-4ab5-8bad-de913803d5ac.jpg</url>
      <title>Forem: Julien Kervizic</title>
      <link>https://forem.com/julienkervizic</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/julienkervizic"/>
    <language>en</language>
    <item>
      <title>Azure Message Brokers patterns for Data Applications</title>
      <dc:creator>Julien Kervizic</dc:creator>
      <pubDate>Tue, 24 Sep 2019 19:19:05 +0000</pubDate>
      <link>https://forem.com/julienkervizic/azure-message-brokers-patterns-for-data-applications-1din</link>
      <guid>https://forem.com/julienkervizic/azure-message-brokers-patterns-for-data-applications-1din</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F0%2AK8LFtGiFSRF2m8Jj" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F0%2AK8LFtGiFSRF2m8Jj"&gt;&lt;/a&gt;Photo by &lt;a href="https://unsplash.com/@adeolueletu?utm_source=medium&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Adeolu Eletu&lt;/a&gt; on &lt;a href="https://unsplash.com?utm_source=medium&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I have previously written how pub/sub patterns could be helpful to put &lt;a href="https://medium.com/analytics-and-data/overview-of-the-different-approaches-to-putting-machinelearning-ml-models-in-production-c699b34abf86#d6d6" rel="noopener noreferrer"&gt;machine learning models into production&lt;/a&gt;, but message brokers in data application has a wider use than just Machine Learning. On Azure, there is two main messages brokers, Service Bus and Event Hub. Knowing what these message brokers can do, how they should be used for developing data applications and which ones are more suitable for a certain type of use case is primordial in order to get the most out of them.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Service bus and Event Hub&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;According to the Azure &lt;a href="https://docs.microsoft.com/en-us/azure/event-grid/compare-messaging-services#comparison-of-services" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;, service bus is meant for high value messaging while Event hub is meant for big data pipelines. Now, both message brokers service have a use in analytics applications, but the key is to understand the specificities of each system.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Service-Bus&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Some of the key feature from Service Bus include, include duplicate detection, transaction processing and routing.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Duplicate detection:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Service Bus checks the particular MessageId for topics having the “requiresDuplicateDetection” property set to true.&lt;/p&gt;

&lt;p&gt;It looks back the history of messages that have passed through the topic based on a duplicateDetectionHistoryTimeWindow. An example ARM template would incorporate the deduplication mechanism is shown below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "$schema": "[https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#](https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#)",
  "contentVersion": "1.0.0.0",
  "parameters": {
  },
  "variables": { },
  "resources": [
    {
      "apiVersion": "2017-04-01",
      "name": "my\_sb\_namespace",
      "type": "Microsoft.ServiceBus/namespaces",
      "location": "West Europe",
      "properties": {
      },
      "resources": [
        {
          "apiVersion": "2017-04-01",
          "name": "my\_serviceBusTopicName",
          "type": "topics",
          "dependsOn": [
            "[concat('Microsoft.ServiceBus/namespaces/', 'my\_sb\_namespace')]"
          ],
          "properties": {
            **"requiresDuplicateDetection": "true",  
            "duplicateDetectionHistoryTimeWindow": "PT10M",**"path": "my\_serviceBusTopicName",
            "lockDuration": "PT5M",
          },
          "resources": []
        }
      ]
    }
  ],
  "outputs": {}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This property of service bus can be for instance leveraged in application capturing orders information from tracking script and wanting to ensure that no duplicate information is flowing in downstream systems from occurrences such as a page refresh on a thank you page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F709%2F1%2A8nZUuFklFkJvCs1X_v40Uw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F709%2F1%2A8nZUuFklFkJvCs1X_v40Uw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One example of this type of application is shown above:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A tracking script generates an http call to an API end point&lt;/li&gt;
&lt;li&gt;The API pushes the message to a Service bus topic with duplicate detection enabled&lt;/li&gt;
&lt;li&gt;An analytics ingestor application, reads the messages in a topic subscription and pushes the data to Google Analytics using the &lt;a href="https://medium.com/analytics-and-data/the-complexity-of-implementing-google-analytics-22b3061248e6#a784" rel="noopener noreferrer"&gt;measurement protocol&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  &lt;strong&gt;Peek / Lock:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Azure Service Bus offers two way to handle messages, one destructive on every message read, one non-destructive using a peek /lock mechanism.&lt;/p&gt;

&lt;p&gt;Setting up the non-destructive read, only requires setting up one parameter in the receiving function:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;The peek / lock mechanism allows to implement &lt;strong&gt;transactions&lt;/strong&gt; using ASB. Messages can be deleted on success and otherwise can be either abandoned explicitly or through the lock time expiring. Abandoning the message, allows for it to be put back into the queue for further processing attempts.&lt;/p&gt;

&lt;p&gt;Being able to handle transactions mechanism is particularly important, when dealing with issue of compliance, such as revenue recognition, or that have a direct downstream impact for example a request for delivery of inventory that needs to be planned.&lt;/p&gt;

&lt;p&gt;Both the lock and destructive read mechanism, enable &lt;strong&gt;receiver scaling&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F696%2F1%2Ay47yR2Y6FPJruFRqkGNnqA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F696%2F1%2Ay47yR2Y6FPJruFRqkGNnqA.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the example above, each receiver are locking a set of messages. When that happens the messages become invisible to the other receivers. This type of mechanism allows for scaling the downstream ingestion of the messages without the risk of ingesting the same message multiple times.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Routing:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Routing is enabled using &lt;a href="https://docs.microsoft.com/en-us/azure/service-bus-messaging/topic-filters" rel="noopener noreferrer"&gt;topic filters&lt;/a&gt; rules on subscription. There are three kind of potential filters that can be applied to subscription, boolean, sql and correlation filters. These can leverage the data present in system and (customer) user properties.&lt;/p&gt;

&lt;p&gt;For instance, if I wanted to filter only the messages intended on a specific topic by country, and {‘country’: ‘GB’} had been set in the message custom properties, the following azure command line command would create the necessary filter on the subscription.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;az servicebus topic subscription rule create \
  --resource-group ${AZURE\_RESOURCE\_GROUP}\
  --namespace-name ${SB\_NAMESPACE\_NAME} \
  --topic-name ${TOPIC\_NAME} \
  --subscription-name ${SUBSCRIPTION\_NAME}\
  --name ${FILTER\_NAME}\
  --filter-sql-expression "user.country='${COUNTRY}'"'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An example of how this kind of routing mechanism could be useful is described below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F838%2F1%2AKJFuoZ8aBJZ4kiPpMahixw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F838%2F1%2AKJFuoZ8aBJZ4kiPpMahixw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A churn scoring applications could publish messages to a service bus topic, containing two subscriptions, one that would only consider customers likely to churn and one generic that would contain all customers. Based on these topic subscriptions two applications could then naively consume the message, one for instance to trigger a retention campaign, the other to simply update the score of every consumer in the database.&lt;/p&gt;

&lt;h3&gt;
  
  
  EventHub
&lt;/h3&gt;

&lt;p&gt;EventHub is known for its low latency and high scalability, making it particularly well suited to handle real-time data and big data. Lesser known are its replay and data capture functionalities as well as its Kafka integration.&lt;/p&gt;

&lt;h4&gt;
  
  
  Partition ownership and Checkpoints
&lt;/h4&gt;

&lt;p&gt;While Azure Service Bus uses the concept of message locks to handle being able to use multiple consumers, Azure Event Hub relies on the concept of partition ownership.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F770%2F1%2A0JecxSet59biSg-f321KdA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F770%2F1%2A0JecxSet59biSg-f321KdA.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Partitions for a given consumer group get assigned to a receiver application for processing purpose. In the example above the receiver application get assigned partition 1 and 2, while the receiver application 2, gets assigned partitions 3 and 4. It is best practice to only have one active receiver application by consumer group / partition.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F799%2F1%2AWcj6uPy_YK61KvVdAnPHaw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F799%2F1%2AWcj6uPy_YK61KvVdAnPHaw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Instead of locks and deletion, event hub uses the concept of check-points to understand what event have been processed. Once the events have been processed, the position of the event across (ingestion) time is check-pointed within a partition, to indicate that the receiver should process the messages from this point onward.&lt;/p&gt;

&lt;p&gt;Since the events are kept within the EventHub for the duration of the retention period, this approach makes it possible to “replay” the data. This can be useful, when needing to train Machine Learning models and see how they behave on &lt;a href="https://medium.com/streaming-at-scale-in-azure/streaming-at-scale-with-event-hub-capture-79c30fb9f3e5#d6b6" rel="noopener noreferrer"&gt;past historical data&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Data Ingestion
&lt;/h4&gt;

&lt;p&gt;EventHub offers the possibility to export the ingested data directly onto a blog storage or Azure Data Lake directly, through its’ &lt;a href="https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-capture-overview" rel="noopener noreferrer"&gt;capture&lt;/a&gt; functionality.&lt;/p&gt;

&lt;p&gt;Once in a Data Lake/Blob Storage , you can leverage &lt;a href="https://docs.microsoft.com/en-us/azure/data-lake-analytics/data-lake-analytics-u-sql-get-started" rel="noopener noreferrer"&gt;Azure Data Lake Analytics&lt;/a&gt;, or computation engines such as &lt;a href="https://medium.com/@ArsenVlad/presto-querying-data-in-azure-blob-storage-and-azure-data-lake-store-99149c8c796" rel="noopener noreferrer"&gt;Presto&lt;/a&gt; or &lt;a href="https://medium.com/streaming-at-scale-in-azure/apache-drill-azure-blobs-and-azure-stream-analytics-ef34a1360d2b" rel="noopener noreferrer"&gt;Apache Drill&lt;/a&gt; to directly query this data.&lt;/p&gt;

&lt;h4&gt;
  
  
  Kafka
&lt;/h4&gt;

&lt;p&gt;Event hub offers a &lt;a href="https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-for-kafka-ecosystem-overview" rel="noopener noreferrer"&gt;Kafka interface&lt;/a&gt;, this notably enables an integration with Apache Spark. Spark offers a &lt;a href="https://spark.apache.org/docs/latest/streaming-programming-guide.html" rel="noopener noreferrer"&gt;straight-forward&lt;/a&gt; way to deal with streams, and notably offers a way to perform &lt;a href="https://spark.apache.org/docs/latest/streaming-programming-guide.html#window-operations" rel="noopener noreferrer"&gt;windowed operations&lt;/a&gt;, this is particularly useful in doing &lt;strong&gt;real-time aggregations&lt;/strong&gt;. The following &lt;a href="https://databricks.com/blog/2017/05/08/event-time-aggregation-watermarking-apache-sparks-structured-streaming.html" rel="noopener noreferrer"&gt;post from data-bricks&lt;/a&gt;, explains how this time aggregation works.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.linkedin.com/in/julienkervizic/" rel="noopener noreferrer"&gt;Julien Kervizic - Senior Enterprise Data Architect - GrandVision NV | LinkedIn&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;More from me on &lt;a href="https://medium.com/analytics-and-data" rel="noopener noreferrer"&gt;Hacking Analytics&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://medium.com/analytics-and-data/on-the-evolution-of-data-engineering-c5e56d273e37" rel="noopener noreferrer"&gt;ON the evolution of Data Engineering&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/analytics-and-data/overview-of-the-different-approaches-to-putting-machinelearning-ml-models-in-production-c699b34abf86" rel="noopener noreferrer"&gt;Overview of the different approaches to putting Machine Learning (ML) models in production&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/analytics-and-data/setting-up-airflow-on-azure-connecting-to-ms-sql-server-8c06784a7e2b" rel="noopener noreferrer"&gt;Setting up Airflow on Azure &amp;amp; connecting to MS SQL Server&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/analytics-and-data/overview-of-efficiency-concepts-in-big-data-engineering-418995f5f992" rel="noopener noreferrer"&gt;Overview of efficiency concepts in Big Data Engineering&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




</description>
      <category>datascience</category>
      <category>dataengineering</category>
      <category>bigdata</category>
      <category>azure</category>
    </item>
    <item>
      <title>ON the evolution of Data Engineering</title>
      <dc:creator>Julien Kervizic</dc:creator>
      <pubDate>Tue, 30 Jul 2019 21:40:30 +0000</pubDate>
      <link>https://forem.com/julienkervizic/on-the-evolution-of-data-engineering-51hk</link>
      <guid>https://forem.com/julienkervizic/on-the-evolution-of-data-engineering-51hk</guid>
      <description>&lt;p&gt;A few years ago being a data engineer meant managing data in and out of a database, creating pipelines in SQL or Procedural SQL and doing some form of ETL to load data in a data-warehouse, creating data-structures to unify, standardize and (de)normalize datasets for analytical purpose in a non-realtime manner. Some companies were adding to that a more front facing business components that involved building analytic cubes and dashboard for business users.&lt;/p&gt;

&lt;p&gt;In 2018 and beyond the role and scope of the data engineers has changed quite drastically. The emergence of data products has created a gap to fill which required a mix of skills not traditionally embedded within typical development teams, the more Software Development Oriented data engineers and the more data oriented Backend Engineers were in a prime role to fill this gap.&lt;/p&gt;

&lt;p&gt;This evolution was facilitated by a growing number of technologies that helped to bridge the gap both for those of Data Engineering and those of a more Backend Engineering background.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8pPWXcm0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/1400/1%2A8cv0TDr2AgJRlPZOlT6vig.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8pPWXcm0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/1400/1%2A8cv0TDr2AgJRlPZOlT6vig.jpeg" alt=""&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Big Data&lt;/strong&gt;: The emergence of Big Data and the associated technologies that can with it drastically changed the data landscape with Hadoop open-sourced in 2006, it became easier and cheaper to store large amount of data, Hadoop unlike traditional RDBMS databases did not require a lot of structuring in order to be able to process the data. The complexity to develop on Hadoop was initially quite high, requiring the development of Map Reduce jobs in Java. The challenges of processing big data forced the emergence of Backend Engineers working on analytical data workflow. It was not until Hive was open sourced in 2010 that the more traditional data engineers could get an easy bridge to get on boarded in this era of Big data.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HG1iY75H--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/1400/0%2AwpCdSbrSFvmHbMT_" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HG1iY75H--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/1400/0%2AwpCdSbrSFvmHbMT_" alt=""&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Data Orchestration Engines&lt;/strong&gt;: With the development of Big data, large internet companies were faced with a challenge to operate complex data flow without any tools such as SSIS used for more traditional RDBMS working in this ecosystem. Spotify opened sourced Luigi in 2012 and Airbnb Airflow (inspired by a similar system at facebook) in 2015. Coming from a heavy engineering driven background, these orchestration engines were essentially data-flows as code.&lt;/p&gt;

&lt;p&gt;Python being the language most of these orchestration engine were built on helped them gain ground benefiting based on the traction in the PyData ecosystem and from the increase use of python among Production engineers. Traditional Data Engineers coming into this ecosystem needed to adapt and up-skill in software engineering.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yOsSf3Y4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/r7afxqsi92vxgkndt0yj.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yOsSf3Y4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/r7afxqsi92vxgkndt0yj.jpeg" alt=""&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Machine Learning&lt;/strong&gt;: The trove of data that was now possible to collect from the internet, Machine learning quickly gained traction. Until the advent of Hadoop, Machine Learning models were usually trained on a single machine and usually applied on a very ad-hoc manner. For large internet companies, in the early days of Hadoop leverage machine learning models required some advanced software development knowledge in order to train and apply models into production, with the use of frameworks such as Mahout leveraging upon MapReduce.&lt;/p&gt;

&lt;p&gt;Some Backend engineers started to specialize in this area to become Machine Learning Engineers, very production focused Data Scientists. For a lot of startup this kind of development was however overkill. Improvement in SKLearn, a python project open started in 2007, and the popularization of orchestration engine made it fairly easy to go from a proof of concept by a Data Scientist to production ready workflows by Data Engineers for moderately sized datasets.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_6b-ZnHU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/2ybocd9kj9xirdhgh30f.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_6b-ZnHU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/2ybocd9kj9xirdhgh30f.jpeg" alt=""&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Spark &amp;amp; Real-time&lt;/strong&gt;: It was the release of Spark’s MLlib for python in 2014, that democratized machine learning computation on Big data. The API was fairly similar to the one Data-scientists were used to from the PyData ecosystem and further development of Spark further helped bridged the gap. Spark further offered a way for data engineers to easily process streaming data, offering a window towards real-time processing. Spark enabled an increased contribution of data engineers towards data products.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CUUL6bF---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/bw3bwp3tl8t688huk0g7.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CUUL6bF---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/bw3bwp3tl8t688huk0g7.jpeg" alt=""&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Cloud development &amp;amp; Serverless&lt;/strong&gt;: AWS was officially launched in 2006, its storage layer S3 had been built upon Hadoop the traditional big data platform. Elastic Map Reduce was launched in 2009 making it easier to dynamically spin up and scale Hadoop clusters for processing purpose.&lt;/p&gt;

&lt;p&gt;The move to the cloud had multiple implication for data engineers. The cloud abstracted physical limitations, for most users it meant that storage and compute was essentially infinite provided one can pay for it. Optimization previously done to keep business running waiting for new servers to be installed or upgraded needed not to be done anymore. So was the work previously done tasks scheduling to allocate the load across time due to ressource constraint. The cloud by allowing for scaling up and down ressources made it much easier to handle high peak batch jobs typical in data engineering. This however came at the cost of having to manage infrastructure and the scaling process through code.&lt;/p&gt;

&lt;p&gt;The introduction of Lambda function on AWS in late 2014 kicked off the serverless movement. From a data perspective data could be easily ingested without managing infrastructure. The release Athena launching in late 2016 pushed things further allowing to query directly onto s3 without the need to setup a cluster. This is freeing data engineers from managing infrastructure scaling based on requests allowing them to spend more time on development.&lt;/p&gt;




&lt;p&gt;The role of the data engineer is no longer to just provide support for analytics purpose but to be the owner of data-flows and to be able to serve data both to production and for analytics purpose.&lt;/p&gt;

&lt;p&gt;To that end Data Engineering has been looking more towards a software engineering perspective. Maxime Beauchemin’s post on functional data engineering advocates advocates for borrowing patterns of functional programming and apply them to data engineering. The emerging data ops movement and its manifesto in turn borrows from the DevOps movement in software engineering.&lt;/p&gt;

</description>
      <category>data</category>
      <category>dataengineering</category>
      <category>etl</category>
      <category>sql</category>
    </item>
    <item>
      <title>CDPs and DMPs a story of Advertising platforms</title>
      <dc:creator>Julien Kervizic</dc:creator>
      <pubDate>Fri, 19 Jul 2019 06:25:55 +0000</pubDate>
      <link>https://forem.com/julienkervizic/cdps-and-dmps-a-story-of-advertising-platforms-4kl3</link>
      <guid>https://forem.com/julienkervizic/cdps-and-dmps-a-story-of-advertising-platforms-4kl3</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2Afnr80MmoEuZNQJPtsJzfjA.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2Afnr80MmoEuZNQJPtsJzfjA.jpeg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Customer Data Platform and Data Management platforms are some of the components of a data driven, marketing technology stack. They provide tools for marketers to effectively target different segment of the population.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Customer Data Platform (CDP)&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The Customer data platform is meant as a data store for all internal attributes and events related to a given customer. It is meant to provide a way to unify data across multiple data source, with potentially different types of customer identifiers and as such needs to offer a way to resolve identities.&lt;/p&gt;

&lt;h4&gt;
  
  
  Use cases for a CDP:
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Single Source of Truth:&lt;/strong&gt; The aim of the customer platform is to act as the single source of truth for customer data, offering a 360 degree views of customer behavior across the different touch point and identities.&lt;/p&gt;

&lt;p&gt;It enables to also structure and standardize the inputs and data models of customers, for instance with mParticle’s &lt;a href="https://docs.mparticle.com/developers/server/json-reference/#commerce_event" rel="noopener noreferrer"&gt;commerce events&lt;/a&gt; which structure different product action onto the same schema. Beside the standardization component, part of the CDP’s role during the data integration phase is also to provide better data quality by cleansing and de-duping the data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Advertising:&lt;/strong&gt; Since CDPs are able to collect data from the different touch points of customer interactions and resolving their identities. It is also able to harmonize the communication towards the customers across the different communication channels.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Empower Personalization:&lt;/strong&gt; &lt;a href="https://medium.com/analytics-and-data/principles-of-e-commerce-personalization-4feb6de4b6e" rel="noopener noreferrer"&gt;Personalization&lt;/a&gt; can be empowered to the highest level by the use of a customer data platform. Customer data platforms allows for the creation and utilization of data from a merged identity, through means of a) &lt;a href="https://community.tealiumiq.com/t5/Tealium-API/Visitor-Lookup-API/ta-p/22859#toc-hId-1330156159" rel="noopener noreferrer"&gt;Attribute retrieval&lt;/a&gt; b) &lt;a href="https://www.qubit.com/customer-segmentation/" rel="noopener noreferrer"&gt;segment creation&lt;/a&gt; c) &lt;a href="https://relay42.com/resources/blog/optimising-customer-journeys-with-ai" rel="noopener noreferrer"&gt;machine learning score&lt;/a&gt;. These data points can then be used to power advertising campaigns, website recommendation or to empower personalization across the full user journey.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ease Integration:&lt;/strong&gt; One of the role of customer data platforms is to facilitate the integration of different datasources both inbound or outbound. The customer data platform needs to be able to integrate data sources such as web analytics, e-commerce data, email behavior and export to the different end points that can make use of the data such as advertising platform, marketing automation tools or a data warehouse.&lt;/p&gt;

&lt;h4&gt;
  
  
  List of CDPs
&lt;/h4&gt;

&lt;p&gt;There exists quite a large list of CDP vendors out there, usually each with a different focus.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CDPs originating from a&lt;a href="https://medium.com/analytics-and-data/tealiumiq-tms-3195095cab66" rel="noopener noreferrer"&gt;&lt;/a&gt; &lt;strong&gt;Tag Management systems&lt;/strong&gt; provider such as &lt;a href="https://medium.com/analytics-and-data/tealiumiq-tms-3195095cab66" rel="noopener noreferrer"&gt;Tealium&lt;/a&gt;, or &lt;a href="https://medium.com/analytics-and-data/google-analytics-with-ensighten-tms-cd7e1933fc89" rel="noopener noreferrer"&gt;Ensighten&lt;/a&gt;. These systems tend to have pivoted into Customer Profile by leveraging their common data model used for tag integration.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pure Play Oriented:&lt;/strong&gt; such as &lt;a href="https://segment.com" rel="noopener noreferrer"&gt;&lt;em&gt;Segment&lt;/em&gt;&lt;/a&gt;&lt;em&gt;,&lt;/em&gt; one of the few CDP offering a free developer trial version, &lt;a href="https://www.mparticle.com/" rel="noopener noreferrer"&gt;&lt;em&gt;mParticle&lt;/em&gt;&lt;/a&gt;&lt;em&gt;, a&lt;/em&gt; CDP focused on providing data integration, offering an unified data model, ingesting different types of events such as commerce events onto a common data model and exporting it to different end-points.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Campaign Management Oriented:&lt;/strong&gt; &lt;a href="https://www.lytics.com/" rel="noopener noreferrer"&gt;Lytics&lt;/a&gt; is a CDP with a strong focused on campaign management, customer journeys and of enrichment of profile from 2nd party data , &lt;a href="https://www.agile-one.com/" rel="noopener noreferrer"&gt;&lt;em&gt;Agile One&lt;/em&gt;&lt;/a&gt; &lt;em&gt;a&lt;/em&gt; CDP with both campaigns and analytics capabilities or &lt;a href="https://www.sessionm.com/" rel="noopener noreferrer"&gt;&lt;em&gt;SessionM&lt;/em&gt;&lt;/a&gt; a CDP focused on providing loyalty management as part of their offering.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Personalization Oriented:&lt;/strong&gt; &lt;a href="https://qubit.com" rel="noopener noreferrer"&gt;&lt;em&gt;Qubit&lt;/em&gt;&lt;/a&gt;&lt;em&gt;,&lt;/em&gt; although it does not sell itself as a CDP, but rather as a personalization platform, it shares a number of functionalities with them, such as an ability to deduplicate customers across identities, storing of data at user level, ability to segment audiences and some possibilities for integration with other platforms (eg: Salesforce Marketing Cloud).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Open Source:&lt;/strong&gt; &lt;a href="https://unomi.apache.org/" rel="noopener noreferrer"&gt;&lt;em&gt;Unomi&lt;/em&gt;&lt;/a&gt; is an open source CDP, some of its draw back being the lack of UI, the need to have to host it and the lack of an extensive integration ecosystem.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Caveats&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Seeing a CDP as a golden records for Customer needs to be taken with a certain grain of salt, ingested data is usually persisted with attributes, for instance product information is usually persisted at the same time as the events triggered. The backend of most CDPs don’t usually allow for the kind of merging activities necessary to maintain dimensions such as a product category dimension.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Data Management Platform (DMP)&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;What’s the purpose of a DMP — the purpose of a data management platform is the collection, enrichment of data and management of data for digital marketing purpose. One of the main value from a DMP is the ability to provide a consistent experience across different marketing channels.&lt;/p&gt;

&lt;h4&gt;
  
  
  Data collection and enrichment:
&lt;/h4&gt;

&lt;p&gt;The DMP collects data from a clients’ first party sources, for instance from the users visiting its websites. From second party sources, ie: data that is obtained through collaboration, this could be targeting settings for a Facebook campaign that can be identified when a user visit the website, and from third party sources, data that is obtained from other activities.&lt;/p&gt;

&lt;p&gt;At the heart of the DMP is the notion of an anonymous user identity, typically identified through cookie ids, these cookies can be matched through rule base systems or through probabilistic matching.&lt;/p&gt;

&lt;h4&gt;
  
  
  Use cases for a DMP:
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Advertising&lt;/strong&gt; : The main purpose of DMPs is to offer a a cohesive audience targeting. This is done through segment building and the creation of different segments for different type of personas. DMPs typically provide different type of segments:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Static Segments:&lt;/strong&gt; Segments are run once based on a snapshot of a visitors’ attributes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Adaptive Segments:&lt;/strong&gt; Segments are constantly being updated based on the data being provided to the platform. For instance an adaptive segment can be “website visitors 30days”&lt;/li&gt;
&lt;li&gt;Segments obtained from Machine Learning models for &lt;strong&gt;Lookalike modeling&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These segments can then be exported to DSPs or other activation channels.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Audience Insight&lt;/strong&gt; : DMPs also provide insights on the behavioral patterns of your customers, as well as learn more about who your customers are by leveraging informations provided by third parties.&lt;/p&gt;

&lt;h4&gt;
  
  
  List of DMP
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.salesforce.com/products/marketing-cloud/data-management/" rel="noopener noreferrer"&gt;&lt;em&gt;Salesforce DMP&lt;/em&gt;&lt;/a&gt; (Krux): Salesforce integrated Krux as part of their marketing cloud platform, offering a way to target “unknown” visitors on your websites, and enhance the information, you have on them with third party data.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.adobe.com/analytics/audience-manager.html" rel="noopener noreferrer"&gt;&lt;em&gt;Adobe Audience manager&lt;/em&gt;&lt;/a&gt;: is Adobe’s DMP, well integrated into adobe marketing cloud, it enables marketeers to get a better grasps of the different audience segments, interacting with their ads or the website.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.mediamath.com/" rel="noopener noreferrer"&gt;&lt;em&gt;Mediamath&lt;/em&gt;&lt;/a&gt;: an independent adtech vendor in between a DMP and a DSP solution, benefiting from over $600M of funding.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.oracle.com/marketingcloud/products/data-management-platform/" rel="noopener noreferrer"&gt;Oracle BlueKai&lt;/a&gt;: Oracle’s DMP with a heavy data enrichment slant, it boast overs 200 media partners.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Wrap up
&lt;/h3&gt;

&lt;p&gt;At their core, CDPs and DMPs have an overlap in functionalities, but also some difference, which mostly resolve from their treatment of identity. CDPs also have an overlap in functionality with other systems such as Tag Management, Master Data Management and Marketing Automation tooling.&lt;/p&gt;




</description>
      <category>datamanagement</category>
      <category>programmatic</category>
      <category>analytics</category>
      <category>data</category>
    </item>
    <item>
      <title>How to collect the data you need to bootstrap your digital marketing analytics</title>
      <dc:creator>Julien Kervizic</dc:creator>
      <pubDate>Mon, 20 May 2019 19:51:16 +0000</pubDate>
      <link>https://forem.com/julienkervizic/how-to-collect-the-data-you-need-to-bootstrap-your-digital-marketing-analytics-hhm</link>
      <guid>https://forem.com/julienkervizic/how-to-collect-the-data-you-need-to-bootstrap-your-digital-marketing-analytics-hhm</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GZWB9bse--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2AZxBcyOPlfApyfJT6" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GZWB9bse--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2AZxBcyOPlfApyfJT6" alt=""&gt;&lt;/a&gt;Photo by &lt;a href="https://unsplash.com/@campaign_creators?utm_source=medium&amp;amp;utm_medium=referral"&gt;Campaign Creators&lt;/a&gt; on &lt;a href="https://unsplash.com?utm_source=medium&amp;amp;utm_medium=referral"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To a large extent boot-strapping your marketing activities with data, resolves around the collection of data of two or three specific domains depending on the scope of your business.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;Campaign Activity&lt;/em&gt;&lt;/strong&gt; : Be it from Digital Marketing, pushing ads such as Facebook or Google ads, or more through email service providers/marketing automation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;Clickstreams:&lt;/em&gt;&lt;/strong&gt; Provides an understanding of the customer journey on site and the different factors that contributed to a conversion. Leveraging clickstream data allows to be able to properly attribute conversion to specific campaigns.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;Sales:&lt;/em&gt;&lt;/strong&gt; Digital Marketing for e-commerce websites revolves around generating online sales. These should be tracked and the campaign spend should be optimized against this objective.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Use Cases
&lt;/h3&gt;

&lt;p&gt;There are quite a few use cases around marketing analytics, but we can easily show how these data sources of Campaign Activity, Clickstreams and Ecommerce sales can drive some of the biggest marketing analytics use cases such as media-mix modelling, marketing attribution and churn prevention.&lt;/p&gt;

&lt;h4&gt;
  
  
  Media-Mix Modeling
&lt;/h4&gt;

&lt;p&gt;Media-mix modeling (MMM) allows to get an understanding of how to shift your budget mix among different advertising channels to optimize your outcome. It relies on statistics techniques to understand where 1 unit of marginal spend would be best placed.&lt;/p&gt;

&lt;p&gt;MMM relies on two specific source of information 1. Spend data (Campaign) 2. an Outcome data (Eg: Ecommerce Sales), that we want to optimize for. In Order to be effective it is important for MMM to have a view of all the different channel spend contributing to the outcome.&lt;/p&gt;

&lt;h4&gt;
  
  
  Marketing Attribution
&lt;/h4&gt;

&lt;p&gt;Marketing attribution role is to assign credit to specific marketing campaign, to get a better sense of their contribution to a specific objective. Attribution methods such as “last click”, provide full credit to a specific campaign when an objective is reached, in this case it provides the full credit of a campaign to the last touchpoint having contributed to the said objective, while other techniques can partial credit. Explanation of different attribution techniques are provided in the following medium posts: &lt;a href="https://medium.com/@odolenakostova/online-attribution-in-a-multi-channel-marketing-world-d2141f08f9d6"&gt;here&lt;/a&gt; and &lt;a href="https://medium.com/analytics-for-humans/an-in-depth-look-at-attribution-modeling-in-digital-marketing-2ed0170c6f3b"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Marketing attribution relies on Campaign Data (Spend), Clickstream information and Sales data in order to properly attribute Campaign activities. Along with setting up the different systems to collect the information, proper url tagging (UTM) and potentially setting up the right Cookies on the websites are necessary first step to enable this use case.&lt;/p&gt;

&lt;h4&gt;
  
  
  Churn Prevention
&lt;/h4&gt;

&lt;p&gt;Churn identification and prevention is one of the most traditional CRM use cases. It leverages upon Sales and Campaign data (CRM) to get a better understanding as to what customers are likely to churn and to what offer they would tend to respond to in order to stick with the service offering.&lt;/p&gt;

&lt;h3&gt;
  
  
  Data Collection
&lt;/h3&gt;

&lt;p&gt;In general one of the hardest part of empowering Marketing Analytics is the ability to source the data. It requires information to be pulled from a variety of sources. Depending on the specific of the Business trying to kick-start this use-case there can be a variety of applicable ways to integrate each of the data sources required.&lt;/p&gt;

&lt;h3&gt;
  
  
  Campaigns data collection
&lt;/h3&gt;

&lt;p&gt;There exists quite a few way to integrate and collect campaign data, from using specific data integration solutions, to leveraging singers taps, using the different tools built in data export capabilities or through building specific API pipelines.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Data Integration solutions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Different tools exists to simplify the collection of data from marketing campaigns, &lt;a href="http://talend.com"&gt;Talend&lt;/a&gt;, &lt;a href="http://www.adverity.com"&gt;Adverity&lt;/a&gt;, &lt;a href="http://fivetran.com"&gt;Fivetran&lt;/a&gt; and &lt;a href="https://www.alooma.com/integrations"&gt;Alooma&lt;/a&gt; (recently acquired by Google) provide a series of connectors that make data integration from these different ad-sources fairly easy.&lt;/p&gt;

&lt;h4&gt;
  
  
  Singer Taps
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hvs0BEwn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2AhqorE7mNxyPOJD0_" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hvs0BEwn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2AhqorE7mNxyPOJD0_" alt=""&gt;&lt;/a&gt;Photo by &lt;a href="https://unsplash.com/@arstyy?utm_source=medium&amp;amp;utm_medium=referral"&gt;Austin Neill&lt;/a&gt; on &lt;a href="https://unsplash.com?utm_source=medium&amp;amp;utm_medium=referral"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.singer.io/#taps"&gt;Singer taps&lt;/a&gt; provides open-source pre-built connectors to a series of advertising sources such Facebook, Google, Outbrain, Salesforce, Marketo, Selligent,.. The data from these sources can be then be easily fetched by only modifying some configuration settings and executing a command line call, for instance&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tap-adwords -c config.json -p properties.json -s state.json
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  &lt;strong&gt;Data Exports&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OIbjgc8f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2A5u5Yc2AVP6D_uBRS" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OIbjgc8f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2A5u5Yc2AVP6D_uBRS" alt=""&gt;&lt;/a&gt;Photo by &lt;a href="https://unsplash.com/@chuttersnap?utm_source=medium&amp;amp;utm_medium=referral"&gt;chuttersnap&lt;/a&gt; on &lt;a href="https://unsplash.com?utm_source=medium&amp;amp;utm_medium=referral"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Certain advertising tools allows for data exports to Big Query, a different data-warehouse tool or as file exports, for instance:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://cloud.google.com/bigquery/docs/doubleclick-campaign-transfer"&gt;DoubleClick&lt;/a&gt; and &lt;a href="https://help.emarsys.com/hc/en-us/articles/360000176214-Open-Data-End-user-guide"&gt;Emarsys&lt;/a&gt; provide exports to Google BigQuery&lt;/li&gt;
&lt;li&gt;Salesforce Marketing Cloud allows &lt;a href="https://help.salesforce.com/articleView?id=mc_es_export_de.htm&amp;amp;type=5"&gt;FTP/CSV exports&lt;/a&gt;, flow which can be automated in automation studio and then ingested into a database/data-warehouse&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Custom Development — API Pipelines&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YiKCJBg9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2Ag1fMzVezKLP4SkTD" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YiKCJBg9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2Ag1fMzVezKLP4SkTD" alt=""&gt;&lt;/a&gt;Photo by &lt;a href="https://unsplash.com/@lastly?utm_source=medium&amp;amp;utm_medium=referral"&gt;Tyler Lastovich&lt;/a&gt; on &lt;a href="https://unsplash.com?utm_source=medium&amp;amp;utm_medium=referral"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Development of pipelines to pull directly the data from Facebook, Google through API calls. This requires a data engineer or developer to setup the different data-flows. Most advertising sources provide SDK for easy integrations with their platforms.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Google Ads&lt;/em&gt;: &lt;a href="http://google-api-python-client"&gt;Google API Python Client&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Facebook:&lt;/em&gt; &lt;a href="https://developers.facebook.com/docs/business-sdk/"&gt;Facebook Business SDK&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Salesforce Marketing Cloud:&lt;/em&gt; &lt;a href="https://github.com/salesforce-marketingcloud/FuelSDK-Python"&gt;FuelSDK&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  ClickStream Collection
&lt;/h3&gt;

&lt;p&gt;Different alternatives exist in order to collect clickstream data, from relying on a premium analytics tool such as google analytics 360 or Adobe, leveraging a Customer Data Platform, a Clickstream collector or through setting up some custom development.&lt;/p&gt;

&lt;h4&gt;
  
  
  Google Analytics/Adobe Analytics
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---MBlb_-6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2A99-7FyjAUlsFYVMS" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---MBlb_-6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2A99-7FyjAUlsFYVMS" alt=""&gt;&lt;/a&gt;Photo by &lt;a href="https://unsplash.com/@austindistel?utm_source=medium&amp;amp;utm_medium=referral"&gt;Austin Distel&lt;/a&gt; on &lt;a href="https://unsplash.com?utm_source=medium&amp;amp;utm_medium=referral"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The simplest way, if you can afford it, to collect raw clickstream data is through google/adobe Analytics. Google offers the possibility to export raw clickstream data to Big Query as part of their Google 360 offering. One of the major draw-back of going for that route is the $150k annual cost of Google Analytics 360.&lt;/p&gt;

&lt;h4&gt;
  
  
  Customer Data Platform
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jiCRNfYX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2AmmO5q1LR9o1ctSxv" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jiCRNfYX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2AmmO5q1LR9o1ctSxv" alt=""&gt;&lt;/a&gt;Photo by &lt;a href="https://unsplash.com/@blakewisz?utm_source=medium&amp;amp;utm_medium=referral"&gt;Blake Wisz&lt;/a&gt; on &lt;a href="https://unsplash.com?utm_source=medium&amp;amp;utm_medium=referral"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Most customer data platform offer the possibility to export ingested events to a data-warehouse. They ingest data from multiple sources, including website activity and are able to stream it back for processing or analysis. Depending on the size of your business, a customer data platform might prove more expensive than purchasing a Google 360 license, but offers additional benefits. Certain CDP such as &lt;a href="https://segment.com/pricing/"&gt;segment&lt;/a&gt;, offer a free version up to a certain amount of events or active users.&lt;/p&gt;

&lt;h4&gt;
  
  
  ClickStream Collector
&lt;/h4&gt;

&lt;p&gt;Different open source clickstream collectors exist, the most known one are &lt;a href="https://snowplowanalytics.com/"&gt;Snowplow&lt;/a&gt; and &lt;a href="https://divolte.io/"&gt;divolte&lt;/a&gt;. They offer a way to ingest clickstream data, without the need to fully develop it. The draw-back of using these, is that you need to be managing the infrastructure.&lt;/p&gt;

&lt;h4&gt;
  
  
  Custom development
&lt;/h4&gt;

&lt;p&gt;Another solution to collect clickstream data is through custom development. Logic App, Function App, Lambda function and an EventHub/Kinesis/PubSub setup would allow for a scalable ingestion of data, but at the cost of managing code and infrastructure .&lt;/p&gt;

&lt;h3&gt;
  
  
  (Online) Sales data collection
&lt;/h3&gt;

&lt;p&gt;There are different ways to source information related to online sales, all of which have their own set of pros and cons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;Analytics Tags:&lt;/em&gt;&lt;/strong&gt; Analytics tags on the website to get a sense of online sales data. Data from your analytics tools can then be exported either manually, through API call or for those with Google 360 through a Big query export.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;Database replication/mirroring:&lt;/em&gt;&lt;/strong&gt; Some e-commerce platforms expose or let you choose your own database solution. This allows for using database replication / mirroring to get a live copy of the data for analysis or reporting purpose.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;Data Integration Solutions:&lt;/em&gt;&lt;/strong&gt; Pre-built data integration solutions exists, with certain platforms, acquiring one of these solution can significantly eases the development and maintenance needed to handle this part of the data collection process.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;Singer Taps:&lt;/em&gt;&lt;/strong&gt; Certain platforms, have singer taps created for them, essentially a pre-built ETL/API client which only needs to be configured before pulling the data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;API Pipelines:&lt;/em&gt;&lt;/strong&gt; API pipelines can be generated on schedule to pull relevant information. They do require some custom development in order to pull.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;Webhooks:&lt;/em&gt;&lt;/strong&gt; Webhooks provides for platform supporting it, of a way to export and ingest data in real-time. Their main draw back is that you need to develop and maintain infrastructure, API/Webhook receiver.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;Streams:&lt;/em&gt;&lt;/strong&gt; Some e-commerce solutions allow you to get a feed of transaction to an event stream exports. This allows for getting real-time ingestion by passing an API/Webhook receiver.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Analytics Tags
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--S2-bm3In--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2AIyvoarznC1u60EfA" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--S2-bm3In--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2AIyvoarznC1u60EfA" alt=""&gt;&lt;/a&gt;Photo by &lt;a href="https://unsplash.com/@nevenkrcmarek?utm_source=medium&amp;amp;utm_medium=referral"&gt;Neven Krcmarek&lt;/a&gt; on &lt;a href="https://unsplash.com?utm_source=medium&amp;amp;utm_medium=referral"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is possible to capture online sales data through an analytics tag such as Google’s. Google provides a structured way to pass the information to analytics through its &lt;a href="http://enhanced%20ecommerce"&gt;enhanced ecommerce&lt;/a&gt; plug-in. This allows to provide a good first pass at capturing e-commerce data, there is however quite a few drawbacks from that approach:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;em&gt;Ad-blocker&lt;/em&gt;: This approach faces issues for user using certain ad-block, which blacklist Google Analytics domain and any attempt from the analytics.js tag, although there are &lt;a href="https://medium.freecodecamp.org/save-your-analytics-from-content-blockers-7ee08c6ec7ee"&gt;some workarounds&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Page Load issues:&lt;/em&gt; Users, who leaves the thank you page before the tag has had the chance to fire, would not have their order data being pushed to Google Analytics&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Delayed Payment:&lt;/em&gt; Orders having payment methods that allow for delayed payment, such as Bank Transfer or Paypal, might be incorrectly classified as a successful sales or not recorded depending on the approach taken.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The main advantage from using this approach is the universality of it and the speed at which this can be deployed, usually only necessitating some tag integration for most web-shops, and for certain platform such as shopify, only some &lt;a href="https://help.shopify.com/en/manual/reports-and-analytics/google-analytics/google-analytics-setup"&gt;simple configuration&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Another of the advantage of setting up enhanced e-commerce tracking, is the ability to tie purchase to specific sessions and therefore be able to rely on google’s last click attribution. With it it is possible to attribute specific orders to specific campaign and sales-channel based on a last click attribution, this can be beneficial.&lt;/p&gt;

&lt;h4&gt;
  
  
  Database Replication &amp;amp; Mirroring
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ROHME1Oo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2ABTBtbVzE4j8sYmgi" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ROHME1Oo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2ABTBtbVzE4j8sYmgi" alt=""&gt;&lt;/a&gt;Photo by &lt;a href="https://unsplash.com/@fodelwdc?utm_source=medium&amp;amp;utm_medium=referral"&gt;Fares Hamouche&lt;/a&gt; on &lt;a href="https://unsplash.com?utm_source=medium&amp;amp;utm_medium=referral"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Some E-commerce platforms, allow those operating the platform to setup their own database , this is the case of &lt;a href="https://devdocs.magento.com/guides/v2.3/install-gde/install/web/install-web_2-db.html"&gt;Magento&lt;/a&gt;, &lt;a href="https://world.episerver.com/documentation/Items/Developers-Guide/Episerver-CMS/8/Deployment/About-the-database/"&gt;EpiServer&lt;/a&gt;, or SiteCore for instance. In these cases, it is possible to setup a Master-Slave database replication or &lt;a href="https://docs.microsoft.com/en-us/sql/database-engine/database-mirroring/database-mirroring-sql-server?view=sql-server-2017"&gt;database mirroring&lt;/a&gt;, so that the data can be used for reporting purpose without affecting the production environment.&lt;/p&gt;

&lt;p&gt;These can be setup without custom development, and can allow for a quick turnaround for providing data for reporting purposes.&lt;/p&gt;

&lt;h4&gt;
  
  
  Data Integration solutions
&lt;/h4&gt;

&lt;p&gt;As for Campaign data, data integration tools exists that provide turnkey integration for e-commerce data. Each of the mentioned vendors provide connectors to certain e-commerce platforms:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Talend&lt;/em&gt;: Shopify, BigCommerce and Magento are available as Talend connectors from &lt;a href="https://cloudbee.com/talend-open-studio-components/"&gt;Cloudbee&lt;/a&gt;,&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Advertity&lt;/em&gt;: supports Hybris, Shopware, Shopify and Magento&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;FiveTran&lt;/em&gt;: supports Salesforce CommerceCloud, Magento, WooCommerce, Shopify and SpreeCommerce&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Alooma:&lt;/em&gt; supports Shopify and Magento&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The use of these data integration solution are an alternative when there is lack of technical capabilities within the team/department.&lt;/p&gt;

&lt;h4&gt;
  
  
  Singer Taps
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pDVZvlSv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2AcG-p110dxzgQZ9Pm" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pDVZvlSv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2AcG-p110dxzgQZ9Pm" alt=""&gt;&lt;/a&gt;Photo by &lt;a href="https://unsplash.com/@dchuck?utm_source=medium&amp;amp;utm_medium=referral"&gt;Daniel Chekalov&lt;/a&gt; on &lt;a href="https://unsplash.com?utm_source=medium&amp;amp;utm_medium=referral"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Currently &lt;a href="https://github.com/singer-io/tap-woocommerce"&gt;WooCommerce&lt;/a&gt; is the only web-shop, having a &lt;a href="https://www.singer.io/#taps"&gt;singer-tap&lt;/a&gt; connector, making it’s use quite restricted. It is however possible to develop custom singer taps for specific use. This can be a good move, when already operating online campaign data collection through SingerTaps.&lt;/p&gt;

&lt;h4&gt;
  
  
  Custom Development — API Pipelines
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2JfC9qEy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2Af7r7p7QkXdJYe94r" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2JfC9qEy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2Af7r7p7QkXdJYe94r" alt=""&gt;&lt;/a&gt;Photo by &lt;a href="https://unsplash.com/@quinten149?utm_source=medium&amp;amp;utm_medium=referral"&gt;Quinten de Graaf&lt;/a&gt; on &lt;a href="https://unsplash.com?utm_source=medium&amp;amp;utm_medium=referral"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Most web-shops these days allows for pulling order information directly as API calls, this is the case of Pure SaaS platforms such as &lt;a href="https://help.shopify.com/en/api/reference/orders"&gt;Shopify&lt;/a&gt;, &lt;a href="https://developers.lightspeedhq.com/ecom/endpoints/order/"&gt;Lightspeed&lt;/a&gt;, Commercecloud or &lt;a href="https://docs.commercetools.com/http-api-projects-orders"&gt;Commercetools&lt;/a&gt;, but also of the likes of &lt;a href="https://devdocs.magento.com/guides/m1x/api/rest/Resources/Orders/sales_orders.html#RESTAPI-Resource-SalesOrders-HTTPMethod-GET-orders"&gt;Magento&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Some of which are supported by python SDK:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/Shopify/shopify_python_api"&gt;Shopify Python SDK&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Commercetools with a &lt;a href="https://github.com/labd/commercetools-python-sdk"&gt;Python SDK&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://pypi.org/project/magento/2.1/"&gt;Magento Python SDK&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One of the major drawback of this approach is that it requires custom data engineer or software engineer work, it requires polling and to a certain degree is not “real-time”. Certain platform furthermore have rate limitations that might make it impractical to work with for pulling large amounts of orders.&lt;/p&gt;

&lt;p&gt;One of the advantage of it however, is the ability to pull updated information about specific orders to date-ranges.&lt;/p&gt;

&lt;h4&gt;
  
  
  Custom Development — Webhooks
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YFH4ZWLu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2A8CLTHM1lmpfuf-Xp" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YFH4ZWLu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2A8CLTHM1lmpfuf-Xp" alt=""&gt;&lt;/a&gt;Photo by &lt;a href="https://unsplash.com/@chris_j_scott?utm_source=medium&amp;amp;utm_medium=referral"&gt;Chris Scott&lt;/a&gt; on &lt;a href="https://unsplash.com?utm_source=medium&amp;amp;utm_medium=referral"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Webhooks are essentially a way to send a notification over HTTP when some type of event happen, for our purpose, they provides a way to create a real-time ingestion of data from an e-commerce platform. Web-hooks can also provide a way to go around some of the rate-limitation if there isn’t any need to make callbacks.&lt;/p&gt;

&lt;p&gt;They do require some sort of web-hook listener API and ingestion layer in order to capture the data. These can be built with the same type of technologies used for capturing clickstream data, for example a Logic App / EventHub combination.&lt;/p&gt;

&lt;p&gt;Most e-commerce platform supports web-hooks, &lt;a href="https://help.shopify.com/en/api/reference/events/webhook"&gt;Shopfiy&lt;/a&gt;, &lt;a href="https://developers.lightspeedhq.com/ecom/tutorials/webhooks/"&gt;Lightspeed&lt;/a&gt; and &lt;a href="https://docs.woocommerce.com/document/webhooks/"&gt;WooCommerce&lt;/a&gt;, &lt;a href="https://docs.enterprise.shopware.com/connect/rest_api/"&gt;Shopware&lt;/a&gt;, and &lt;a href="https://developer.bigcommerce.com/api-docs/getting-started/webhooks/about-webhooks"&gt;Big commerce&lt;/a&gt;support it natively, while Magento supports it through 3rd party plugins, and platforms, such as &lt;a href="https://community.sitecore.net/developers/f/8/t/4489"&gt;sitecore&lt;/a&gt; or &lt;a href="https://www.c2experience.com/blog/getting-hooked-on-episerver-webhooks"&gt;episerver&lt;/a&gt;need custom development.&lt;/p&gt;

&lt;h4&gt;
  
  
  Custom Development — Streams
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bVLZisp1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2A4jgcEDgC6IZ1hzig" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bVLZisp1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2A4jgcEDgC6IZ1hzig" alt=""&gt;&lt;/a&gt;Photo by &lt;a href="https://unsplash.com/@yan_slg?utm_source=medium&amp;amp;utm_medium=referral"&gt;Boudhayan Bardhan&lt;/a&gt; on &lt;a href="https://unsplash.com?utm_source=medium&amp;amp;utm_medium=referral"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Some e-commerce platforms are able to publish events directly onto a message queue (eg: Google Pub/Sub, Azure Service Bus, AWS SQS). This is the case of &lt;a href="https://docs.commercetools.com/http-api-projects-subscriptions"&gt;Commercetools&lt;/a&gt;, that prefered this approach to the standard HTTP &lt;a href="https://techblog.commercetools.com/webhooks-the-devil-in-the-details-ca7f7982c24f"&gt;webhooks&lt;/a&gt;. This allows for instance to natively “duplicate” the relevant data for both processing (eg order fulfillment), and for long term storage in a datawarehouses and let the different consumer of the data “subscribe” from that single source of information.&lt;/p&gt;

&lt;p&gt;Beside Google Pub/Sub that has a turnkey &lt;a href="https://cloud.google.com/dataflow/docs/guides/templates/provided-streaming#cloudpubsubsubscriptiontobigquery"&gt;export to a Datawarehouse (BigQuery)&lt;/a&gt;, the other technology choices will still require development work in order to ingest he data.&lt;/p&gt;

&lt;p&gt;More from me on &lt;a href="https://medium.com/analytics-and-data"&gt;Hacking Analytics&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://medium.com/analytics-and-data/on-the-evolution-of-data-engineering-c5e56d273e37"&gt;One the evolution of Data Engineering&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/analytics-and-data/leveraging-facebook-python-api-for-marketing-analytics-f4372f042112?source=friends_link&amp;amp;sk=43a90fda6d1bcdfa03379162ea00e46b"&gt;Leveraging Facebook Python API for Marketing Analytics&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/analytics-and-data/5-domains-of-ecommerce-data-strategy-82b61356042c?source=friends_link&amp;amp;sk=2a29ed95b7882db2ff9d7adc3803554c"&gt;5 domains of ecommerce Data Strategy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/analytics-and-data/10-benefits-to-using-airflow-33d312537bae?source=friends_link&amp;amp;sk=9449eedcb64c30fb1823c72901041f44"&gt;10 Benefits to using Airflow&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




</description>
      <category>dataengineering</category>
      <category>data</category>
      <category>marketing</category>
      <category>analytics</category>
    </item>
    <item>
      <title>10 Benefits to using Airflow</title>
      <dc:creator>Julien Kervizic</dc:creator>
      <pubDate>Thu, 16 May 2019 16:33:46 +0000</pubDate>
      <link>https://forem.com/julienkervizic/10-benefits-to-using-airflow-14dn</link>
      <guid>https://forem.com/julienkervizic/10-benefits-to-using-airflow-14dn</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mc79JUUP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/845/1%2AVdzG4IrO_zKbh4_Sz2dP7A.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mc79JUUP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/845/1%2AVdzG4IrO_zKbh4_Sz2dP7A.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In continuation from a series of posts, where I have explained the &lt;a href="https://medium.com/analytics-and-data/airflow-the-easy-way-f1c26859ee21"&gt;basics of airflow&lt;/a&gt; and how to setup &lt;a href="https://medium.com/analytics-and-data/setting-up-airflow-on-azure-connecting-to-ms-sql-server-8c06784a7e2b?source=your_stories_page---------------------------"&gt;airflow on azure&lt;/a&gt;, and what &lt;a href="https://dev.to/julienkervizic/5-considerations-to-have-when-using-airflow-5c81-temp-slug-8477774"&gt;considerations to have when using airflow&lt;/a&gt;, I wanted to cover in details what makes airflow a great tool to use for data processing.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;1. DAGs&lt;/strong&gt; :
&lt;/h4&gt;

&lt;p&gt;Dags are a way to setup workflows, they can setup a sequence of operations that can be individually retried on failure and restarted where the operation failed. Dags provide a nice abstraction to a series of operations.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Programmatic Workflow Management:
&lt;/h4&gt;

&lt;p&gt;Airflow provide a way to setup programmatic workflows, Tasks for instances can be generated on &lt;a href="https://www.data-essential.com/create-dynamic-workflow-in-apache-airflow/"&gt;fly within a dag&lt;/a&gt;. While Sub-DAGs and &lt;a href="https://airflow.apache.org/concepts.html?highlight=xcom"&gt;XCom&lt;/a&gt;, allows to create complex dynamic workflows.&lt;/p&gt;

&lt;p&gt;Dynamics Dags can for instance be setup based on variables or connections defineed within the &lt;a href="https://www.astronomer.io/guides/dynamically-generating-dags/"&gt;Airflow UI&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  3. Automate your Queries, Python Code or Jupyter Notebook
&lt;/h4&gt;

&lt;p&gt;Airflow has a lot of operators setup to run code. Airflow has operator for most databases and being setup in python it has a PythonOperator that allow for quickly porting python code to production.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://airflow.readthedocs.io/en/latest/papermill.html"&gt;Papermilll&lt;/a&gt; is an extension to jupyter notebook, allowing the parametrization and execution of notebooks, it is supported through airflow PapermillOperator. Netflix notably has suggested a combination or airflow and &lt;a href="https://papermill.readthedocs.io/en/latest/"&gt;papermill&lt;/a&gt; to automate and deploy notebook in production:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/netflix-techblog/scheduling-notebooks-348e6c14cfd6"&gt;Part 2: Scheduling Notebooks at Netflix&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;4. Task Dependency management:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;It is extremely good at managing different sort of dependencies, be it a task completion, dag runs status, file or partition presence through specific sensor. Airflow also handles task dependency concept such as &lt;a href="http://airflow.apache.org/concepts.html?highlight=branch#branching"&gt;branching&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/@guillaume_payen/use-conditional-tasks-with-apache-airflow-98bab35f1846"&gt;Use conditional tasks with Apache Airflow&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;5. Extendable model:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;It is fully extendable through the development of custom sensors, hooks and operators. Airflow notably benefits from a large amount of &lt;a href="https://github.com/apache/airflow/tree/master/airflow/contrib/operators"&gt;community contributed operators&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Operators in different programming languages such as R &lt;a href="https://github.com/apache/airflow/pull/3115"&gt;[AIRFLOW-2193]&lt;/a&gt; are being built in using python wrappers, in the future other programing language such as Javascript which also have &lt;a href="https://code.google.com/archive/p/pyv8/"&gt;python wrapper (pyv8)&lt;/a&gt; could also be created.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;6. Monitoring and management interface:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--X9EmDh9R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AFdCmNWA-rKgmsZshGpaj2Q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--X9EmDh9R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AFdCmNWA-rKgmsZshGpaj2Q.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Airflow provides a monitoring and managing interface, where it is possible to have a quick overview of the status of the different tasks, as well as have the possibility to trigger and clear tasks or DAGs runs.&lt;/p&gt;

&lt;h4&gt;
  
  
  7. Retry policy built in:
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lieppKr---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/853/1%2AoDnmyS_c-HUZduhZ28b8Hw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lieppKr---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/853/1%2AoDnmyS_c-HUZduhZ28b8Hw.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It has an auto-retry policy built-in, configurable through :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;retries:&lt;/strong&gt; number of retries before failing the task&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;retry_delays: (&lt;/strong&gt;timedelta) delay between retries&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;retry_exponential_backoff: (&lt;/strong&gt;Boolean) to setup an exponential backoff between retries&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;max_retry_delay:&lt;/strong&gt; Maximum delay (timedelta) between retgries&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These arguments can be passed through the context to any operator, as they are supported by the BaseOperator class.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;8. Easy interface to interact with logs:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fnrfnfCI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AnNl14Q4P0BSQiz-HJzWkAw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fnrfnfCI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AnNl14Q4P0BSQiz-HJzWkAw.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Airflow provides an easy access to the logs of each of the different tasks run through its web-ui, making it easy to debug tasks in production.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;9. Rest API:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://airflow.apache.org/api.html"&gt;Airflow’s API&lt;/a&gt; allows to create workflows from external sources, and to be data product on top of it:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/google-cloud/using-airflow-experimental-rest-api-on-google-cloud-platform-cloud-composer-and-iap-9bd0260f095a"&gt;Using Airflow Experimental Rest API on Google Cloud Platform: Cloud Composer and IAP&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The rest API, allows to use the same paradigm used to built pipelines, to create asynchronous workflows, such as&lt;a href="https://medium.com/adobetech/adobe-experience-platform-orchestration-service-with-apache-airflow-952203723c0b"&gt;custom machine learning training operations&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;10. Alerting system:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;It provides a default alerting system on tasks failed, email is the default, but alerting through slack can be set up using a callback and the slack operator:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/datareply/integrating-slack-alerts-in-airflow-c9dcd155105"&gt;Integrating Slack Alerts in Airflow&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;More from me on &lt;a href="https://medium.com/analytics-and-data"&gt;Hacking Analytics&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://medium.com/analytics-and-data/on-the-evolution-of-data-engineering-c5e56d273e37"&gt;One the evolution of Data Engineering&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/analytics-and-data/overview-of-efficiency-concepts-in-big-data-engineering-418995f5f992"&gt;Overview of efficiency concepts in Big Data Engineering&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/analytics-and-data/setting-up-airflow-on-azure-connecting-to-ms-sql-server-8c06784a7e2b?source=friends_link&amp;amp;sk=c9c7c39100e7eaef45c7793caaa265b7"&gt;Setting up Airflow on Azure &amp;amp; connecting to MS SQL Server&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/analytics-and-data/airflow-the-easy-way-f1c26859ee21"&gt;Airflow, the easy way&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




</description>
      <category>datascience</category>
      <category>data</category>
      <category>airflow</category>
      <category>bigdataetl</category>
    </item>
    <item>
      <title>5 Considerations to have when using Airflow</title>
      <dc:creator>Julien Kervizic</dc:creator>
      <pubDate>Tue, 14 May 2019 19:00:52 +0000</pubDate>
      <link>https://forem.com/julienkervizic/5-considerations-to-have-when-using-airflow-5ea5</link>
      <guid>https://forem.com/julienkervizic/5-considerations-to-have-when-using-airflow-5ea5</guid>
      <description>&lt;h3&gt;
  
  
  5 considerations to have when using Airflow
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F796%2F1%2ArkbkMYnVwYncKlO4dPEnUg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F796%2F1%2ArkbkMYnVwYncKlO4dPEnUg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In previous posts, I have explained the &lt;a href="https://medium.com/analytics-and-data/airflow-the-easy-way-f1c26859ee21" rel="noopener noreferrer"&gt;basics of airflow&lt;/a&gt; and how to setup &lt;a href="https://medium.com/analytics-and-data/setting-up-airflow-on-azure-connecting-to-ms-sql-server-8c06784a7e2b?source=your_stories_page---------------------------" rel="noopener noreferrer"&gt;airflow on azure&lt;/a&gt;, I haven’t however covered what considerations we should give, when using Airflow.&lt;/p&gt;

&lt;p&gt;I see 5 main considerations to have when using airflow:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What type of &lt;strong&gt;infrastructure&lt;/strong&gt; to setup to support it&lt;/li&gt;
&lt;li&gt;What type of &lt;strong&gt;operator&lt;/strong&gt; model to abide by, and which operators to choose&lt;/li&gt;
&lt;li&gt;How to architect your different &lt;strong&gt;DAGs&lt;/strong&gt; and setup your tasks&lt;/li&gt;
&lt;li&gt;Whether to leverage &lt;strong&gt;templated&lt;/strong&gt; code or not&lt;/li&gt;
&lt;li&gt;Whether and how to use it’s &lt;strong&gt;REST API&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These considerations will dictate how you and your team will be using airflow and how it will be managed.&lt;/p&gt;

&lt;h3&gt;
  
  
  (1) Airflow Infrastructure — Go for a Managed Service if Possible
&lt;/h3&gt;

&lt;p&gt;Setting up and maintaining airflow isn’t so easy, if you need to set it up, you will most likely need quite a bit more than the base image:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Encryption needs to be setup to safely store secrets and credentials&lt;/li&gt;
&lt;li&gt;Setting up an authorization layer, if only through the flask login setup and preferably through an oAuth2 provider such as google&lt;/li&gt;
&lt;li&gt;SSL needs to be configured&lt;/li&gt;
&lt;li&gt;The web server needs to be moved to a more production ready setup (for example using wsgi/nginx)&lt;/li&gt;
&lt;li&gt;Libraries and drivers need to be installed to support the different types of operations you wish to handle&lt;/li&gt;
&lt;li&gt;…&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For the most simple use cases, it is possible to rely solely on the local executor, but once real processing need arise, more distributed computation need arise and management of the infrastructure becomes more complex.&lt;/p&gt;

&lt;p&gt;They require also more resources to run than a Local executor setup, where worker, scheduler and web-server can lie in the same container:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Celery executor&lt;/em&gt;: Webserver (UI), Redis (MQ), Postgres (Metadata), Flower (monitoring), Scheduler, Worker&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Mesos Executor&lt;/em&gt;: Webserver (UI), Redis (MQ), Postgres (Metadata), Mesos infra&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Kubernetes&lt;/em&gt;: Webserver (UI), Postgres (Metadata) and Scheduler, Kubernetes infra&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The high number of components will raise the complexity, make it harder to maintain and debug problems requiring that one understand how the &lt;a href="https://blog.sicara.com/using-airflow-with-celery-workers-54cb5212d405" rel="noopener noreferrer"&gt;Celery executor&lt;/a&gt; works with Airflow or how to interact with &lt;a href="https://towardsdatascience.com/kubernetesexecutor-for-airflow-e2155e0f909c" rel="noopener noreferrer"&gt;Kubernetes&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Managed version of airflow exists on Google Cloud, through &lt;a href="https://cloud.google.com/composer/" rel="noopener noreferrer"&gt;Cloud Composer&lt;/a&gt;, and &lt;a href="https://www.astronomer.io/" rel="noopener noreferrer"&gt;Astronomer.io&lt;/a&gt; also offers managed versions, &lt;a href="https://www.qubole.com/" rel="noopener noreferrer"&gt;qubole&lt;/a&gt; offers it as part of its’ data platform. Where applicable it is more than recommended to go for a managed version than setting up and managing this infrastructure yourself.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2A8cURwaSgf8iYk_61NZbRtA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2A8cURwaSgf8iYk_61NZbRtA.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AlSTvs2S3QSIe9kvgx8Ib8g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AlSTvs2S3QSIe9kvgx8Ib8g.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  (2) Sensors, Hooks and &lt;strong&gt;Operators — Find your fit&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Depending on your use case, you might want to be able to use certain sensor , hooks or operator. And while airflow has a decent support for the most &lt;a href="https://airflow.apache.org/_api/airflow/operators/index.html" rel="noopener noreferrer"&gt;common operators&lt;/a&gt;, and good support on &lt;a href="https://airflow.apache.org/howto/operator/gcp/index.html#" rel="noopener noreferrer"&gt;google cloud&lt;/a&gt;. If you have a more uncommon, use case you will probably need to check in &lt;a href="https://github.com/apache/airflow/tree/master/airflow/contrib/operators" rel="noopener noreferrer"&gt;user contributed operators list&lt;/a&gt; or develop your own.&lt;/p&gt;

&lt;p&gt;Understanding how to use operators depending on your particular company setup is also important. Some, have a radical stance &lt;a href="https://medium.com/bluecore-engineering/were-all-using-airflow-wrong-and-how-to-fix-it-a56f14cb0753" rel="noopener noreferrer"&gt;with respect to operator&lt;/a&gt;, but the reality is that the use of operators need to be taken in the context of your company.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Does your company have an engineering bias that supports the use of Kubernetes or other container style instances?&lt;/li&gt;
&lt;li&gt;Is your company use of airflow, more driven by your Datas-Science department, with little engineering support? For them, it might make more sense to use a python operator or the still &lt;a href="https://github.com/apache/airflow/pull/3115" rel="noopener noreferrer"&gt;pending R operator&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Is your company only planning to use airflow to operate data transfers (Sftp/S3 …) and SQL queries to maintain a data-warehouse? For them using K8s or any container instances would be overkill. This is for example the approach taken at &lt;a href="http://bytepawn.com/fetchr-data-science-infra.html#fetchr-data-science-infra" rel="noopener noreferrer"&gt;Fetchr&lt;/a&gt;, where most of the processing is done in ERM/Presto.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Selecting your operator setup is not a one size fit all.&lt;/p&gt;

&lt;h3&gt;
  
  
  (3) DAGS — Keep them simple
&lt;/h3&gt;

&lt;p&gt;There are quite a few ways to architect your DAGS in airflow, but as a general rule it is good to keep them simple. Keep within the DAGS tasks that are truly dependent on each other, when dealing with multiple DAGS dependencies abstract them into another DAG and file.&lt;/p&gt;

&lt;p&gt;When dealing with lot of data-sources and interdependencies, things can get messy, and setting up dags as self-contained files, kept as simple as possible can go a long way to make your code maintainability. The &lt;a href="https://airflow.readthedocs.io/en/latest/_modules/airflow/sensors/external_task_sensor.html" rel="noopener noreferrer"&gt;external task sensor&lt;/a&gt;, helps to separate DAG and their dependencies in multiple self contained DAGS.&lt;/p&gt;

&lt;p&gt;As in most distributed system it is important to setup operation as idempotent as possible — at least within a Dag Run. Certain operations between dag runs may rely on a depend on past settings.&lt;/p&gt;

&lt;p&gt;Sub-DAGS, should be used with parsimony for the same reason of code maintainability. One of the only valid reason for me in using Sub-DAGS is for the creation of Dynamic DAGS.&lt;/p&gt;

&lt;p&gt;Communication between tasks, although possible with &lt;a href="https://airflow.apache.org/concepts.html?highlight=xcom" rel="noopener noreferrer"&gt;XCom&lt;/a&gt; should be minimized as much as possible in favor of self containing functions/operators, this makes the code more legible, stateless and unless you want to be able to only re-run this part of the operation do not justify the use of these. Dynamic Dags are one of the notable exception to this.&lt;/p&gt;

&lt;h3&gt;
  
  
  (4) Templates and Macros — Legible Code
&lt;/h3&gt;

&lt;p&gt;Airflow leverages &lt;a href="http://jinja.pocoo.org/" rel="noopener noreferrer"&gt;jinja&lt;/a&gt; for &lt;a href="https://airflow.apache.org/tutorial.html#templating-with-jinja" rel="noopener noreferrer"&gt;templating&lt;/a&gt;. Commands such as Bash or SQL command can easily be templated, for execution with variables fitted or computed by the context. Templates can provide a more readable alternatives to direct string manipulation in python (eg: through a format command). JinJa templates is the default templating engine of most Flask developers, and can also provide a good bridge for python web developers getting into data.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://airflow.apache.org/macros.html" rel="noopener noreferrer"&gt;Macros&lt;/a&gt; provides a way to take further advantage of templating by exposing objects and functions to the templating engine. User can leverage a set of default macros, or customize theirs at global or DAG level.&lt;/p&gt;

&lt;p&gt;Using templated code does however take you away from vanilla python and exposes one more layer of complexity, for engineers typically needing to leverage quite a large array of technologies and apis.&lt;/p&gt;

&lt;p&gt;Whether or not you choose to leverage template is a team/personal choice, there are more traditional ways to obtain the same results, wrapping the same in python format commands for example, but it can make the code more legible.&lt;/p&gt;

&lt;h3&gt;
  
  
  (5) Event Driven — REST API for building Data Products
&lt;/h3&gt;

&lt;p&gt;Airflows’ &lt;a href="https://airflow.readthedocs.io/en/latest/api.html" rel="noopener noreferrer"&gt;REST Api&lt;/a&gt;, allow for the creation of event driven driven workflows. The key feature of the API, is to let you trigger DAGS runs with specific configuration:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2A3xj72HcV9m5ocwkThZGN7w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2A3xj72HcV9m5ocwkThZGN7w.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The rest API allow for building, data product applications built on top of airflow, with use cases such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Spanning out clusters and processing based on an&lt;a href="https://medium.com/google-cloud/using-airflow-experimental-rest-api-on-google-cloud-platform-cloud-composer-and-iap-9bd0260f095a" rel="noopener noreferrer"&gt;http request&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Setting up a workflow based on a message or file appearing in respectively a &lt;a href="https://blog.godatadriven.com/airflow-experimental-rest-api" rel="noopener noreferrer"&gt;message topic or blog stora&lt;/a&gt;ge&lt;/li&gt;
&lt;li&gt;Building fulling fledge &lt;a href="https://medium.com/adobetech/adobe-experience-platform-orchestration-service-with-apache-airflow-952203723c0b" rel="noopener noreferrer"&gt;Machine Learning platforms&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Leveraging the Rest API allows for the construction of complex asynchronous processing patterns, while re-using the same architecture, platform and possibly code that are used for more traditional data processing.&lt;/p&gt;

&lt;p&gt;More from me on &lt;a href="https://medium.com/analytics-and-data" rel="noopener noreferrer"&gt;Hacking Analytics&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://medium.com/analytics-and-data/on-the-evolution-of-data-engineering-c5e56d273e37" rel="noopener noreferrer"&gt;One the evolution of Data Engineering&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/analytics-and-data/overview-of-efficiency-concepts-in-big-data-engineering-418995f5f992" rel="noopener noreferrer"&gt;Overview of efficiency concepts in Big Data Engineering&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/analytics-and-data/setting-up-airflow-on-azure-connecting-to-ms-sql-server-8c06784a7e2b?source=friends_link&amp;amp;sk=c9c7c39100e7eaef45c7793caaa265b7" rel="noopener noreferrer"&gt;Setting up Airflow on Azure &amp;amp; connecting to MS SQL Server&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/analytics-and-data/airflow-the-easy-way-f1c26859ee21" rel="noopener noreferrer"&gt;Airflow, the easy way&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/analytics-and-data/e-commerce-analysis-data-structures-and-applications-6420c4fa65e7" rel="noopener noreferrer"&gt;E-commerce Analysis: Data-Structures and Applications&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




</description>
      <category>analytics</category>
      <category>machinelearning</category>
      <category>data</category>
      <category>dataengineering</category>
    </item>
    <item>
      <title>Python Screening Interview question for DataScientists</title>
      <dc:creator>Julien Kervizic</dc:creator>
      <pubDate>Sat, 11 May 2019 11:28:51 +0000</pubDate>
      <link>https://forem.com/julienkervizic/python-screening-interview-question-for-datascientists-30g4</link>
      <guid>https://forem.com/julienkervizic/python-screening-interview-question-for-datascientists-30g4</guid>
      <description>&lt;h3&gt;
  
  
  Python Screening Interview questions for DataScientists
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F0%2AAVvpe5YdYeRiA1ML" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F0%2AAVvpe5YdYeRiA1ML" width="800" height="533"&gt;&lt;/a&gt;Photo by &lt;a href="https://unsplash.com/@marius?utm_source=medium&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Marius Masalar&lt;/a&gt; on &lt;a href="https://unsplash.com?utm_source=medium&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;DataScience requires an interdisciplinary set of skills, from handling databases, to running statistical model, to setting up business cases and programming itself. More often than not technical interviews for data-scientists assess more the knowledge of specific data manipulation APIs such as pandas, sklearn or spark, rather than a programming way of thinking.&lt;/p&gt;

&lt;p&gt;While I think that a knowledge of the more “applied” APIs is something that should be tested when hiring data-scientist, so is the knowledge of more traditional programming.&lt;/p&gt;

&lt;h3&gt;
  
  
  String Reversal &amp;amp; Palindrome
&lt;/h3&gt;

&lt;p&gt;String reversal questions can provide some information as to how well, certain candidates have been with dealing with text in python and at handling basic operations.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;&lt;em&gt;Question 1&lt;/em&gt;&lt;/strong&gt; :
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; Reverse the String “ “the fox jumps over the lazy dog”&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Answer:&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = "the fox jumps over the lazy dog"
a[::-1]

or ''.join(x for x in reversed(a)) [less efficient]
or ''.join(a[-x] for x in range(1, len(a)+1)) [less efficient]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Assessment:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This is more of a warmup question than anything else and while it is good to know the shortcut notation, especially as it denotes some knowledge of how python deals with strings (eg substr a[0:7] for the fox) it is not necessary for most data-science’s purpose&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Question 2:
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt; : identity all words that are palindromes in the following sentence “Lol, this is a gag, I didn’t laugh so much in a long time”&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Answer:&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def isPalindrome(word: str) -\&amp;gt; bool:
 if(word == word[::-1]):
 return True
 return False

def getPalindromesFromStr(inputStr: str) -\&amp;gt; list:
 cleanStr = inputStr.replace(",","").lower()
 words = set(cleanStr.split(" "))
 wPalindromes = [
 word for word in words 
 if isPalindrome(word) and word != ""
 ]
 return wPalindromes

getPalindromesFromStr(“Lol, this is a gag, I didn’t laugh so much in a long time”)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Assessment:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Does the candidate thinks about cleaning his/her inputs?&lt;/li&gt;
&lt;li&gt;Does the candidate know the basic or word processing in python such as replace / split / lower?&lt;/li&gt;
&lt;li&gt;Does the candidate know how to use list comprehension?&lt;/li&gt;
&lt;li&gt;How does the candidate structure his/her code?&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;FizzBuzz&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;FizzBuzz is a traditional programming screening question, that allows to test if a candidate can think through a problem that is not a simple if else statement. The approach that they take can also shed some light to their understanding of the language.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; Write a program that prints the number for 1 to 50, for number multiple of 2 print fizz instead of a number, for numbers multiple of 3 print buzz, for numbers which are multiple of both 2 and 3 fizzbuzz.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Answer:&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def fizzbuzzfn(num) -\&amp;gt; str:
 mod\_2 = (num % 2 == 0) 
 mod\_3 = (num % 3 == 0)
 if (mod\_2 or mod\_3):
 return (mod\_2 \* 'Fizz') + (mod\_3 \* 'Buzz')
 return str(num)

print('\n'.join([fizzbuzzfn(x) for x in range(1,51)]))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Assessment:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Do they know the modulo operator and are able to apply it?&lt;/li&gt;
&lt;li&gt;Are they storing the result of the modulo operators in variables for re-use?&lt;/li&gt;
&lt;li&gt;Do they understand how True/False interact with a String?&lt;/li&gt;
&lt;li&gt;Are they bombarding their code with if statements?&lt;/li&gt;
&lt;li&gt;Do they return a consistent type or mix both integer and string?&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  First Duplicate word
&lt;/h3&gt;

&lt;p&gt;First finding of duplicate word allows to identity if candidates know the basic of text processing in python as well as are able to handle some basic data structure.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Question 1&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; Given a string find the first duplicate word, example string: “this is just a wonder, wonder why do I have this in mind”&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Answer:&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string = "this is just a wonder, wonder why do I have this in mind"

def firstduplicate(string: str) -\&amp;gt; str:
 import re
 cleanStr = re.sub("[^a-zA-Z -]", "", string)

 words = cleanStr.lower().split(" ")
 seen\_words = set()
 for word in words:
 if word in seen\_words:
 return word
 else: 
 seen\_words.add(word)
 return None

firstduplicate(string)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Assessment:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Do I have constraint I need to work with, for instance in terms of memory?&lt;/li&gt;
&lt;li&gt;Cleans the string from punctuation? Replace or Regexp? If use regexp replace, should I compile the regexp expression or used it directly?&lt;/li&gt;
&lt;li&gt;Knows the right data-structure to check for existence.&lt;/li&gt;
&lt;li&gt;Does it terminate the function as soon as the match is found or?&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Question 2:
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; What if we wanted to find the first word with more than 2 duplicates in a string?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Answer:&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string = "this is just a wonder, wonder why do I have this in mind. This is all that matters."

def first2timesduplicate(string: str) -\&amp;gt; str:
 import re
 cleanStr = re.sub("[^a-zA-Z -]", "", string)

 words = cleanStr.lower().split(" ")
 seen\_words = dict()

for word in words:
 previous\_count = seen\_words.get(word, 0)
 seen\_words[word] = previous\_count + 1
 if previous\_count \&amp;gt;= 2:
 return word
 return None

first2timesduplicate(string)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Assessment:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Some small modification is needed to be able to accommodate that change, the main one is arising from the use of a dictionary data-structure rather than a set. &lt;a href="https://docs.python.org/2/library/collections.html" rel="noopener noreferrer"&gt;Counters&lt;/a&gt; are also a valid data-structure for this use case.&lt;/li&gt;
&lt;li&gt;There is little difficulty on modifying the previous function to cope with this change request, it is worth checking that the candidate does instantiate the specific key correctly, taking into account default values.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Quick Fire questions
&lt;/h3&gt;

&lt;p&gt;Some quick fire questions can also be asked to test the general knowledge of the python language.&lt;/p&gt;

&lt;h4&gt;
  
  
  Question 1:
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; Replicate the sum for any number of variables, eg sum(1,2,3,4,5..)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Answer&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def sum(\*args):
 val = 0
 for arg in args:
 val += arg
 return val
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Assessment:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Quick interview question to check the knowledge of variable arguments, and how to setup one of the most basic functions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Question 2:
&lt;/h4&gt;

&lt;p&gt;Questions around the Fibonacci series is a classic of programming interviews and candidates should in general be at least familiar with them. They allow to test recursive thinking.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; Fibonacci sequences are defined as follow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;F\_0 = 0 ; F\_1 = 1
F\_n = F\_{-1} + F\_{-2}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Write a function that gives the sum of all fibonacci numbers from 0 to n.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Answer:&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def fibonacci(n: int) -\&amp;gt; int:
 # fib series don't exist \&amp;lt; 0 
 # might want to throw an error or a null 
 # for that
 if n \&amp;lt;= 0: 
 return 0
 if n == 1: 
 return 1
 else:
 return fibonacci(n-1) + fibonacci(n-2)

def naiveFibSum(n: int) -\&amp;gt; int:
 return sum([fibonacci(x) for x in range(0, n+1)])

def sumFib(n: int) -\&amp;gt; int:
 return fibonacci(n + 2) -1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Assessment:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;First, is the candidate able to think recursively?&lt;/li&gt;
&lt;li&gt;Is the candidate only thinking about a naive solution to the sum of fibonacci series or is s/he understanding that it can also summarized to a in a more effective way?&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Wrap up
&lt;/h3&gt;

&lt;p&gt;These questions are just meant to be a first screener for data-scientist and should be combined with statistical and data manipulation types of questions. They are meant to give a quick glimpse on whether a candidate has the basic minimum knowledge to go through a full interview rounds.&lt;/p&gt;

&lt;p&gt;More advanced programming questions for Python would tend to cover the use of generators, decorators, cython or the efficient use of libraries such as pandas/numpy.&lt;/p&gt;

&lt;p&gt;More from me on &lt;a href="https://medium.com/analytics-and-data" rel="noopener noreferrer"&gt;Hacking Analytics&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://medium.com/analytics-and-data/sql-interview-questions-for-aspiring-data-scientist-the-histogram-76a46de9b0a3" rel="noopener noreferrer"&gt;SQL interview Questions For Aspiring Data Scientist — The Histogram&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/julienkervizic/become-a-pro-at-pandas-python-s-data-manipulation-library-4214-temp-slug-5230196"&gt;Become a Pro at Pandas, Python’s data manipulation Library&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/analytics-and-data/e-commerce-analysis-data-structures-and-applications-6420c4fa65e7" rel="noopener noreferrer"&gt;E-commerce Analysis: Data-Structures and Applications&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/analytics-and-data/setting-up-airflow-on-azure-connecting-to-ms-sql-server-8c06784a7e2b" rel="noopener noreferrer"&gt;Setting up Airflow on Azure &amp;amp; connecting to MS SQL Server&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/analytics-and-data/3-simple-rules-to-build-machine-learning-models-that-add-value-61106db88461" rel="noopener noreferrer"&gt;3 simple rules to build machine learning Models that add value&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




</description>
      <category>engineering</category>
      <category>python</category>
      <category>programming</category>
      <category>technology</category>
    </item>
    <item>
      <title>Become a Pro at Pandas, Python’s data manipulation Library</title>
      <dc:creator>Julien Kervizic</dc:creator>
      <pubDate>Thu, 09 May 2019 17:34:26 +0000</pubDate>
      <link>https://forem.com/julienkervizic/become-a-pro-at-pandas-python-s-data-manipulation-library-2161</link>
      <guid>https://forem.com/julienkervizic/become-a-pro-at-pandas-python-s-data-manipulation-library-2161</guid>
      <description>&lt;p&gt;&lt;a href="https://medium.com/analytics-and-data/become-a-pro-at-pandas-pythons-data-manipulation-library-264351b586b1?source=rss----5bbc46989439---4" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2600%2F0%2AUAKmqEnb3YsEUTdt"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The pandas library is the most popular data manipulation library for python. It provides an easy way to manipulate data through its…&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding The pandas library
&lt;/h2&gt;

&lt;p&gt;One of the keys to getting a good understanding of pandas, is to understand that pandas is mostly a wrapper around a series of other python libraries. The main ones being Numpy, sql alchemy, Matplot lib and openpyxl.&lt;/p&gt;

&lt;p&gt;The core internal model of the data-frame is a series of numpy arrays, and pandas functions, such as the now deprecated “as_matrix” functtion, which return results in numpy’s &lt;a href="https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.as_matrix.html" rel="noopener noreferrer"&gt;internal representation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Pandas leverages other libraries to get data in and out of data-frames, SQL Alchemy for instance is used through the read_sql and to_sql functions. While openpyxl and xlsx writer are used for read_excel and to_excel functions.&lt;/p&gt;

&lt;p&gt;Matplotlib and Seaborn in turn are used to provide an easy interface, to plot information available within a data frame, using command such as df.plot()&lt;/p&gt;

&lt;h2&gt;
  
  
  Numpy’s Panda — Efficient pandas
&lt;/h2&gt;

&lt;p&gt;One of the complain that you often hear is that Python is slow or that it is difficult to handle large amount of data. Most often than not, this is due to poor efficiency of the code being written. It is true that native python code tends to be slower than compiled code, but libraries like Pandas provides a python interface to compiled code and knowing how to properly use this interface, let us get the best out of pandas/python.&lt;/p&gt;

&lt;h3&gt;
  
  
  APPLY &amp;amp; VECTORIZED OPERATIONS
&lt;/h3&gt;

&lt;p&gt;Pandas, like its underlying library Numpy, performs vectorized operations more efficiently than performing loops. These efficiencies are due to vectorized operations being performed through C compiled code, rather than native python code, and on the ability of vectorized operations to operate on entire datasets rather than just a sub-portion at the time.&lt;/p&gt;

&lt;p&gt;The apply interface allows to gain some of the efficiency by using a CPython interfaces to do the looping:&lt;br&gt;
&lt;code&gt;df.apply(lambda x: x['col_a'] * x['col_b'], axis=1)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;But most of the performance gain would be obtained from the use of vectorized operation themselves, be it directly in pandas or by calling its’ internal Numpy arrays directly.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fi24rqfxlr848vy0fwsoz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fi24rqfxlr848vy0fwsoz.png"&gt;&lt;/a&gt;&lt;br&gt;
As you can see from the picture above the difference in performance can be drastic, between processing it with a vectorized operation (3.53ms) and looping with apply to do an addition (27.8s). Additional efficiencies can be obtained by directly invoking the numpy’s arrays and api, eg:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F7ovdsppfccnwuq2dbrhk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F7ovdsppfccnwuq2dbrhk.png"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Swifter&lt;/strong&gt;: &lt;a href="https://medium.com/@jmcarpenter2/swiftapply-automatically-efficient-pandas-apply-operations-50e1058909f9?source=post_page-----264351b586b1----------------------" rel="noopener noreferrer"&gt;swifter&lt;/a&gt; is a python library that makes it easy to vectorize different types of operations on dataframe, its API is fairly similar to that of the apply function&lt;/p&gt;

&lt;h3&gt;
  
  
  EFFICIENT DATA STORING THROUGH DTYPES
&lt;/h3&gt;

&lt;p&gt;When loading a data-frame into memory, be it through read_csv, or read_excel or some other data-frame read function, SQL makes type inference which might prove to be inefficient. These APIs allow you to specify the types of each columns explicitly. This allows for a more efficient storage of data in memory.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;df.astype({'testColumn': str, 'testCountCol': float})&lt;/code&gt;&lt;br&gt;
Dtypes are native object from &lt;a href="https://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html" rel="noopener noreferrer"&gt;Numpy&lt;/a&gt;, which allows you to define the exact type and number of bits used to store certain informations.&lt;/p&gt;

&lt;p&gt;Numpy’s dtype &lt;code&gt;np.dtype('int32')&lt;/code&gt; would for instance represent a 32 bits long integer. Pandas default to 64 bits integer, we could be save half the space by using 32 bits:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F5n6yxvep3tq96dv41j03.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F5n6yxvep3tq96dv41j03.png"&gt;&lt;/a&gt;&lt;br&gt;
memory_usage() shows the number of bytes used by each of the columns, since there is only one entry (row) per column, the size of each int64 column is 8bytes and of int32 4bytes.&lt;/p&gt;

&lt;p&gt;Pandas also introduces the categorical dtype, that allows for efficient memory utilization for frequently occurring values. In the example below, we can see a 28x decrease in memory utilization for the field posting_date when we converted it to a categorical value.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F03mr9qqq9zdhyt2n96v4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F03mr9qqq9zdhyt2n96v4.png"&gt;&lt;/a&gt;&lt;br&gt;
In our example, the overall size of the data-frame drops by more than 3X by just changing this data type:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fcdkrb6qh24ob8getaaln.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fcdkrb6qh24ob8getaaln.png"&gt;&lt;/a&gt;&lt;br&gt;
Not only using the right dtypes allows you to handle larger datasets in memory, but it also makes some computations become more efficient. In the example below, we can see that using categorical type brought a 3X speed improvement for the groupby / sum operation.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Foozf7jnk2ujas0j8mwl6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Foozf7jnk2ujas0j8mwl6.png"&gt;&lt;/a&gt;&lt;br&gt;
Within pandas, you can define the dtypes, either during the data load (read_ ) or as a type conversion (astype).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CyberPandas&lt;/strong&gt;: &lt;a href="https://www.anaconda.com/cyberpandas-extending-pandas-with-richer-types/" rel="noopener noreferrer"&gt;Cyber pandas&lt;/a&gt; is one of the different library extension that enables a richer variety of datatypes by supporting ipv4 and ipv6 data types and storing them efficiently.&lt;/p&gt;

&lt;h3&gt;
  
  
  HANDLING LARGE DATASETS WITH CHUNKS
&lt;/h3&gt;

&lt;p&gt;Pandas allows for the loading of data in a data-frame by chunks, it is therefore possible to process data-frames as iterators and be able to handle data-frames larger than the available memory.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fixt4ujgpp0qxcpdbiryu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fixt4ujgpp0qxcpdbiryu.png"&gt;&lt;/a&gt;&lt;br&gt;
The combination of defining a chunksize when reading a data source and the get_chunk method, allows pandas to process data as an iterator, such as in the example shown above, where the data frame is read 2 rows at the time. These chunks can then be iterated through:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;i = 0&lt;br&gt;
for a in df_iter:&lt;br&gt;
  # do some processing  &lt;br&gt;
  chunk = df_iter.get_chunk()&lt;br&gt;
  i += 1&lt;br&gt;
  new_chunk = chunk.apply(lambda x: do_something(x), axis=1)&lt;br&gt;
  new_chunk.to_csv("chunk_output_%i.csv" % i )&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
The output of which can then be fed to a csv file, pickled, exported to a database, etc…&lt;/p&gt;

&lt;p&gt;setting up operator by chunks also allows certain operations to be perform through &lt;a href="https://docs.python.org/2/library/multiprocessing.html" rel="noopener noreferrer"&gt;multi-processing&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Dask: is a for instance, a framework built on top of Pandas and build with multi-processing and distributed processing in mind. It makes use of collections of chunks of pandas data-frames both in memory and on disk.&lt;/p&gt;

&lt;h2&gt;
  
  
  SQL Alchemy’s Pandas — Database Pandas
&lt;/h2&gt;

&lt;p&gt;Pandas also is built up on top of SQL Alchemy to interface with databases, as such it is able to download datasets from diverse SQL type of databases as well as push records to it. Using the SQL Alchemy interface rather than the Pandas’ API directly allows us to do certain operations not natively supported within pandas such as transactions or upserts:&lt;/p&gt;

&lt;h3&gt;
  
  
  SQL TRANSACTIONS
&lt;/h3&gt;

&lt;p&gt;Pandas can also make use of SQL transactions, handling commits and rollbacks. Pedro Capelastegui, explained in one of his blog post &lt;a href="https://capelastegui.wordpress.com/2018/05/21/commit-and-rollback-with-pandas-dataframe-to_sql/" rel="noopener noreferrer"&gt;notably&lt;/a&gt;, how pandas could take advantage of transactions through a SQL alchemy context manager.&lt;br&gt;
&lt;code&gt;with engine.begin() as conn:&lt;br&gt;
  df.to_sql(&lt;br&gt;
    tableName,&lt;br&gt;
    con=conn,&lt;br&gt;
    ...&lt;br&gt;
  )&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;the advantage of using a SQL transaction, is the fact that the transaction would roll back should the data load fail.&lt;/p&gt;

&lt;h3&gt;
  
  
  SQL extension
&lt;/h3&gt;

&lt;h4&gt;
  
  
  PandaSQL
&lt;/h4&gt;

&lt;p&gt;Pandas has a few SQL extension such as &lt;a href="https://pypi.org/project/pandasql/" rel="noopener noreferrer"&gt;pandasql&lt;/a&gt; a library that allows to perform SQL queries on top of data-frames. Through pandasql the data-frame object can be queried directly as if they were database tables.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fnjmhg5eaiufy99mu6erz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fnjmhg5eaiufy99mu6erz.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  SQL UPSERTs
&lt;/h4&gt;

&lt;p&gt;Pandas doesn’t natively support upsert exports to SQL on databases supporting this function. &lt;a href="https://github.com/ryanbaumann/Pandas-to_sql-upsert" rel="noopener noreferrer"&gt;Patches to pandas&lt;/a&gt; exists to allow this feature.&lt;/p&gt;

&lt;h2&gt;
  
  
  MatplotLib/Seaborn — Visual Pandas
&lt;/h2&gt;

&lt;p&gt;Matplotlib and Searborn visualization are already integrated in some of the dataframe API such as through the .plot command. There is a fairly comprehensive documentation as how the interface works, on &lt;a href="https://pandas.pydata.org/pandas-docs/version/0.22/visualization.html" rel="noopener noreferrer"&gt;pandas’ website&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Extensions&lt;/strong&gt;: Different extensions exists such as Bokeh and plotly to provide interactive visualization within Jupyter notebooks, while it is also possible to extend matplotlib to handle &lt;a href="https://pythonprogramming.net/3d-graphing-pandas-matplotlib/" rel="noopener noreferrer"&gt;3D graphs&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Other Extensions
&lt;/h2&gt;

&lt;p&gt;Quite a few other extensions for pandas exists, which are there to handle no-core functionalities. One of them is tqdm, which provides a progress bar functionality for certain operations, another is pretty pandas which allows to format dataframes and add summary informations.&lt;/p&gt;

&lt;h4&gt;
  
  
  tqdm
&lt;/h4&gt;

&lt;p&gt;tqdm is a progress bar extension in python that interacts with pandas, it allows user to see the progress of maps and applys operations on pandas dataframe when using the relevant function (progress_map and progress_apply):&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F4ofsslfxahr40wy0m5ff.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F4ofsslfxahr40wy0m5ff.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  PrettyPandas
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://github.com/HHammond/PrettyPandas" rel="noopener noreferrer"&gt;PrettyPandas&lt;/a&gt; is a library that provides an easy way to format data-frames and to add table summaries to them:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F73ituvg6fufcgczbpm52.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F73ituvg6fufcgczbpm52.png"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;More from me on &lt;a href="https://medium.com/analytics-and-data" rel="noopener noreferrer"&gt;Hacking Analytics&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://medium.com/analytics-and-data/on-the-evolution-of-data-engineering-c5e56d273e37" rel="noopener noreferrer"&gt;On the evolution of Data Engineering&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/analytics-and-data/airflow-the-easy-way-f1c26859ee21" rel="noopener noreferrer"&gt;Airflow, the easy way&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/analytics-and-data/e-commerce-analysis-data-structures-and-applications-6420c4fa65e7" rel="noopener noreferrer"&gt;E-commerce Analysis: Data-Structures and Applications&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://medium.com/analytics-and-data/setting-up-airflow-on-azure-connecting-to-ms-sql-server-8c06784a7e2b" rel="noopener noreferrer"&gt;Setting up Airflow on Azure &amp;amp; connecting to MS SQL Server&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/analytics-and-data/3-simple-rules-to-build-machine-learning-models-that-add-value-61106db88461" rel="noopener noreferrer"&gt;3 simple rules to build machine learning Models that add value&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>data</category>
      <category>datascience</category>
      <category>engineering</category>
      <category>bigdata</category>
    </item>
    <item>
      <title>New roles of Analytics — The Data Product Owner &amp; Analytics Translator</title>
      <dc:creator>Julien Kervizic</dc:creator>
      <pubDate>Wed, 01 May 2019 16:25:17 +0000</pubDate>
      <link>https://forem.com/julienkervizic/new-roles-of-analytics-the-data-product-owner-analytics-translator-3clm</link>
      <guid>https://forem.com/julienkervizic/new-roles-of-analytics-the-data-product-owner-analytics-translator-3clm</guid>
      <description>&lt;h3&gt;
  
  
  New roles of Analytics — The Data Product Owner &amp;amp; Analytics Translator
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Jzk2rDVK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2AGOByG5Sxm1GNe4JM" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Jzk2rDVK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2AGOByG5Sxm1GNe4JM" alt=""&gt;&lt;/a&gt;Photo by &lt;a href="https://unsplash.com/@markusspiske?utm_source=medium&amp;amp;utm_medium=referral"&gt;Markus Spiske&lt;/a&gt; on &lt;a href="https://unsplash.com?utm_source=medium&amp;amp;utm_medium=referral"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Two new roles have emerged in the world of data in the past few years, roles that are providing a softer touch in a world of technical data. These roles are aimed to fill a clear gap, in a function where juniors are plenty and senior few and bring product and project leadership in a world constrained by the lack of analytical leadership talent.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Data-Science Product Owner&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The role was created by companies like Booking.com, heavily involved in Agile and employing over 200 data-scientists. Nowadays the role can be found in companies hiring only a couple of data-scientists.&lt;/p&gt;

&lt;p&gt;Ignoring the ill-fit that data-science has with Agile (where the Product Owner title comes from), there are preconditions and draw backs to having data-science specific product owners.&lt;/p&gt;

&lt;p&gt;Overall the company and team needs to have a certain technical orientation and composition, critical size and focus to make efficient use of a data product owner.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Technical Orientation:&lt;/strong&gt; In a similar vein that some companies have TPMs, Technical product managers, to cope with the degree of technicality of the role, data-science product owners should have a technical background and preferably this should be within the field of data-sciences, booking.com notably used to hire ex-data-scientists for this role. Product Owners are meant to set the strategic vision, roadmap and prioritize the feature for development, this is not possible in a data-science team without a deep understanding of data-sciences, its constraints, how to setup a MVP and being able to differentiate what can add value and what would likely bring minimal improvement.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Team composition:&lt;/strong&gt; Some of the issues that often happen with data-science teams staffed with a product owner is that of team composition. It is very unusual for instance, to have a data-scientist put model into production by itself. They tend to leverage the expertise of Data Engineers, and often of Backend Software Engineers for that purpose. In the team composition, it is also worth making the distinction between what people often call type “A” (A for Analysis) and type “B” (B for Build) data-scientists. The distinction is worth considering as the work of a type “A” data-scientists would be ported with more difficulty to production and might need additional engineering support.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Critical size:&lt;/strong&gt; In order for it to make sense to have a dedicated product owner for a data-science team, there needs to be a critical mass of data-scientist in your organization, that can be lead through a single vision. For this to apply, you need to have enough data-scientists focused on a single product area.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Team Focus:&lt;/strong&gt; One of the issues having product owner focused purely on data-science, is the focus that it can give to the team. Most often than not a data-science problem is more easily solved by changing the different business or product processes in order to provide more signal in the data. Having products teams purely focused on data-scientists can hinder their output by limiting their scope.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Analytics Translator&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Back in early 2018, McKinsey noticing a gap in the market, coined the title of “&lt;a href="https://hbr.org/2018/02/you-dont-have-to-be-a-data-scientist-to-fill-this-must-have-analytics-role?autocomplete=true"&gt;Analytics Translator&lt;/a&gt;”. They described the role as required deep domain knowledge, to help better prioritize business opportunities.&lt;/p&gt;

&lt;p&gt;There is definitely parallels and overlap in the role of an analytics translator and a data(-science) product owner, notably around setting up the teams’ prioritization, providing domain knowledge and being an interface between the data-science/development team and the business.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Prioritization&lt;/strong&gt; : Both the analytics translator role and the product owner role help prioritize the work carried out by the different members of the team.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Domain Knowledge:&lt;/strong&gt; Both the role of an analytics translator and product owner requires business domain knowledge. Although it is only stated as a hard requirement for the analytics translator.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Interface:&lt;/strong&gt; The analytics translator is meant to bridge the gap towards the business and make sure that the business can leverage upon them, be it an insight or a product that is being built. The role of the product owner similarly is to act as a representative of the business to the development team, and of the development team to the business.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There is some difference in the roles however. While the product owner role, tends to have more of a focus towards building products, the analytics translator has a role more geared towards the business and generating insights.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Product / Project orientation:&lt;/strong&gt; The role of the analytics translator is defined as being more oriented project rather than products. It encompass the full delivery of insights and the leverage of the information provided into action, as I had described into the &lt;a href="https://medium.com/analytics-and-data/4-pillars-of-analytics-1ee79e2e5f5f?source=friends_link&amp;amp;sk=e151e23ae11937eaf5f7e75b3bc0aa5b"&gt;4 Pillars of analytics&lt;/a&gt;, Analytics Translator are responsible for the Last Mile.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Technical fluency:&lt;/strong&gt; McKinsey describes the skills needed for an analytics translator as “general technical fluency”, they need to have some general understanding of the technical concepts used in analytics, although not necessarily be able to apply them themselves. This is a much higher level of data technical competency than a general product owner, but would likely be lower than most data product owner from large technological organizations.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Wrap Up
&lt;/h3&gt;

&lt;p&gt;Both role aim to fill the gaps in a field that is becoming increasingly technical and where certain actors are detaching from their business roots. They can help compensate a lack of more senior analytics talents, such as a Head of Data Science by providing more product / project guidance.&lt;/p&gt;

&lt;p&gt;We need to be however be very particular on the conditions that we bring about these roles, as they need a certain critical mass of technical data talent in order to be truly beneficial and only introduce them in organization that would provide the right context for these roles.&lt;/p&gt;

&lt;p&gt;More from me on &lt;a href="https://medium.com/analytics-and-data"&gt;Hacking Analytics&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://medium.com/analytics-and-data/4-pillars-of-analytics-1ee79e2e5f5f?source=friends_link&amp;amp;sk=e151e23ae11937eaf5f7e75b3bc0aa5b"&gt;4 Pillars of Analytics&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/analytics-and-data/on-the-evolution-of-data-engineering-c5e56d273e37"&gt;One the evolution of Data Engineering&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/analytics-and-data/principles-of-e-commerce-personalization-4feb6de4b6e"&gt;Principles of e-commerce Personalization&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/analytics-and-data/on-customer-lifetime-value-in-ecommerce-d3c151c6fdc0"&gt;On customer lifetime value in ecommerce&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/analytics-and-data/on-the-attribution-and-decomposition-of-mix-and-rate-effects-a681d01b9315"&gt;ON the attribution and decomposition of mix and rate effects&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




</description>
      <category>analytics</category>
      <category>business</category>
      <category>datascience</category>
      <category>product</category>
    </item>
    <item>
      <title>Overview of the different approaches to putting Machine Learning (ML) models in  production</title>
      <dc:creator>Julien Kervizic</dc:creator>
      <pubDate>Mon, 29 Apr 2019 20:21:50 +0000</pubDate>
      <link>https://forem.com/julienkervizic/overview-of-the-different-approaches-to-putting-machine-learning-ml-models-in-production-12ae</link>
      <guid>https://forem.com/julienkervizic/overview-of-the-different-approaches-to-putting-machine-learning-ml-models-in-production-12ae</guid>
      <description>&lt;p&gt;&lt;a href="https://medium.com/analytics-and-data/overview-of-the-different-approaches-to-putting-machinelearning-ml-models-in-production-c699b34abf86?source=rss----5bbc46989439---4" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2600%2F0%2AN-zRq8Vu4A_jDgkT"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are different approaches to putting models into productions, with benefits that can vary dependent on the specific use case. Take for example the use case of churn prediction, there is value in having a static value already that can easily be looked up when someone call a customer service, but there is some extra value that could be gained if for specific events, the model could be re-run with the newly acquired information.&lt;/p&gt;

&lt;p&gt;There is generally different ways to both train and server models into production:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Train&lt;/strong&gt;: one off, batch and real-time/online training&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Serve&lt;/strong&gt;: Batch, Realtime (Database Trigger, Pub/Sub, web-service, inApp)
Each approach having its own set of benefits and tradeoffs that need to be considered.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  One off Training
&lt;/h2&gt;

&lt;p&gt;Models don’t necessarily need to be continuously trained in order to be pushed to production. Quite often a model can be just trained ad-hoc by a data-scientist, and pushed to production until its performance deteriorates enough that they are called upon to refresh it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F692%2F1%2AuDrP8CmxK74DEtXqA738uw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F692%2F1%2AuDrP8CmxK74DEtXqA738uw.png"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;From Jupyter to Prod&lt;/em&gt;&lt;br&gt;
DataScientists prototyping and doing machine learning tend to operate in their environment of choice Jupyter Notebooks. Essentially an advanced GUI on a repl, that allows you to save both code and command outputs.&lt;br&gt;
Using that approach it is more than feasible to push an ad-hoc trained model from some piece of code in Jupyter to production. Different types of libraries and other notebook providers help further tie the link between the data-scientist workbench and production.&lt;/p&gt;
&lt;h3&gt;
  
  
  Model Format
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://docs.python.org/3/library/pickle.html" rel="noopener noreferrer"&gt;Pickle&lt;/a&gt; converts a python object to to a bitstream and allows it to be stored to disk and reloaded at a later time. It is provides a good format to store machine learning models provided that their intended applications is also built in python.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/onnx" rel="noopener noreferrer"&gt;ONNX&lt;/a&gt; the Open Neural Network Exchange format, is an open format that supports the storing and porting of predictive model across libraries and languages. Most deep learning libraries support it and sklearn also has a library extension to convert their model to ONNX’s format.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Predictive_Model_Markup_Language" rel="noopener noreferrer"&gt;PMML&lt;/a&gt; or Predictive model markup language, is another interchange format for predictive models. Like for ONNX sklearn also has another library extension for converting the models to PMML format. It has the drawback however of only supporting certain type of prediction models.PMML has been around since 1997 and so has a large footprint of applications leveraging the format. Applications such as SAP for instance is able to leverage certain versions of the PMML standard, likewise for CRM applications such as PEGA.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://docs.h2o.ai/h2o/latest-stable/h2o-docs/productionizing.html#about-pojos-and-mojos" rel="noopener noreferrer"&gt;POJO and MOJO&lt;/a&gt; are H2O.ai’s export format, that intendeds to offers an easily embeddable model into java application. They are however very specific to using the H2O’s platform.&lt;/p&gt;
&lt;h3&gt;
  
  
  Training
&lt;/h3&gt;

&lt;p&gt;For one off training of models, the model can either be trained and fine tune adhoc by a data-scientists or training through AutoML libraries. Having an easily reproducible setup, however helps pushing into the next stage of productionalization, ie: batch training.&lt;/p&gt;
&lt;h2&gt;
  
  
  Batch Training
&lt;/h2&gt;

&lt;p&gt;While not fully necessary to implement a model in production, batch training allows to have a constantly refreshed version of your model based on the latest train.&lt;/p&gt;

&lt;p&gt;Batch training can benefit a-lot from AutoML type of frameworks, AutoML enables you to perform/automate activities such as feature processing, feature selection, model selections and parameter optimization. Their recent performance has been on par or bested the most diligent data-scientists.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F1400%2F1%2AP6odfU6Xa39t18c70fie3w.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F1400%2F1%2AP6odfU6Xa39t18c70fie3w.jpeg"&gt;&lt;/a&gt;&lt;br&gt;
Using them allows for a more comprehensive model training than what was typically done prior to their ascent: simply retraining the model weights.&lt;/p&gt;

&lt;p&gt;Different technologies exists that are made to support this continuous batch training, these could for instance be setup through a mix of airflow to manage the different workflow and an AutoML library such as tpot, Different cloud providers offer their solutions for AutoML that can be put in a data workflow. Azure for instance integrates machine learning prediction and model training with their data factory offering.&lt;/p&gt;
&lt;h2&gt;
  
  
  Real time training
&lt;/h2&gt;

&lt;p&gt;Real-time training is possible with ‘Online Machine Learning’ models, algorithms supporting this method of training includes K-means (through mini-batch), Linear and Logistic Regression (through Stochastic Gradient Descent) as well as Naive Bayes classifier.&lt;/p&gt;

&lt;p&gt;Spark has StreamingLinearAlgorithm/StreamingLinearRegressionWithSGD to perform these operations, sklearn has SGDRegressor and SGDClassifier that can be incrementally trained. In sklearn, the incremental training is done through the partial_fit method as shown below:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
When deploying this type of models there needs to be serious operational support and monitoring as the model can be sensitive to new data and noise, and model performance needs to be monitored on the fly. In offline training, you can filter points of high leverage and correct for this type of incoming data. This is much harder to do when you are constantly updating your model training based on a stream of new data points.

&lt;p&gt;Another challenge that occurs with training online model is that they don’t decay historical information. This means that, on case there are structural changes in your datasets, the model will need to be anyway re-trained and that there will be a big onus in model lifecycle management.&lt;/p&gt;
&lt;h2&gt;
  
  
  Batch vs. Real-time Prediction
&lt;/h2&gt;

&lt;p&gt;When looking at whether to setup a batch or real-time prediction, it is important to get an understanding of why doing real-time prediction would be important. It can potentially be for getting a new score when significant event happen, for instance what would be the churn score of customer when they call a contact center. These benefits needs to be weighted against the complexity and cost implications that arise from doing real-time predictions.&lt;/p&gt;
&lt;h3&gt;
  
  
  Load implications
&lt;/h3&gt;

&lt;p&gt;Catering to real time prediction, requires a way to handle peak load. Depending on the approach taken and how the prediction ends up being used, choosing a real-time approach, might also require to have machine with extra computing power available in order to provide a prediction within a certain SLA. This contrasts with a batch approach where the predictions computing can be spread out throughout the day based on available capacity.&lt;/p&gt;
&lt;h3&gt;
  
  
  Infrastructure Implications
&lt;/h3&gt;

&lt;p&gt;Going for real-time, put a much higher operational responsibility. People need to be able to monitor how the system is working, be alerted when there is issue as well as take some consideration with respect to failover responsibility. For batch prediction, the operational obligation is much lower, some monitoring is definitely needed, and altering is desired but the need to be able to know of issues arising directly is much lower.&lt;/p&gt;
&lt;h3&gt;
  
  
  Cost Implications
&lt;/h3&gt;

&lt;p&gt;Going for real-time predictions also has costs implications, going for more computing power, not being able to spread the load throughout the day can force into purchasing more computing capacity than you would need or to pay for spot price increase. Depending on the approach and requirements taken there might also be extra cost due to needing more powerful compute capacity in order to meet SLAs. Furthermore, there would tend to be a higher infrastructure footprint when choosing for real time predictions. One potential caveat there is where the choice is made to rely on in app prediction, for that specific scenario the cost might actually end up being cheaper than going for a batch approach.&lt;/p&gt;
&lt;h3&gt;
  
  
  Evaluation Implications
&lt;/h3&gt;

&lt;p&gt;Evaluating the prediction performance in real-time manner can be more challenging than for batch predictions. How do you evaluate performance when you are faced with a succession of actions in a short burst producing multiple predictions for a given customer for instance? Evaluating and debugging real-time prediction models are significantly more complex to manage. They also require a log collection mechanism that allows to both collect the different predictions and features that yielded the score for further evaluation.&lt;/p&gt;
&lt;h2&gt;
  
  
  Batch Prediction Integration
&lt;/h2&gt;

&lt;p&gt;Batch predictions rely on two different set of information, one is the predictive model and the other one is the features that we will feed the model. In most type of batch prediction architecture, ETL is performed to either fetch pre-calculated features from a specific datastore (feature-store) or performing some type of transformation across multiple datasets to provide the input to the prediction model. The prediction model then iterates over all the rows in the datasets providing the different score.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F1388%2F1%2AGtbLV1h4KwN4JB4ffKK04Q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F1388%2F1%2AGtbLV1h4KwN4JB4ffKK04Q.png"&gt;&lt;/a&gt;&lt;br&gt;
Once all the predictions have been computed, we can then “serve” the score to the different systems wanting to consume the information. This can be done in different manner depending on thee use case for which we want to consume the score, for instance if we wanted to consume the score on a front-end application, we would most likely push the data to a “cache” or NoSQL database such as Redis so that we can offer milliseconds responses, while for certain use cases such as the creation of an email journey, we might just be relying on a CSV SFTP export or a data load to a more traditional RDBMS.&lt;/p&gt;
&lt;h2&gt;
  
  
  Real-time Prediction integration
&lt;/h2&gt;

&lt;p&gt;Being able to push model into production for real-time applications require 3 base components. A customer/user profile, a set of triggers and predictive models.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F1052%2F1%2AYTH1CUGPhrIh6aLbcSj3vg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F1052%2F1%2AYTH1CUGPhrIh6aLbcSj3vg.png"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Profile&lt;/strong&gt;: The customer profile contains all the related attribute to the customer as well as the different attributes (eg: counters) necessary in order to make a given prediction. This is required for customer level prediction in order to reduce the latency of pulling the information from multiple places as well as to simplify the integration of machine learning models in productions. In most cases a similar type of data store would be needed in order to effectively fetch the data needed to power the prediction model.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Triggers&lt;/strong&gt;: Triggers are events causing the initiation of process, they can be for churn for instance, call to a customer service center, checking information within your order history, etc …&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Models&lt;/strong&gt;: models need to have been pre-trained and typically exported to one of the different formats previously mentioned (eg pickle, ONNX, PMML) to be something that we could easily port to production.&lt;/p&gt;

&lt;p&gt;There are quite a few different approach to putting models for scoring purpose in production:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Relying on in Database integration&lt;/em&gt;: a lot of database vendors have made a significant effort to tie up advanced analytics use cases within the database. Be it by direct integration of Python or R code, to the import of PMML model.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Exploiting a Pub/Sub model&lt;/em&gt;: The prediction model is essentially an application feeding of a data-stream and performing certain operations, such as pulling customer profile information.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Webservice&lt;/em&gt;: Setting up an API wrapper around the model prediction and deploying it as a web-service. Depending on the way the web-service is setup it might or might not do the pull or data needed to power the model.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;inApp&lt;/em&gt;: it is also possible to deploy the model directly into a native or web application and have the model be run on local or external datasources.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Database integrations
&lt;/h3&gt;

&lt;p&gt;If the overall size of your database is fairly small (&amp;lt; 1M user profile) and the update frequency is occasional it can make sense to integrate some of the real-time update process directly within the database.&lt;/p&gt;

&lt;p&gt;Postgres possess an integration that allows to run Python code as functions or stored procedure called PL/Python. This implementation has access to all the libraries that are part of the PYTHONPATH, and as such are able to use libraries such as Pandas and SKlearn to run some operations.&lt;/p&gt;

&lt;p&gt;This can be coupled with Postgres’ Triggers Mechanism to perform a run of the database and update the churn score. For instance if a new entry is made to a complaint table, it would be valuable to have the model be re-run in real-time.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F1082%2F1%2ADWZxL_wO0pOob_bF3adzlg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F1082%2F1%2ADWZxL_wO0pOob_bF3adzlg.png"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Sequence flow
&lt;/h4&gt;

&lt;p&gt;The flow could be setup in the following way:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;New Event&lt;/em&gt;: When a new row is inserted in the complain table, an event trigger is generated.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Trigger&lt;/em&gt;: The trigger function would update the number of complaint made by this customer in the customer profile table and fetch the updated record for the customer.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Prediction Request&lt;/em&gt;: Based on that it would re-run the churn model through PL/Python and retrieve the prediction.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Customer Profile Update&lt;/em&gt;: It can then re-update the customer profile with the updated prediction. Downstream flows can then happen upon checking if the customer profile has been updated with new churn prediction value.&lt;/p&gt;
&lt;h4&gt;
  
  
  Technologies
&lt;/h4&gt;

&lt;p&gt;Different databases are able to support the running of Python script, this is the case of PostGres which has a native Python integration as previosuly mentioned, but also of Ms SQL Server through its’ Machine Learning Service (in Database), other databases such as Teradata, are able to run R/Python script through an external script command. While Oracle supports PMML model through its data mining extension.&lt;/p&gt;
&lt;h3&gt;
  
  
  Pub/Sub
&lt;/h3&gt;

&lt;p&gt;Implementing real-time prediction through a pub/sub model allows to be able to properly handle the load through throttling. For engineers, it also means that they can just feed the event data through a single “logging” feed, to which different application can subscribe.&lt;/p&gt;

&lt;p&gt;An example, of how this could be setup is shown below:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F1400%2F1%2A3Rgyzsh78S8yAAGWTz_vNg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F1400%2F1%2A3Rgyzsh78S8yAAGWTz_vNg.png"&gt;&lt;/a&gt;&lt;br&gt;
The page view event is fired to a specific event topic, on which two application subscribe a page view counter, and a prediction. Both of these application filter out specific relevant event from the topic for their purpose and consume the different messages in the topics. The page view counter app, provides data to power a dashboard, while the prediction app, updates the customer profile.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F1112%2F1%2APKuD-hTLyhG1f20UuvZb3w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F1112%2F1%2APKuD-hTLyhG1f20UuvZb3w.png"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Sequence flow:
&lt;/h4&gt;

&lt;p&gt;Event messages are pushed to the pub/sub topic as they occur, the prediction app poll the topic for new messages. When a new message is retrieved by the prediction app, it will request and retrieve the customer profile and use the message and the profile information to make a prediction. which it will ultimately push back to the customer profile for further use.&lt;/p&gt;

&lt;p&gt;A slightly different flow can be setup where the data is first consumed by an “enrichment app” that adds the profile information to the message and then pushes it back to a new topic to finally be consumed by the prediction app and pushed onto the customer profile.&lt;/p&gt;
&lt;h4&gt;
  
  
  Technologies
&lt;/h4&gt;

&lt;p&gt;The typical open source combination that you would find that support this kind of use case in the data ecosystem is a combination of Kafka and Spark streaming, but a different setup is possible on the cloud. On google notably a google pub-sub/dataflow (Beam) provides a good alternative to that combination, on azure a combination of Azure-Service Bus or Eventhub and Azure Functions can serve as a good way to consume the mesages and generate these predictions.&lt;/p&gt;
&lt;h3&gt;
  
  
  Web Service
&lt;/h3&gt;

&lt;p&gt;We can implement models into productions as web-services. Implementing predictions model as web-services are particularly useful in engineering teams that are fragmented and that need to handle multiple different interfaces such as web, desktop and mobile.&lt;/p&gt;

&lt;p&gt;Interfacing with the web-service could be setup in different way:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;either providing an identifier and having the web-service pull the required information, compute the prediction and return its’ value&lt;/li&gt;
&lt;li&gt;Or by accepting a payload, converting it to a data-frame, making the prediction and returning its’ value.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The second approach is usually recommended in cases, when there is a lot of interaction happening and a local cache is used to essentially buffer the synchronization with the backend systems, or when needing to make prediction at a different grain than a customer id, for instance when doing session based predictions.&lt;/p&gt;

&lt;p&gt;The systems making use of local storage, tend to have a reducer function, which role is to calculate what would be the customer profile, should the event in local storage be integrated back. As such it provides an approximation of the customer profile based on local data.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F1362%2F1%2AWZAWyyDXsq3Uy490suEefA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F1362%2F1%2AWZAWyyDXsq3Uy490suEefA.png"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Sequence Flow
&lt;/h4&gt;

&lt;p&gt;The flow for handling the prediction using a mobile app, with local storage can be described in 4 phases.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Application Initialization (1 to 3)&lt;/em&gt;: The application initializes, and makes a request to the customer profile, and retrieve its initial value back, and initialize the profile in local storage.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Applications (4)&lt;/em&gt;: The application stores the different events happening with the application into an array in local storage.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Prediction Preparation (5 to 8)&lt;/em&gt;: The application wants to retrieve a new churn prediction, and therefore needs to prepare the information it needs to provide to the Churn Web-service. For that, it makes an initial request to local storage to retrieve the values of the profile and the array of events it has stored. Once they are retrieve, it makes a request to a reducer function providing these values as arguments, the reducer function outputs an updated* profile with the local events incorporated back into this profile.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Web-service Prediction (9 to 10)&lt;/em&gt;: The application makes a request to the churn prediction web-service, providing the different the updated*/reduced customer profile from step 8 as part of the payload. The web-service can then used the information provided by the payload to generate the prediction and output its value, back to the application.&lt;/p&gt;

&lt;p&gt;There are quite a few technologies that can be used to power a prediction web-service:&lt;/p&gt;
&lt;h5&gt;
  
  
  Functions
&lt;/h5&gt;

&lt;p&gt;AWS Lambda functions, Google Cloud functions and Microsoft Azure Functions (although Python support is currently in Beta) offer an easy to setup interface to easily deploy scalable web-services.&lt;/p&gt;

&lt;p&gt;For instance on Azure a prediction web-service could be implemented through a function looking roughly like this:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h5&gt;
  
  
  Container
&lt;/h5&gt;

&lt;p&gt;An alternative to functions, is to deploy a flask or django application through a docker container (Amazon ECS, Azure Container Instance or Google Kubernetes Engine). Azure for instance provides an easy way to setup prediction containers through its’ Azure Machine Learning service.&lt;/p&gt;

&lt;h5&gt;
  
  
  Notebooks
&lt;/h5&gt;

&lt;p&gt;Different notebooks providers such as databricks and dataiku have notably worked on simplifying the model deployment from their environments. These have the feature of setting up a webservice to a local environment or deploying to external systems such as Azure ML Service, Kubernetes engine etc…&lt;/p&gt;

&lt;h3&gt;
  
  
  in App
&lt;/h3&gt;

&lt;p&gt;In certain situations when there are legal or privacy requirements that do not allow for data to be stored outside of an application, or there exists constraints such as having to upload a large amount of files, leveraging a model within the application tend to be the right approach.&lt;/p&gt;

&lt;p&gt;Android-ML Kit or the likes of Caffe2 allows to leverage models within native applications, while Tensorflow.js and ONNXJS allow for running models directly in the browser or in apps leveraging javascripts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Considerations
&lt;/h2&gt;

&lt;p&gt;Beside the method of deployments of the models, they are quite a few important considerations to have when deploying to production.&lt;/p&gt;

&lt;h3&gt;
  
  
  Model Complexity
&lt;/h3&gt;

&lt;p&gt;The complexity of the model itself, is the first considerations to have. Models such as a linear regressions and logistic regression are fairly easy to apply and do not usually take much space to store. Using more complex model such as a neural network or complex ensemble decision tree, will end up taking more time to compute, more time to load into memory on cold start and will prove more expensive to run&lt;/p&gt;

&lt;h3&gt;
  
  
  Data Sources
&lt;/h3&gt;

&lt;p&gt;It is important to consider the difference that could occur between the datasource in productions and the one used for training. While it is important for the data used for the training to be in sync with the context it would be used for in production, it is often impractical to recalculate every value so that it becomes perfectly in-sync.&lt;/p&gt;

&lt;h3&gt;
  
  
  Experimentation framework
&lt;/h3&gt;

&lt;p&gt;Setting up an experimentation framework, A/B testing the performance of different models versus objective metrics. And ensuring that there is sufficient tracking to accurately debug and evaluate models performance a posteriori.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;Choosing how to deploy a predictive models into production is quite a complex affair, there are different way to handle the lifecycle management of the predictive models, different formats to stores them, multiple ways to deploy them and very vast technical landscape to pick from.&lt;/p&gt;

&lt;p&gt;Understanding specific use cases, the team’s technical and analytics maturity, the overall organization structure and its’ interactions, help come to the the right approach for deploying predictive models to production.&lt;/p&gt;




&lt;p&gt;More from me on &lt;a href="https://medium.com/analytics-and-data" rel="noopener noreferrer"&gt;Hacking Analytics&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://medium.com/analytics-and-data/on-the-evolution-of-data-engineering-c5e56d273e37" rel="noopener noreferrer"&gt;On the evolution of Data Engineering&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/analytics-and-data/airflow-the-easy-way-f1c26859ee21" rel="noopener noreferrer"&gt;Airflow, the easy way&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/analytics-and-data/e-commerce-analysis-data-structures-and-applications-6420c4fa65e7" rel="noopener noreferrer"&gt;E-commerce Analysis: Data-Structures and Applications&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/analytics-and-data/setting-up-airflow-on-azure-connecting-to-ms-sql-server-8c06784a7e2b" rel="noopener noreferrer"&gt;Setting up Airflow on Azure &amp;amp; connecting to MS SQL Server&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/analytics-and-data/3-simple-rules-to-build-machine-learning-models-that-add-value-61106db88461" rel="noopener noreferrer"&gt;3 simple rules to build machine learning Models that add value&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>data</category>
      <category>dataengineering</category>
      <category>machinelearning</category>
      <category>software</category>
    </item>
  </channel>
</rss>
