Things to know about Data-Driven Architecture on cloud
Tags: database, datascience, cloud, architecture
Published: 2022-03-19 05:04:38

<!-- wp:paragraph -->
<p>As data becomes more diverse and valuable, we will see more emphasis on data-driven architecture . Developers need to understand the importance of accuracy, consistency, and quality of data. So they can develop quality data pipelines, and products to make sure we put the data first.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>This blog explains what data is, how can we enrich our data, how can we analyse our data, and how to best use our data. We will be covering AWS Glue, AWS QuickSight, and AWS Sagemaker.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Inspiration of this blog, was after reading the Forbes Blog on, "<strong>The Age Of Analytics And The Importance Of Data Quality".</strong></p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li><a rel="noreferrer noopener" href="https://www.forbes.com/sites/forbesagencycouncil/2019/10/01/the-age-of-analytics-and-the-importance-of-data-quality/?sh=76cca4fa5c3c" target="_blank">https://www.forbes.com/sites/forbesagencycouncil/2019/10/01/the-age-of-analytics-and-the-importance-of-data-quality/?sh=76cca4fa5c3c</a></li><li><a href="https://www.freecodecamp.org/news/is-data-important-to-your-business/" target="_blank" rel="noreferrer noopener">https://www.freecodecamp.org/news/is-data-important-to-your-business/</a></li></ol>
<!-- /wp:list -->

<!-- wp:heading {"textAlign":"center","level":3} -->
<h3 class="has-text-align-center">Q.What is Data?</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Data is raw information. For example, your daily consumption of coffee. It is raw information about the amount of coffee you have consumed, but if you analyse it and gain insights from it.</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Types of coffee beans or coffee flavour </li><li>How much sugar do you put into the coffee?</li></ol>
<!-- /wp:list -->

<!-- wp:image {"align":"center","width":288,"height":288,"sizeSlug":"large"} -->
<figure class="wp-block-image aligncenter size-large is-resized"><img src="https://ciscocanada.files.wordpress.com/2013/09/cisco_blog_canada_coffee.png" alt="" width="288" height="288"/><figcaption>Image Credits: https://ciscocanada.files.wordpress.com/2013/09/cisco_blog_canada_coffee.png</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Now that we differentiate between information and data. There are many formats to store and transfer data, these formats depend on the type of data. For example,&nbsp;</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Write coffee ingredients on a piece of paper i.e unstructured&nbsp; </li><li>Write it in a .csv file i.e structured&nbsp;</li><li>A combination of both i.e semi-structured.</li></ol>
<!-- /wp:list -->

<!-- wp:image {"align":"center","sizeSlug":"large"} -->
<figure class="wp-block-image aligncenter size-large"><img src="https://programmerprodigycode.files.wordpress.com/2022/03/ecd9e-1sbcb7tf8jjwzchdtt_sodw.png" alt=""/><figcaption>Image Credits: https://programmerprodigycode.files.wordpress.com/2022/03/ecd9e-1sbcb7tf8jjwzchdtt_sodw.png</figcaption></figure>
<!-- /wp:image -->

<!-- wp:heading {"textAlign":"center","level":3} -->
<h3 class="has-text-align-center">Q.How to enrich our data?</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>As a data engineer, you would like to maximise the insights you could gather from your data. Some data formats are developer-friendly, and some are not. So we need to convert data to developer-friendly formats, there are many ways of doing it.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"textAlign":"center","level":5} -->
<h5 class="has-text-align-center">An example of no/low code could be AWS Glue,</h5>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>AWS Glue is a fully managed ETL (extract, transform, and load) service that makes it simple and cost-effective to categorise your data, clean it, enrich it, and move it reliably between various data stores and data streams.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>You can store your data using various AWS services and still maintain a unified view of your data using the AWS Glue Data Catalogue</strong>. Use Data Catalogue to search and discover the datasets that you own, and maintain the relevant metadata in one central repository.&nbsp;</p>
<!-- /wp:paragraph -->

