<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="https://futurewithml.netlify.app/feed_style.xsl" type="text/xsl"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <tabi:metadata xmlns:tabi="https://github.com/welpo/tabi">
        <tabi:base_url>https:&#x2F;&#x2F;futurewithml.netlify.app</tabi:base_url>
        <tabi:separator>
            |
        </tabi:separator>
        <tabi:about_feeds>This is a web feed, also known as an Atom feed. Subscribe by copying the URL from the address bar into your newsreader. Visit About Feeds to learn more and get started. It&#x27;s free.</tabi:about_feeds>
        <tabi:visit_the_site>Visit website</tabi:visit_the_site>
        <tabi:recent_posts>Recent posts</tabi:recent_posts>
        <tabi:last_updated_on>Updated on $DATE</tabi:last_updated_on>
        <tabi:default_theme></tabi:default_theme>
        <tabi:post_listing_date>date</tabi:post_listing_date>
        <tabi:current_section>MLarchitecture</tabi:current_section>
    </tabi:metadata><link rel="extra-stylesheet" href="https://futurewithml.netlify.app/skins/cyber.css?h=eb029a27afbc61465b52" /><title>Future With ML - MLarchitecture</title>
        <subtitle>Machine Learning Design Patterns, MLOps, and AI Engineering insights by Christian Picon Calderon</subtitle>
    <link href="https://futurewithml.netlify.app/categories/mlarchitecture/atom.xml" rel="self" type="application/atom+xml"/>
    <link href="https://futurewithml.netlify.app/categories/mlarchitecture/" rel="alternate" type="text/html"/>
    <generator uri="https://www.getzola.org/">Zola</generator><updated>2023-03-04T00:00:00+00:00</updated><id>https://futurewithml.netlify.app/categories/mlarchitecture/atom.xml</id><entry xml:lang="en">
        <title>Ml patterns design</title>
        <published>2023-03-04T00:00:00+00:00</published>
        <updated>2023-03-04T00:00:00+00:00</updated>
        <author>
            <name>Christian Picon Calderon</name>
        </author>
        <link rel="alternate" href="https://futurewithml.netlify.app/posts/chapter01-ml-pattern-design/" type="text/html"/>
        <id>https://futurewithml.netlify.app/posts/chapter01-ml-pattern-design/</id>
        
            <content type="html">&lt;h1 id=&quot;machine-learning-patterns&quot;&gt;&lt;strong&gt;Machine Learning Patterns&lt;&#x2F;strong&gt;&lt;&#x2F;h1&gt;