<!-- wp:image {"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://d1.awsstatic.com/aws-glue-graphics/Product-page-diagram_AWS-Glue_Elixir%402x.6511bc93abc20bb7bc8d03ebe2be1cbb7f2623fe.png" alt=""/><figcaption>Image Credits: https://d1.awsstatic.com/aws-glue-graphics/Product-page-diagram_AWS-Glue_Elixir%402x.6511bc93abc20bb7bc8d03ebe2be1cbb7f2623fe.png</figcaption></figure>
<!-- /wp:image -->

<!-- wp:heading {"textAlign":"center","level":5} -->
<h5 class="has-text-align-center">Q.How does AWS Glue work?</h5>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>You define jobs in AWS Glue to do the work that's required to extract, transform, and load (ETL) data from a data source to a data target. You perform the following actions:</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>For datastore sources, you define a crawler to populate your AWS Glue Data Catalogue with metadata table definitions. <ol><li>Point your crawler at a data store, and the crawler creates table definitions in the Data Catalogue.&nbsp;</li></ol></li><li>AWS Glue can generate a script to transform your data or, you can provide the script in the AWS Glue console or API.( currently in Python and Scala scripts) </li><li>You can run your job on-demand, or you can set it up to start when a specified trigger occurs. The trigger can be a time-based schedule or an event.</li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p><strong>You use the AWS Glue console to define and orchestrate your ETL workflow</strong>. The console calls several API operations in the AWS Glue Data Catalogue and AWS Glue Jobs system to perform the following tasks:</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Define AWS Glue objects such as jobs, tables, crawlers, and connections. </li><li>Schedule when crawlers run. </li><li>Define events or schedules for job triggers. </li><li>Search and filter lists of AWS Glue objects. </li><li>Edit transformation scripts.</li></ol>
<!-- /wp:list -->

<!-- wp:image {"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://d2908q01vomqb2.cloudfront.net/b6692ea5df920cad691c20319a6fffd7a4a766b8/2018/04/17/PartitionedData2.jpg" alt=""/><figcaption>Image Credits: https://d2908q01vomqb2.cloudfront.net/b6692ea5df920cad691c20319a6fffd7a4a766b8/2018/04/17/PartitionedData2.jpg</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>If you don't prefer a No/Low code solution, you should try Pandas Library</strong>. Pandas library is great for data wrangling, and most of the data engineers will have experience with Pandas.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>For more information, feel free to listen to my session on introduction to AWS Glue where I compare No/Low code solutions to Pandas library:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li><a target="_blank" href="https://www.youtube.com/watch?v=njxWiaqlErQ&amp;t=963s" rel="noreferrer noopener">https://www.youtube.com/watch?v=njxWiaqlErQ&amp;t=963s</a></li></ol>
<!-- /wp:list -->

<!-- wp:heading {"textAlign":"center","level":3} -->
<h3 class="has-text-align-center">Q.What to do after enriching your data?</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Data visualisation helps you to visualise your data as maps or graphs and interact with them. This makes it much easier for the human mind to digest the data and thus allowing it to spot patterns and trends in a much better way. This could be either done by standard business analysis tools like Tableau or R or python. A few key benefits are,</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Identifying important trends depending on the type of visualisation can help you to determine trends over time amongst a data set.&nbsp; </li><li>Being able to spot and identify relationships within your data is key, it can help you to both drive future business decisions in the right direction and also to make corrective actions elsewhere.&nbsp; </li><li>Having a quick reference to a visualisation allows the data to collaborate with many recipients.&nbsp;</li></ol>
<!-- /wp:list -->

<!-- wp:image {"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://i.pinimg.com/originals/7a/42/8e/7a428e9a180bb7e4911d5eaab8297982.jpg" alt=""/><figcaption>Image Credits: https://i.pinimg.com/originals/7a/42/8e/7a428e9a180bb7e4911d5eaab8297982.jpg</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>There are a variety of ways to present your data, depending on what type of data you are trying to show</strong>. For each use case, there will be a specific type of chart, for example:</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>To present data that shows relationships between data points, use scatter or bubble chart. </li><li>To compare data between two or more data sets, use either a Bar, Column or Line chart.</li><li>Looking at the distribution of data across an entire data set, use a histogram.</li><li>Represent the part-to-whole relationship of a data set, use a pie chart, stacked column chart, 100% stacked column chart, or a treemap.</li></ol>
<!-- /wp:list -->

<!-- wp:image {"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://az801952.vo.msecnd.net/uploads/b9335f90-bb61-4773-899e-3927c923b9be.png" alt=""/><figcaption>Image Credits:  https://az801952.vo.msecnd.net/uploads/b9335f90-bb61-4773-899e-3927c923b9be.png</figcaption></figure>
<!-- /wp:image -->

<!-- wp:heading {"textAlign":"center","level":5} -->
<h5 class="has-text-align-center">An example of no/low code could be AWS QuickSight</h5>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Amazon QuickSight allows everyone to understand your data by asking questions in natural language, exploring through interactive dashboards, or looking for patterns and outliers powered by machine learning.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Quicksight allows you to share dashboards, email reports, and embedded analytics.</strong> By taking your data and visually displaying the questions you want to answer you can gain relevant insights into your company data</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>It allows you to draw various graphs and charts using options in User Interface. There are a lot of different options to work with. Let's cover a few terminologies</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Fields: These reflect the columns of the table in the database. </li><li>Visual Types: This is how your data will be represented. This can be from a simple sum to a chart/graph or even a heat map. </li><li>Sheets: These allow for many visuals to be stored together on a single page. To keep things simple, we'll be working with only one sheet.</li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>Try changing the Visual Type of this data and see how it's represented. You might need to add extra fields to the Field wells to make them populate correctly.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://d2908q01vomqb2.cloudfront.net/b6692ea5df920cad691c20319a6fffd7a4a766b8/2017/09/21/quicksight-sept-4.gif" alt=""/><figcaption>Image Credits: https://d2908q01vomqb2.cloudfront.net/b6692ea5df920cad691c20319a6fffd7a4a766b8/2017/09/21/quicksight-sept-4.gif</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>QuickSight, by default, has an automatic save feature enabled by default for each analysis. Personally, the case study of Quicksight in the NFL has to be one of the interesting use cases reads.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>If you don't prefer a No/Low code solution, you should try looking into MatplotLib, Seaborn, and Bokeh Library</strong>. They are great for data visualisation and most of the data engineers will have experience with them.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"textAlign":"center","level":3} -->
<h3 class="has-text-align-center">Q.How can we predict an outcome using our data?</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>After Data visualisation helps us understand patterns in data. We would like to predict/classify an outcome based on historical data.&nbsp;</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"textAlign":"center","level":5} -->
<h5 class="has-text-align-center">Q.What is Machine learning?</h5>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Machine learning is a branch of artificial intelligence (AI) and computer science which focuses on the use of data and algorithms to imitate the way that humans learn, gradually improving its accuracy.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","sizeSlug":"large"} -->
<figure class="wp-block-image aligncenter size-large"><img src="https://analyticsinsight.b-cdn.net/wp-content/uploads/2021/08/ML-System.jpg" alt=""/><figcaption>Image Credits: https://analyticsinsight.b-cdn.net/wp-content/uploads/2021/08/ML-System.jpg</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>An example of low code Machine learning solutions. When considering Machine learning solutions, there are many use cases to consider</strong>. Let us consider a few,</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Extract text and data from documents: Rather than building up your Model from scratch, you could use AWS Textract. <ol><li>Amazon Textract extracts text, handwriting, and data from scanned documents.&nbsp;</li></ol></li><li>If you want to build Chatbots, then AWS Lex would help you build chatbots.<ol><li>To design, build, test, and deploy conversational interfaces in applications using advanced natural language models.</li></ol></li><li>If you want to automate speech recognition, AWS Transcribe.&nbsp;<ol><li>An automatic speech recognition service that makes it easy to add speech to text capabilities to any application. Consider the use case of Alexa.</li></ol></li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p><strong>For more information on various machine learning general use case solutions refer to,</strong></p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li><a href="https://aws.amazon.com/machine-learning/">https://aws.amazon.com/machine-learning/</a></li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p><strong>If you don't prefer Low code solution, you should try looking into Sagemaker</strong>. They are good for computing and deploying your ML models, as you get AWS compute servers.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"textAlign":"center","level":4} -->
<h4 class="has-text-align-center">Q.What is a sagemaker?</h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>At its core, sagemaker is a fully managed service that provides the tools to build, train and deploy machine learning models. It has some components in it such as managing notebooks and helping label and train models deploy models with a variety of ways to use endpoints.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>SageMaker algorithms are available via container images</strong>. Each region that supports SageMaker has its copy of the images. You will begin by retrieving the URI of the container image for the current session's region.&nbsp;You can also utilise your  own container images for specific ML algorithms.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="http://programmerprodigycode.files.wordpress.com/2022/03/0bc53-1mfyty2swftpsulqybcgy-w.png" alt=""/><figcaption>Image Credits: http://programmerprodigycode.files.wordpress.com/2022/03/0bc53-1mfyty2swftpsulqybcgy-w.png</figcaption></figure>
<!-- /wp:image -->

<!-- wp:heading {"textAlign":"center","level":4} -->
<h4 class="has-text-align-center"><strong>Q.How can we host Sagemaker models?</strong></h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>SageMaker can host models through its hosting services. The model is accessible to the client through a SageMaker endpoint. The Endpoint is accessible over HTTPS and SageMaker Python SDK.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Another way would be using AWS Batch. <strong>It manages the processing of large datasets within the limits of specified parameters</strong>. When a batch transform job starts, SageMaker initialises compute instances and distributes the inference or pre-processing workload between them.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>In Batch Transform, you provide your inference data as an S3 URI and SageMaker will care of downloading it, running the prediction and uploading the results afterwards to S3 again.</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Batch Transform partitions the Amazon S3 objects in the input by key and maps Amazon S3 objects to an instance. To split input files into mini-batches you create a batch transform job, set the SplitType parameter value to Line. You can control the size of the mini-batches by using the BatchStrategy and MaxPayloadInMB parameters.&nbsp;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>After processing, it creates an output file with the same name and the .out file extension. The batch transforms job stores the output files in the specified location in Amazon S3, such as s3://awsexamplebucket/output/.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://d2908q01vomqb2.cloudfront.net/f1f836cb4ea6efb2a0b1b99f41ad8b103eff4b59/2019/08/21/inference-with-tensorflow-1.gif" alt=""/><figcaption>Image credits: https://aws.amazon.com/blogs/machine-learning/performing-batch-inference-with-tensorflow-serving-in-amazon-sagemaker/</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>The predictions in an output file are in the same order as the corresponding records in the input file. To combine the results of many output files into a single output file, set the AssembleWith parameter to Line.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>For more information refer,</strong></p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>https://docs.aws.amazon.com/sagemaker/latest/dg/batch-transform.html </li><li>https://docs.aws.amazon.com/sagemaker/latest/dg/how-it-works-batch.html </li><li>https://docs.aws.amazon.com/sagemaker/latest/dg/ex1-model-deployment.html#ex1-batch-transform</li></ol>
<!-- /wp:list -->

<!-- wp:heading {"textAlign":"center","level":4} -->
<h4 class="has-text-align-center">Q. How to Select the right to compute instance?</h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Choosing a Compute instance completely biased on either price or compute, might not be a good option. <strong>As you select a cheaper compute instance, it takes you about 30 mins. But if you would have selected a better compute instance, it takes 10 mins.</strong> The second alternative would have been a better alternative economically and time-based.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Some points to remember while choosing CPU and GPU will be</strong></p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>The CPU time grows proportional to the size of the matrix squared or cubed. </li><li>The GPU time grows almost linearly with the size of the matrix for the sizes used in the experiment. It can add more compute cores to complete the computation in much shorter times than a CPU. </li><li>Sometimes the CPU performs better than GPU for these small sizes. In general, GPU excel for large-scale problems. </li><li>For larger problems, GPUs can offer speedups in the hundreds. For Example, an application used for facial or object detection in an image or a video will need more computing. Hence GPUs might be a better solution.</li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p><strong>For more information, feel free to listen to my session on introduction to Algorithms and AWS Sagemaker:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>https://vimeo.com/586886985/7faddfb340</li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p><strong>For more information on Sagemaker,</strong></p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>https://aws.amazon.com/blogs/aws/sagemaker/</li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>After considering all the no/low code solutions and coding solutions.<strong> Let's consider a use case,</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>If you have a relatively small business with not that much need of customisation, then perhaps no/low code solutions. But if you want to customise your application, you would have to you coding solutions. A point to remember, depending on your datasets size, diversity and quality, you could either go for CPU(less compute) or GPU (more compute).</p>
<!-- /wp:paragraph -->