&lt;p&gt;Hello! First and foremost, I am embarking on a journey to highlight the main aspects presented in the book “&lt;a href=&quot;https:&#x2F;&#x2F;www.oreilly.com&#x2F;library&#x2F;view&#x2F;machine-learning-design&#x2F;9781098115777&#x2F;&quot;&gt;Machine Learning Design Patterns&lt;&#x2F;a&gt;” This series is intended for machine learning engineers, data engineers, and data scientists. I will skip the explanation of basic terminology and focus on the nuances of facing the most common challenges when deploying machine learning models. The concept of patterns was introduced in the field of civil engineering&#x2F;architecture by Christopher Alexander and five co-authors in the book titled “A Pattern Language” (1977). The main idea is that in a situation that happens recurrently, the pattern describes the core solution for this context and can be applied several times for this or similar ones. Here, we will explore the most general patterns that can be applied to machine learning system design.&lt;&#x2F;p&gt;
&lt;span id=&quot;continue-reading&quot;&gt;&lt;&#x2F;span&gt;
&lt;hr &#x2F;&gt;
&lt;p&gt;However we can’t proceed without defining the most common challenges in ML:&lt;&#x2F;p&gt;
&lt;h2 id=&quot;data-quality&quot;&gt;&lt;strong&gt;Data Quality&lt;&#x2F;strong&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;As you may know, in ML, “Garbage in, garbage out” applies, we must to check accuracy, completeness, consistency and timeliness of data&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Data accuracy&lt;&#x2F;strong&gt; refers to the great and harness job that data engineers carry out. These engineers play an essential role in checking and handling typos, duplicate entries, measurement inconsistencies, missing features, and the particularities of unstructured data. For instance, duplicates can lead the model to assign more weight to those duplicated samples during learning. Also, incorrectly labeled training examples introduce bias in the model.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Data Completeness&lt;&#x2F;strong&gt; ensures that your training data contains a varied representation of each label. It has the same effect on learning as the duplicated examples in the training data. To deal with data accuracy and completeness issues, you should perform an Exploratory Data Analysis (EDA). I encourage you to take a look at Pandas profile or Dtale to facilitate this analysis.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Data consistency&lt;&#x2F;strong&gt; is another common aspect of machine learning. As you know, in supervised learning, you need labeled data, so here, we should ask for labeled data or start labeling it. The problem arises when labelers introduce bias, especially if the data requires domain knowledge (like in medical images). One common technique is to divide the work among a group of people, then have multiple people labeling each example and take the most commonly applied label (we will see this in-depth in Fairness Lens pattern design). Inconsistent features are also considered in this section as they can change over time (think about sensors with different offset of calibration).&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Timelines&lt;&#x2F;strong&gt; in data refers to the latency between the event occurrence and the addition to the database. It is more important in real-time machine learning applications, so in this case, you should record as much data as possible. For example, add a timestamp when a data point was generated and when it was added to the storage.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;reproducibility&quot;&gt;&lt;strong&gt;Reproducibility&lt;&#x2F;strong&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;Machine learning, unlike traditional software, has an inherent element of randomness. For example, matrix weights are initialized with random values, so the model converges to different outputs for different training executions. This can make it difficult to run comparisons across experiments. Fixing a value for seed can solve this issue.&lt;&#x2F;p&gt;
&lt;p&gt;Training an ML model involves several artifacts that need to be fixed to ensure reproducibility: the data used, the splitting mechanism used to generate datasets for training and validation, data preparation and model hyperparameters, and variables like batch size and learning rate schedule. It also applies to ML framework dependencies. Running ML workloads in containers and standardizing library versions can help ensure repeatability.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;data-drift&quot;&gt;&lt;strong&gt;Data Drift&lt;&#x2F;strong&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;Data drift is an important concept in ML, especially in production. Data drift refers to the challenge of ensuring that your machine learning models remain relevant. To solve for drift, it’s essential to continually update your training dataset, retrain your model, and modify the weight your model assigns to particular groups of input data. Exploratory data analysis is a technique required here to understand the behavior of the data. For example, predicting the likelihood of a storm requires exploring the data available from the sensors for this scenario. In the next image, we can see that training a model on data before 2000 would lead to inaccurate predictions.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;futurewithml.netlify.app&#x2F;posts&#x2F;chapter01-ml-pattern-design&#x2F;chap1_datadrift.png&quot; alt=&quot;chap1_datadrift.png&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;Copyright 2020 Google Inc. Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at &lt;a href=&quot;http:&#x2F;&#x2F;www.apache.org&#x2F;licenses&#x2F;LICENSE-2.0&quot;&gt;http:&#x2F;&#x2F;www.apache.org&#x2F;licenses&#x2F;LICENSE-2.0&lt;&#x2F;a&gt; Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h2 id=&quot;scale&quot;&gt;&lt;strong&gt;Scale&lt;&#x2F;strong&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;You will encounter scaling challenges in different phases of your ML application, such as data collection and preprocessing, training, and serving. The size of your data willl dictate the tooling required for your solution. ML engineers are responsible for determining the neccesary infrastructure for a specific training job. If your dataset is big enough, model training can be time consuming and computationally expensive.  In the context of model serving, the infrastructure required to support a team of data scientist getting predictions is entirely different from the infrastructure necessary to support a production model for millions of predictions by hour. We will see resilience and reproducibility in chapter 6 and 7.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;multiple-objectives-the-hidden-big-challenge&quot;&gt;&lt;strong&gt;Multiple Objectives&lt;&#x2F;strong&gt; (The hidden big challenge)&lt;&#x2F;h2&gt;
&lt;p&gt;Model in production introduce a big challenge for a Ml engineer because the model is being used by different teams&#x2F;roles in the organization. Having this scenario, we will see that defining a sucessful model is not easy. Each user&#x2F;team&#x2F;role has his own definition of a success model given his needs.  For example, a data scientist&#x2F;ML research is interest in minimize the loss function of the model. The project manager is interested in generate value by linking this model into the organization products, so here we start dealing with how to define a KPI that mimics the behavior of the loss function. Finally, the executive team is insterested in increase the revenue by using this model but they understand the KPI more that a mathematical function like loss function.  As you saw, it is responsability of the data scientist work together with the project manager to define this KPI, then move this into executive team.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;thanks&quot;&gt;Thanks&lt;&#x2F;h2&gt;
&lt;p&gt;Dear &lt;a href=&quot;https:&#x2F;&#x2F;www.linkedin.com&#x2F;in&#x2F;jameshclrk&#x2F;&quot;&gt;James Clark&lt;&#x2F;a&gt;, I just wanted to take a moment to thank you for inspiring&#x2F;helping me to start my own personal blog. Your blog, https:&#x2F;&#x2F;jamesclark.dev&#x2F;, has been a source of inspiration for me, and your willingness to share your experiences and knowledge has been invaluable. Thanks to your guidance, I now have a platform to express my thoughts, share my ideas, and connect with others who share my passions. Your support and encouragement have been instrumental in helping me get started, and I am truly grateful for all that you have done for me. Thank you again for everything, James!&lt;&#x2F;p&gt;
</content>
        <summary type="html">Machine Learning Patterns
Hello! First and foremost, I am embarking on a journey to highlight the main aspects presented in the book “Machine Learning Design Patterns” This series is intended for machine learning engineers, data engineers, and data scientists. I will skip the explanation of basic terminology and focus on the nuances of facing the most common challenges when deploying machine learning models. The concept of patterns was introduced in the field of civil engineering/architecture by Christopher Alexander and five co-authors in the book titled “A Pattern Language” (1977). The main idea is that in a situation that happens recurrently, the pattern describes the core solution for this context and can be applied several times for this or similar ones. Here, we will explore the most general patterns that can be applied to machine learning system design.
…</summary>
        </entry>
</feed>
