<?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>DEV Community: Abdul Raheem</title>
    <description>The latest articles on DEV Community by Abdul Raheem (@xfarooqi).</description>
    <link>https://dev.to/xfarooqi</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%2F966621%2F78f02e18-93d3-41c2-b657-f9e567790bae.png</url>
      <title>DEV Community: Abdul Raheem</title>
      <link>https://dev.to/xfarooqi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/xfarooqi"/>
    <language>en</language>
    <item>
      <title>Extractly - Turn PDFs into Data</title>
      <dc:creator>Abdul Raheem</dc:creator>
      <pubDate>Mon, 15 Sep 2025 06:50:48 +0000</pubDate>
      <link>https://dev.to/xfarooqi/extractly-turn-pdfs-into-data-1gh8</link>
      <guid>https://dev.to/xfarooqi/extractly-turn-pdfs-into-data-1gh8</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/google-ai-studio-2025-09-03"&gt;Google AI Studio Multimodal Challenge&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Extractly&lt;/strong&gt; is an AI-powered PDF extraction platform that accurately extracts text, tables, and charts from PDFs, preserving their exact format and wording.&lt;/p&gt;

&lt;p&gt;Most open-source libraries break down when faced with complex PDFs, especially SEC filings, financial reports, and compliance documents filled with dense tables and tricky formatting. Cells merge, numbers misalign, and the meaning of entire sections can be lost. Extractly fixes this problem.&lt;/p&gt;

&lt;p&gt;Extractly excels at maintaining table structures and formatting integrity. This matters because even a small misalignment in financial tables can completely change their meaning, which in turn compromises any downstream applications( especially RAG systems).&lt;/p&gt;

&lt;p&gt;With &lt;strong&gt;Extractly&lt;/strong&gt;, organizations can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reliably extract complex tables and structured data without losing fidelity.&lt;/li&gt;
&lt;li&gt;Ensure clean, LLM-ready data for training or RAG pipelines.&lt;/li&gt;
&lt;li&gt;Build production-grade AI systems that understand documents as they were intended, not as garbled text.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By bridging the gap between raw PDFs and accurate, structured data, Extractly enables a new level of trust, precision, and usability in working with critical documents.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;Original PDF Content&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Extractly Content&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6zsith6mbkg5dufxt9td.png" alt="Original PDF Content"&gt;&lt;/td&gt;
&lt;td&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzkn80ngesb4teplkn32f.png" alt="Extractly Content"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Real World Impact
&lt;/h3&gt;

&lt;p&gt;By transforming messy, unstructured PDFs into clean, structured, and reliable data, Extractly unlocks new levels of automation and insight across industries:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Finance &amp;amp; Compliance&lt;/strong&gt; → Accurate SEC filing extractions reduce hours of manual review.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Legal &amp;amp; Contracts&lt;/strong&gt; → Precise table preservation ensures no meaning is lost in negotiations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Healthcare &amp;amp; Research&lt;/strong&gt; → Extracts lab results and trial data from complex forms with high accuracy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AI &amp;amp; RAG Pipelines&lt;/strong&gt; → Produces clean, reliable data that boosts retrieval accuracy and downstream analytics.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;Live App: &lt;a href="https://extractly-505581424280.us-west1.run.app/" rel="noopener noreferrer"&gt;https://extractly-505581424280.us-west1.run.app/&lt;/a&gt;&lt;br&gt;
Video Recording: &lt;a href="https://youtu.be/rFwgBlbzGXg" rel="noopener noreferrer"&gt;https://youtu.be/rFwgBlbzGXg&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How I Used Google AI Studio
&lt;/h2&gt;

&lt;p&gt;I used Google AI Studio to quickly turn my backend into a functional app. With the app builder and Gemini 2.5 Pro code assistant, I connected my backend, generated the UI, and set up the necessary connectors in minutes.&lt;/p&gt;

&lt;p&gt;I applied prompt engineering techniques to guide the code assistant in optimizing the user experience. This included refining the UI into a more interactive design, adding components such as file download options, and rendering extracted results directly within the application.&lt;/p&gt;

&lt;p&gt;Google AI Studio saved me a lot of time I would have otherwise spent building the frontend from scratch, while still giving me the freedom to shape the app’s flow and design the way I wanted.&lt;/p&gt;

&lt;h2&gt;
  
  
  Multimodal Features
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Extractly&lt;/strong&gt; uses Gemini 2.5 Pro’s multimodal capabilities to process PDFs that contain a mix of text, tables, and images. Instead of treating a PDF as flat text, Gemini analyzes both the content and the layout, which allows Extractly to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Accurately capture tables and complex structures without losing formatting or merging cells.&lt;/li&gt;
&lt;li&gt;Preserve original document fidelity, so financial and legal documents retain their meaning.&lt;/li&gt;
&lt;li&gt;Extract multiple modalities together (text, structured data, and visuals) for a richer, more usable output.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By treating PDFs as multimodal objects (text + layout + structure), Extractly ensures that users don’t lose meaning or context when working with complex documents. For users, this means they can trust the extracted data to be LLM-ready, consistent, and production-grade without spending time on manual cleanup.&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>googleaichallenge</category>
      <category>ai</category>
      <category>gemini</category>
    </item>
    <item>
      <title>Deploy Your Static Web App on AWS S3 in just 10 Minutes</title>
      <dc:creator>Abdul Raheem</dc:creator>
      <pubDate>Sun, 15 Sep 2024 08:47:58 +0000</pubDate>
      <link>https://dev.to/aws-builders/deploy-your-static-web-app-on-aws-s3-in-just-10-minutes-23l5</link>
      <guid>https://dev.to/aws-builders/deploy-your-static-web-app-on-aws-s3-in-just-10-minutes-23l5</guid>
      <description>&lt;p&gt;I recently found myself staring at a folder full of HTML, CSS, and JavaScript files—my latest online project was about to go live. But then came the scary question: How do I launch this static web application without getting bogged down in server maintenance and complicated configurations?&lt;/p&gt;

&lt;p&gt;I wanted a solution that was easy, affordable, and scalable. I'd heard of several hosting providers, but most looked overkill for a simple static website. Upon research, I came across AWS Serverless technologies, notably Amazon S3. Skeptical yet intrigued, I decided to give it a try. I'm pleased I did because it worked out to be the ideal option.&lt;/p&gt;

&lt;p&gt;This blog will demonstrate how to solve this problem using AWS Serverless technology, specifically by leveraging Amazon S3 (Simple Storage Service) to host a static website.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding AWS Serverless
&lt;/h2&gt;

&lt;p&gt;AWS Serverless is a cloud-native development model that allows developers to build and run applications without thinking about servers. While servers still exist, AWS handles all the server settings, maintenance, and scaling. You simply focus on your website code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding Amazon S3 Buckets
&lt;/h2&gt;

&lt;p&gt;An Amazon S3 bucket is a cloud storage resource available in AWS's Simple Storage Service (S3), which is an object storage service offering scalability, data availability, security, and performance. It provides Static website hosting where you can host your application serverless.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: The homepage of your document should be specified as &lt;code&gt;index.html&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Why Use S3 Buckets for Static Websites?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Perfect for hosting HTML, CSS, JavaScript, images, and other static files.&lt;/li&gt;
&lt;li&gt;Designed for high durability.&lt;/li&gt;
&lt;li&gt;Pay only for the storage you use.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step-by-Step Guide
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Setting Up AWS Account
&lt;/h3&gt;

&lt;p&gt;An AWS account. If you don't have one, you can create a &lt;a href="https://aws.amazon.com/free/" rel="noopener noreferrer"&gt;Free AWS Account.&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Visit AWS Management Console
&lt;/h3&gt;

&lt;p&gt;Go to the &lt;a href="http://console.aws.amazon.com/" rel="noopener noreferrer"&gt;AWS Management Console&lt;/a&gt; and search for S3.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3nyrq7c5ohss9t0wsckl.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3nyrq7c5ohss9t0wsckl.png" alt=" " width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Create a new Bucket
&lt;/h3&gt;

&lt;p&gt;On the S3 homepage, you will see an option to create a new bucket for your website. Click on it.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg9qzbztdii7vsris57ok.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg9qzbztdii7vsris57ok.png" alt=" " width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Create a bucket with a default setting but be very careful while choosing the name for the bucket because it can not be changed in the future.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Upload your website to Bucket
&lt;/h3&gt;

&lt;p&gt;After creating the bucket, click on it to access the option to upload files. Click the &lt;code&gt;Upload&lt;/code&gt; button and add the website repo/folder in your bucket and upload them. Again make sure to rename your homepage as &lt;code&gt;index.html&lt;/code&gt;&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fddz6frhhphor13okyup6.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fddz6frhhphor13okyup6.png" alt=" " width="800" height="429"&gt;&lt;/a&gt;&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F05oaqn7u3rwgo6ajt0ph.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F05oaqn7u3rwgo6ajt0ph.png" alt=" " width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Click on the Website Link
&lt;/h3&gt;

&lt;p&gt;After uploading the files, you visit your website folder and there you can see all the files including &lt;code&gt;index.html&lt;/code&gt; and if you click on &lt;code&gt;Index.html&lt;/code&gt; you'll see a webpage link named as &lt;code&gt;Object URL&lt;/code&gt;.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5giwlx1o80pf2jhi70h8.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5giwlx1o80pf2jhi70h8.png" alt=" " width="800" height="429"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But clicking on it will result in the following error.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;This XML file does not appear to have any style information associated with it. The document tree is shown below.
&amp;lt;Error&amp;gt;
&amp;lt;Code&amp;gt;AccessDenied&amp;lt;/Code&amp;gt;
&amp;lt;Message&amp;gt;Access Denied&amp;lt;/Message&amp;gt;
&amp;lt;RequestId&amp;gt;04JFN7P4G3PAKWRX&amp;lt;/RequestId&amp;gt;
&amp;lt;HostId&amp;gt;Kdv84AFKxknddRTFla2/aeGypn/pqig7MRHi9QtVk1PD2IMoVAxG59+gI4+R8Svlv8fDQ7l3x6k=&amp;lt;/HostId&amp;gt;
&amp;lt;/Error&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why so?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In creating the bucket, we set the bucket permissions to not allow public read access, preventing users from accessing your files.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Update Bucket Setting
&lt;/h3&gt;

&lt;p&gt;To access our website publicly we need to do the following two things:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a. Allow Public Access&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For this, you need to visit your bucket and then click on &lt;code&gt;Permission&lt;/code&gt; and edit &lt;code&gt;Block public access (bucket settings)&lt;/code&gt; and uncheck &lt;code&gt;Block all public access&lt;/code&gt;&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flth2no4jk6056v6ofajv.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flth2no4jk6056v6ofajv.png" alt=" " width="800" height="449"&gt;&lt;/a&gt;&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0oy4ei6cky79y1bb5vyl.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0oy4ei6cky79y1bb5vyl.png" alt=" " width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;b. Update Bucket Policy&lt;/strong&gt;&lt;br&gt;
In the same permission tab, you see an option for bucket policy. On that bucket policy add the following policy and save changes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "PublicReadGetObject",
      "Effect": "Allow",
      "Principal": "*",
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::your-bucket-name/*"
    }
  ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note: You need to update your &lt;code&gt;Resource&lt;/code&gt; with your bucket name in the above code&lt;/strong&gt;&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flgpu0vf2f1vong0fv672.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flgpu0vf2f1vong0fv672.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Check Index.html
&lt;/h3&gt;

&lt;p&gt;After completing all the steps, navigate to your website folder and click on the &lt;code&gt;index.html&lt;/code&gt; file. &lt;/p&gt;

&lt;p&gt;You'll find the previous link there—click on it, and this time, you'll see your application running on a cloud serverless platform with minimal effort.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F91x35swdinfm1oy3fwmt.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F91x35swdinfm1oy3fwmt.png" alt=" " width="800" height="476"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Hosting a static website with AWS S3 is an easy and quick solution. By creating a bucket, uploading your files, and adjusting relevant settings, you can quickly deploy your site without worrying about server management. It’s a simple and efficient way to launch a static website using AWS Serverless technologies.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>staticwebapps</category>
      <category>serverless</category>
      <category>s3</category>
    </item>
    <item>
      <title>Deploy Your LLM on AWS EC2</title>
      <dc:creator>Abdul Raheem</dc:creator>
      <pubDate>Sat, 14 Sep 2024 20:31:02 +0000</pubDate>
      <link>https://dev.to/aws-builders/deploy-your-llm-on-aws-ec2-2ig3</link>
      <guid>https://dev.to/aws-builders/deploy-your-llm-on-aws-ec2-2ig3</guid>
      <description>&lt;p&gt;Ever been excited to deploy your own Large Language Model(LLM) but hit a wall because your laptop isn't up to the task? I know exactly how that feels. LLMs are powerful, but they demand a lot of computing power—something most of us just don’t have on hand.&lt;/p&gt;

&lt;p&gt;I ran into this problem myself. I wanted to create a cool application using LLMs that my friends could use, but the idea of buying an expensive GPU just to make it work was out of the question. So, I started looking for a workaround. That's when I stumbled upon AWS.&lt;/p&gt;

&lt;p&gt;Using AWS turned out to be a lifesaver. I didn’t need to invest in any fancy hardware. Instead, AWS lets you pay only for what you use. Now, I've got three different LLMs applications running on the cloud, and I didn’t have to spend a ton of money on equipment.&lt;/p&gt;

&lt;p&gt;In this post, I'll walk you through how you can set up your own LLMs on the cloud step-by-step and will share some tips to save your costs as well. If I can do it, you can too!&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;For deployment on AWS, we need to understand how LLMs compute work and which instance can be a good fit for us to go with.&lt;/p&gt;

&lt;p&gt;I will be using an LLM-based RAG application built with Streamlit, using the LLama2-7B model from Meta.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Understanding the Right resource
&lt;/h3&gt;

&lt;p&gt;Since each Large Language Model (LLM) has a different number of parameters and may use different numerical precisions, they require varying GPU capabilities for inference and fine-tuning.&lt;/p&gt;

&lt;p&gt;A simple rule of thumb to estimate how much GPU memory is needed to store the model parameters during inference of any open-source LLM is as follows:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;GPU Memory (in bytes) = Number of model parameters × Bits per parameter ÷ 8 (bits per byte)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For example, for a 7-billion-parameter model using 32-bit floating-point numbers:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GPU Memory&lt;/strong&gt; = 7,000,000,000 parameters × 32 bits per parameter ÷ 8 bits per byte&lt;br&gt;
&lt;strong&gt;GPU Memory&lt;/strong&gt; = 28,000,000,000 bytes&lt;br&gt;
&lt;strong&gt;GPU Memory&lt;/strong&gt; = 28 GB&lt;/p&gt;

&lt;p&gt;However, this requirement can be quite high. To reduce the memory footprint, we can use quantization techniques. For instance, using 4-bit quantization:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GPU Memory&lt;/strong&gt; = 7,000,000,000 parameters × 4 bits per parameter ÷ 8 bits per byte&lt;br&gt;
&lt;strong&gt;GPU Memory&lt;/strong&gt; = 3,500,000,000 bytes&lt;br&gt;
&lt;strong&gt;GPU Memory&lt;/strong&gt; = 3.5 GB&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Therefore, quantizing the model to 4 bits reduces the GPU memory requirement to approximately 3.5 GB.&lt;/strong&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  2. Which Compute To Choose?
&lt;/h3&gt;

&lt;p&gt;AWS instances like g4, g5, p3, and p4 are the latest generation of GPU-based instances and provide the highest performance in Amazon EC2 for deep learning and high-performance computing (HPC).&lt;/p&gt;

&lt;p&gt;Some examples of compute and cost are as follows:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Instance Type&lt;/th&gt;
&lt;th&gt;GPU Type&lt;/th&gt;
&lt;th&gt;GPU Memory (GB)&lt;/th&gt;
&lt;th&gt;vCPUs&lt;/th&gt;
&lt;th&gt;On-Demand Price (per hour)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;g4dn.xlarge&lt;/td&gt;
&lt;td&gt;NVIDIA T4&lt;/td&gt;
&lt;td&gt;16&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;$0.526&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;g5.xlarge&lt;/td&gt;
&lt;td&gt;NVIDIA A10G&lt;/td&gt;
&lt;td&gt;24&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;$1.006&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;p3.2xlarge&lt;/td&gt;
&lt;td&gt;NVIDIA V100&lt;/td&gt;
&lt;td&gt;16&lt;/td&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;$3.06&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;g4dn.12xlarge&lt;/td&gt;
&lt;td&gt;NVIDIA T4&lt;/td&gt;
&lt;td&gt;192&lt;/td&gt;
&lt;td&gt;48&lt;/td&gt;
&lt;td&gt;$4.344&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;g5.8xlarge&lt;/td&gt;
&lt;td&gt;NVIDIA A10G&lt;/td&gt;
&lt;td&gt;96&lt;/td&gt;
&lt;td&gt;32&lt;/td&gt;
&lt;td&gt;$8.288&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;p3.8xlarge&lt;/td&gt;
&lt;td&gt;NVIDIA V100&lt;/td&gt;
&lt;td&gt;64&lt;/td&gt;
&lt;td&gt;32&lt;/td&gt;
&lt;td&gt;$12.24&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;p4d.24xlarge&lt;/td&gt;
&lt;td&gt;NVIDIA A100&lt;/td&gt;
&lt;td&gt;320&lt;/td&gt;
&lt;td&gt;96&lt;/td&gt;
&lt;td&gt;$32.77&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h2&gt;
  
  
  Step-by-Step Guide
&lt;/h2&gt;

&lt;p&gt;Since we are aware of all the math and resources we require, let's go with deploying LLM application on AWS.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step - 1
&lt;/h3&gt;

&lt;p&gt;Search EC2 on your AWS Console. You will see a similar page for EC2.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkcd0w6rvyd6bjj9q202c.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkcd0w6rvyd6bjj9q202c.png" alt="AWS EC2" width="800" height="598"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Step - 2
&lt;/h2&gt;

&lt;p&gt;Click on Instance from the sidebar and then click on Launch Instance&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ayomkwurjfqqbimdyhh.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ayomkwurjfqqbimdyhh.png" alt="EC2 Instance" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Step - 3
&lt;/h2&gt;

&lt;p&gt;Configure the EC2 instance using the following setting and launch a new instance. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Name:&lt;/strong&gt; Your-Application-Name&lt;br&gt;
&lt;strong&gt;Amazon Machine Image (AMI):&lt;/strong&gt; Ubuntu-Latest&lt;br&gt;
&lt;strong&gt;Instance Type:&lt;/strong&gt; g4dn.xlarge&lt;br&gt;
&lt;strong&gt;Key Pair:&lt;/strong&gt; Create a New Key Pair and use that&lt;br&gt;
&lt;strong&gt;Network Setting:&lt;/strong&gt; Use default with the addition of &lt;code&gt;"Allow HTTPS traffic from the internet"&lt;/code&gt; &amp;amp; &lt;code&gt;"Allow HTTP traffic from the internet"&lt;/code&gt;&lt;br&gt;
&lt;strong&gt;Storage:&lt;/strong&gt; 16 GB&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fum1u3idwz9ta7dvs2zll.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fum1u3idwz9ta7dvs2zll.png" alt="Configure-EC2-1" width="800" height="935"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs413llg1st1wwd6ibzac.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs413llg1st1wwd6ibzac.png" alt="Configure-EC2-2" width="782" height="1230"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Step - 4 (Only For Streamlit Application)
&lt;/h2&gt;

&lt;p&gt;Go to the recently launched new instance and define some inbound roles, since we are running a streamlit application and it runs on port &lt;strong&gt;8501&lt;/strong&gt;, we have to define that rule.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmehlxft6i29ue6plgni9.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmehlxft6i29ue6plgni9.png" alt="Port Changing" width="800" height="429"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, we will click on "Edit inbound rules" and add the following Custom TCP role with port &lt;strong&gt;8501&lt;/strong&gt; and click &lt;strong&gt;save rules&lt;/strong&gt;.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7zvsm37sz2y2mw8km4r6.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7zvsm37sz2y2mw8km4r6.png" alt="Port Changing 2" width="800" height="415"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Step - 5
&lt;/h2&gt;

&lt;p&gt;Go to the recently launched EC2 page and click on the connect button and then connect your recently created instance.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft39sflxxjzxcogi9myda.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft39sflxxjzxcogi9myda.png" alt="EC2 Conf" width="800" height="475"&gt;&lt;/a&gt;&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2h9ylz65udr3mpbt14l5.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2h9ylz65udr3mpbt14l5.png" alt="EC2 Conf" width="800" height="810"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Step - 6
&lt;/h2&gt;

&lt;p&gt;Once connected you will see a terminal where you have to run the following commands to install the required dependencies and updates.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Commands:&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;sudo apt update
sudo apt-get update
sudo apt upgrade -y
sudo apt install git curl unzip tar make sudo vim wget -y
sudo apt install python3-pip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7ljv9fk9k4pcjjqi6wr7.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7ljv9fk9k4pcjjqi6wr7.png" alt="Dependencies" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step - 7
&lt;/h2&gt;

&lt;p&gt;Once downloaded all the dependencies, you need to connect with GitHub to clone(download) your streamlit application and its requirements from the GitHub repo.&lt;/p&gt;

&lt;p&gt;You can clone your repo using the following command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git clone "Your-repository"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Once cloned, you can enter your repo using the following command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;cd "Your-repository"&lt;/code&gt;&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwx39n32rc0xcuyur08f6.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwx39n32rc0xcuyur08f6.png" alt="GitHub Repo Clone" width="800" height="320"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step - 8
&lt;/h2&gt;

&lt;p&gt;First, we need to set up a virtual environment to ensure all the dependencies for the Streamlit application are installed in an isolated environment. This helps avoid conflicts with system-wide Python packages.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install python3-venv
python3 -m venv venv
source venv/bin/activate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the virtual environment is created then we need to install any requirements for the Streamlit application. For this, we will use &lt;code&gt;pip&lt;/code&gt; to read the &lt;code&gt;requirements.txt&lt;/code&gt; file and download all the libraries defined in that file.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pip install -r requirements.txt&lt;/code&gt;&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhr2ugzfykjdpiw1xz6ot.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhr2ugzfykjdpiw1xz6ot.png" alt="Requirements" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step - 9
&lt;/h2&gt;

&lt;p&gt;Once everything is installed and ready, it's time to run your LLM-based application.&lt;/p&gt;

&lt;p&gt;For this, you will run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python3 -m streamlit run &amp;lt;your-application-name&amp;gt;
python3 -m streamlit run app.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0e5xgmkopm34w2ajb4ok.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0e5xgmkopm34w2ajb4ok.png" alt="Running LLM" width="800" height="429"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you click on the external link, it will redirect to your streamlit application. And this is the public link that you can share with your friends and they can enjoy your application as well.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Voila!!!&lt;/strong&gt;&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgj50m5to6hfx4dzcewl5.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgj50m5to6hfx4dzcewl5.png" alt="Streamlit Application" width="800" height="679"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above command will run the application till your terminal is connected. Once it is closed the application will also stop working. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;To Make sure the application keeps running if the terminal is disconnected, you need to run the following command.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;code&gt;nohup python3 -m streamlit run app.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;nohup&lt;/code&gt; ensures the application keeps running even if you log out or lose your terminal session.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Deploying LLMs doesn’t have to be limited by your hardware. AWS offers a flexible, cost-effective way to harness the power of LLMs without investing in expensive GPUs. With the right instance and some optimization techniques like quantization, you can run sophisticated models in the cloud efficiently. By following this guide, you’re now equipped to deploy your own LLM-based application, making it accessible and scalable. So, dive into cloud deployment, share your innovations effortlessly, and let your application reach its full potential!&lt;/p&gt;

&lt;h2&gt;
  
  
  Reference:
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/ec2/instance-types/" rel="noopener noreferrer"&gt;https://aws.amazon.com/ec2/instance-types/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/ec2/index.html" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/ec2/index.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.streamlit.io/" rel="noopener noreferrer"&gt;https://docs.streamlit.io/&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>llm</category>
      <category>rag</category>
      <category>ec2</category>
      <category>aws</category>
    </item>
    <item>
      <title>Deequ: Your Data's BFF</title>
      <dc:creator>Abdul Raheem</dc:creator>
      <pubDate>Fri, 23 Aug 2024 12:32:14 +0000</pubDate>
      <link>https://dev.to/aws-builders/deequ-your-datas-bff-372f</link>
      <guid>https://dev.to/aws-builders/deequ-your-datas-bff-372f</guid>
      <description>&lt;p&gt;Data quality is crucial for reliable applications, whether you’re training accurate machine learning models or ensuring that your insights and decisions are based on trustworthy and accurate data. Issues like missing values, data distribution shifts, and incorrect data can lead to malfunctions, inaccurate machine-learning models, and bad business decisions. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What is Deequ and Why It’s Important?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Deequ is a library built on Apache Spark that allows you to create "unit tests for data," helping you check and measure data quality in large datasets. Deequ is used internally at Amazon to ensure the quality of various large production datasets. &lt;/p&gt;

&lt;p&gt;Where in AWS, relevant team members set data quality constraints, and the system regularly checks metrics and enforces rules, pushing datasets to ML models upon success.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1dskhb0oh9pdcfqi7pgc.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1dskhb0oh9pdcfqi7pgc.png" alt="Image Source: AWS" width="800" height="407"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The best part&lt;/strong&gt; is If we own a large number of datasets or if our dataset has many columns, it may be challenging for us to manually define appropriate constraints. Deequ can automatically generate some useful constraints by analyzing the data distribution. It begins with data profiling and then applies a series of rules to the results. We will see that in detail in the practical part. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Moreover,&lt;/strong&gt; Deequ leverages Spark to compute and provide direct access to data quality metrics like completeness and correlation through an optimized set of aggregation queries. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Purpose of Using Deequ?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Deequ's purpose is to "unit-test" data to find errors in an early stage before the data gets fed to consuming systems or machine learning algorithms. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Some of the benefits of using Deequ are as follows:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Early data error detection&lt;/li&gt;
&lt;li&gt;Improve data reliability and trustworthiness&lt;/li&gt;
&lt;li&gt;Automated data validation&lt;/li&gt;
&lt;li&gt;Improved data integrity&lt;/li&gt;
&lt;li&gt;Streamlined data profiling&lt;/li&gt;
&lt;li&gt;Integration with Spark(scalability + efficiency)&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Ideal Datasets for Deequ?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Deequ is useful for datasets that are meant to be consumed by machines or for tasks involving data analysis, or in simple words we can use Deequ for any dataset that can fit into a Spark dataframe.&lt;/p&gt;

&lt;p&gt;This includes data stored in tables, such as spreadsheets, or databases with a well-defined schema. Deequ confirms the data quality by applying pre-defined constraints or automated constraints to ensure consistency, accuracy, and completeness. It’s specifically designed for structured data with clearly defined attributes. That is why It's designed for data with a clear structure and defined attributes. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; Deequ's strength lies in handling massive datasets efficiently. Its distributed processing power will not be fully utilized with a few thousand rows dataset. Setting up and managing Spark clusters can add overhead, potentially slowing down the overall processing pipeline. The advantage of automated checks and scalability wouldn't be relevant for such a small size. Because we can achieve similar results with lower computational cost and minimal manual efforts.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Deequ excels at ensuring data quality in batch data processing rather than streaming data.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Pros &amp;amp; Cons of Deequ
&lt;/h2&gt;

&lt;p&gt;Before diving into Deequ, it’s important to weigh its pros and cons to understand how it fits your data quality needs and what challenges you might face.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pros:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Declarative API:&lt;/strong&gt; Easy to use, we specify what we expect the data to look like or behave rather than writing complex validation checks manually.&lt;br&gt;
&lt;strong&gt;Example:&lt;/strong&gt; Instead of writing complex code to check if a column has missing values, we can simply say "This column should not have missing values" in Deequ's declarative language. This makes it easier for our team to understand and maintain our data validation checks.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Metrics and Constraints:&lt;/strong&gt; Provides various data quality metrics and allows defining constraints based on those metrics for comprehensive data analysis.&lt;br&gt;
&lt;strong&gt;Example:&lt;/strong&gt; We can define constraints on the number of missing values allowed in a column (e.g., "no more than 5% missing values"). Deequ will calculate the actual percentage of missing values and compare it to our constraint, highlighting any violations. Additionally, we can define constraints for data distribution (e.g., "ensure the age column has a normal distribution"), allowing for comprehensive data analysis.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Scalability:&lt;/strong&gt; Leverages Apache Spark for distributed processing, making it efficient for big data (billions of rows).&lt;br&gt;
&lt;strong&gt;Example:&lt;/strong&gt; Imagine a dataset with billions of customer records. Validating this data locally on a single machine would be slow and impractical. Deequ utilizes Apache Spark, which distributes the data and validation tasks across multiple machines in a cluster. This allows Deequ to handle massive datasets efficiently, analyzing each record in parallel.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Automation:&lt;/strong&gt; Integrates with ML pipelines for automatic data validation, catching issues early and preventing downstream problems.&lt;br&gt;
&lt;strong&gt;Example:&lt;/strong&gt; We can integrate Deequ into our machine-learning workflow. Before training our model, Deequ automatically validates the data, catching issues like missing values or unexpected data formats. This helps prevent us from training a model on bad data, potentially leading to inaccurate results.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Open-Source:&lt;/strong&gt; Freely available and customizable to specific needs.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Cons:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Learning Curve:&lt;/strong&gt; Requires some understanding of Apache Spark and data quality concepts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Limited Out-of-the-Box Rules:&lt;/strong&gt; While Deequ offers a good set of metrics, we might need to write custom rules for complex validation needs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Overhead for Small Datasets:&lt;/strong&gt; Setting up Deequ involves some initial configuration and code writing and Cloud corporate cost if applicable. For very small datasets (like 2,000 rows), the time and effort spent setting up Deequ might outweigh the benefits of automated data validation. &lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Practical Work
&lt;/h2&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyxy7w5104s9t3ievgc4k.gif" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyxy7w5104s9t3ievgc4k.gif" alt="Funny Cat GIF From https://giphy.com/" width="480" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this practical work, we will use PyDeequ, an open-source Python wrapper over Deequ (an open-source tool developed and used at Amazon). While Deequ is written in Scala, PyDeequ allows us to use its data quality and testing capabilities from Python and PySpark, the language of choice of many data scientists.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fts1ko1j9s2v2qtgq0hu6.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fts1ko1j9s2v2qtgq0hu6.png" alt="Image Source: AWS" width="800" height="442"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can call each Deequ function using Python syntax. The wrappers translate the commands to the underlying Deequ calls and return their response.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step-by-Step Process
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Setting Up Pyspark:
&lt;/h3&gt;

&lt;p&gt;I used the &lt;a href="https://github.com/XFarooqi/deequ" rel="noopener noreferrer"&gt;PyDeequ Notebook&lt;/a&gt; and ran it in the AWS Sagemaker and set up the system using the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install necessary Python packages: pydeequ, sagemaker-pyspark, and pyspark.&lt;/li&gt;
&lt;li&gt;Download and set up Java JDK (OpenJDK 11).&lt;/li&gt;
&lt;li&gt;Set the JAVA_HOME environment variable and update the PATH.&lt;/li&gt;
&lt;li&gt;Verify Java installation.&lt;/li&gt;
&lt;li&gt;Initialize a Spark session with PyDeequ configurations.&lt;/li&gt;
&lt;/ul&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc8nbb98vdpsa82dzu0lm.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc8nbb98vdpsa82dzu0lm.png" alt="Setting Up" width="800" height="552"&gt;&lt;/a&gt;&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqx6fqqr6n329uw58lczd.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqx6fqqr6n329uw58lczd.png" alt="Setting Up" width="800" height="530"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Loading Dataset &amp;amp; Visualizing Schema:
&lt;/h3&gt;

&lt;p&gt;For the dataset, I used an open-source dataset of &lt;strong&gt;NYC TLC Trip.&lt;/strong&gt;&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8cwr1kzewrktnmx6k54b.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8cwr1kzewrktnmx6k54b.png" alt="Load Dataset" width="800" height="463"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Data Analysis:
&lt;/h3&gt;

&lt;p&gt;Before we define checks on the dataset, we want to calculate some statistics on the dataset; we call them metrics.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Favfru0n6cs7hb2t184kg.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Favfru0n6cs7hb2t184kg.png" alt="Data Analysis" width="800" height="424"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The output table shows the results of various data features, such as its size, completeness, distinct counts, mean values, compliance checks, and correlations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;From the above data metrics, we learned the following:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;Metric&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Observation&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Compliance of Long Trips&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Only 6.53% of trips are classified as long trips.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Mean Trip Distance&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The average trip distance is approximately 5.37 miles.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Dataset Size&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The dataset contains approximately 2,463,931 records.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;VendorID Completeness&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The VendorID column is 100% complete, with no missing values.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Correlation between Total Amount and Fare Amount&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;There is a very high correlation (0.9999) between total_amount and fare_amount, indicating almost perfect correlation.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Correlation between Fare Amount and Trip Distance&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;There is a very low correlation (0.0004) between fare_amount and trip_distance, indicating little to no linear relationship.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Approximate Count of Distinct VendorIDs&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;There are approximately 4 distinct values in the VendorID column.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  4. Define and Run Tests on Data:
&lt;/h3&gt;

&lt;p&gt;After analyzing the data, it's important to make sure the same properties hold in future datasets. Let's define some data quality checks to the pipeline, we can ensure every dataset is reliable for any application that uses it.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F97ygupnzh7b6cwkm5ee0.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F97ygupnzh7b6cwkm5ee0.png" alt="Run Test" width="800" height="463"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpkjuh28qt1kxiq9zarvw.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpkjuh28qt1kxiq9zarvw.png" alt="Tests Output" width="800" height="506"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Analysis&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;Check&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Outcome&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Record Count&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Passed, with over 2,000,000 entries.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Completeness&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;All columns (VendorID, payment_type, etc.) passed the completeness check.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Uniqueness&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Failed for VendorID, indicating duplicate values exist.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Value Range&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Passed for VendorID and payment_type (with 96% of payment_type values within ["1", "2"]).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Non-Negativity&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Passed for DOLocationID, PULocationID, and trip_distance.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; VendorID failed the uniqueness check, showing duplicate values. All other checks were successful.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  5. Automated Constraints Generation:
&lt;/h3&gt;

&lt;p&gt;Remember, as we discussed earlier, we can automatically generate certain data quality checks for the dataset. Let's see how it works in action.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv85cq3npyc9vbg8srguz.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv85cq3npyc9vbg8srguz.png" alt="Constraints" width="800" height="506"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, you can apply some of these constraints to your data to ensure it meets the quality standards and performs well under these checks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion:
&lt;/h2&gt;

&lt;p&gt;Deequ is a powerful tool for automating data quality checks at scale, ensuring reliable and accurate datasets for better decision-making.&lt;/p&gt;

&lt;p&gt;That’s it for today’s Deequ blog! I hope you found it insightful and learned something new. For more information, detailed documentation, and the original code, feel free to explore the following pages:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/blogs/big-data/test-data-quality-at-scale-with-deequ/" rel="noopener noreferrer"&gt;Deequ&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/blogs/big-data/testing-data-quality-at-scale-with-pydeequ/" rel="noopener noreferrer"&gt;PyDeequ&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/awslabs/deequ" rel="noopener noreferrer"&gt;Deequ GitHub Repository&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/awslabs/python-deequ" rel="noopener noreferrer"&gt;Python-Deequ GitHub Repository&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>deeque</category>
      <category>aws</category>
      <category>data</category>
      <category>analytics</category>
    </item>
    <item>
      <title>Mastering Amazon ECS: Key Building Blocks Explained</title>
      <dc:creator>Abdul Raheem</dc:creator>
      <pubDate>Thu, 13 Jul 2023 08:10:01 +0000</pubDate>
      <link>https://dev.to/xfarooqi/mastering-amazon-ecs-key-building-blocks-explained-538l</link>
      <guid>https://dev.to/xfarooqi/mastering-amazon-ecs-key-building-blocks-explained-538l</guid>
      <description>&lt;p&gt;Amazon Elastic Container Service (ECS) is a comprehensive managed service offered by AWS, specifically designed to facilitate the seamless execution of containers in the cloud environment. ECS relieves developers from the burden of configuring intricate infrastructure settings, enabling them to focus solely on their application code. Whether it involves deploying a straightforward website or orchestrating elaborate distributed microservices with an extensive container fleet, ECS streamlines the entire process effortlessly.&lt;/p&gt;

&lt;p&gt;Getting started with ECS is straightforward. To fully understand how it works and how you can use it, it helps to understand the basic building blocks of ECS and how they fit together!&lt;/p&gt;

&lt;h2&gt;
  
  
  Amazon EC2
&lt;/h2&gt;

&lt;p&gt;First, we need to understand EC2 building blocks because when it comes to launching your containerized applications with Amazon ECS, you have the flexibility to choose between two launch types: EC2 and Fargate. While both options offer powerful capabilities, Fargate takes container management to the next level by abstracting away the complexities of Amazon EC2 instances. With Fargate, you can shift your focus towards managing tasks, rather than worrying about the underlying infrastructure components. In this blog post, we'll delve into the key features and benefits of both launch types, highlighting the advantages of Fargate's simplified approach to containerization within ECS.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhhisffmxxpajbjq16ll7.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhhisffmxxpajbjq16ll7.png" alt=" " width="800" height="649"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Instance
&lt;/h3&gt;

&lt;p&gt;EC2 instances serve as reliable virtual machines (VMs) that offer a wide range of benefits. Notably, you can seamlessly connect to these instances using SSH, ensuring efficient management and control over your containerized applications. The beauty of EC2 lies in its ability to accommodate diverse customer requirements, encompassing memory, storage, and computing power. With numerous instance types available, you can easily find the perfect fit for your specific needs. If you're looking to run a small application or explore a free trial, the t2.micro instance type is an excellent choice. On the other hand, for memory-intensive workloads, options like R3 and X1 instances provide optimal performance. Furthermore, there is a rich assortment of additional instance types tailored to cater to a wide array of use cases.&lt;/p&gt;

&lt;p&gt;With this multitude of EC2 instance types at your disposal, Amazon ECS empowers you to select the ideal configuration that aligns with your application's requirements. Whether you seek lightweight experimentation or robust, memory-optimized operations, EC2 instances offer the flexibility and scalability needed to fulfill your computing needs effectively.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. AMI
&lt;/h3&gt;

&lt;p&gt;AMI stands for Amazon Machine Image. In simple terms, an AMI acts as a vital source of information required to launch an instance. It encompasses critical aspects such as the root volume, launch permissions, and volume-attachment specifications. When it comes to AMI selection, you have multiple options at your disposal. &lt;strong&gt;AWS offers a variety of Linux and Windows AMIs that you can readily leverage.&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Alternatively, you can explore AMIs created and shared by the vibrant user community or browse through the extensive offerings in the AWS Marketplace. For instance, you might consider the Amazon ECS-Optimized AMI specifically designed to enhance ECS deployments. Additionally, if none of the existing options meet your requirements, you can even create your own custom AMI. By carefully choosing the appropriate AMI, you lay a solid foundation for successful instance creation within Amazon ECS. This step ensures that your instances possess the necessary configurations, permissions, and specifications to support your desired workload effectively.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Region
&lt;/h3&gt;

&lt;p&gt;The expansive world of AWS is divided into regions, encompassing distinct geographic areas across the globe. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;These regions include us-east-1 (N. Virginia), us-west-2 (Oregon), eu-central-1 (Frankfurt), ap-northeast-1 (Tokyo), and many more.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Each AWS region is meticulously designed to ensure complete isolation from one another. They consist of multiple independent data centers, forming an intricate network that creates a substantial "blast radius" in the event of failure. This means that even if an entire region experiences an outage, the others remain unaffected, safeguarding your operations from widespread disruptions. By strategically choosing the appropriate AWS region, you will have a solid foundation for your ECS operations, ensuring reliable and efficient container management within a geographically optimized environment.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Availability Zone
&lt;/h3&gt;

&lt;p&gt;AWS regions are further divided into distinct units called Availability Zones. Each region comprises a minimum of two zones, and in some cases, multiple zones are available. These zones are physically isolated from one another and encompass different data centers within the region. However, they are interconnected via high-speed, low-latency fiber-optic networks and share certain underlying facilities.&lt;/p&gt;

&lt;p&gt;The design of EC2 emphasizes mitigating the impact of common failures, ensuring that they are contained within a single zone and do not result in region-wide outages. By distributing your services across multiple zones and distributing workloads across hosts, you can achieve a high level of availability within a region.&lt;/p&gt;

&lt;p&gt;This architecture provides a robust and fault-tolerant infrastructure, enabling you to design resilient applications that can withstand failures at the zone level. By strategically leveraging multiple Availability Zones, you can enhance the availability and reliability of your AWS services, ultimately delivering a seamless experience to your users.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Virtual Private Network(VPS)
&lt;/h3&gt;

&lt;p&gt;The Amazon EC2-VPC (Elastic Compute Cloud - Virtual Private Cloud) capability allows you to construct a logically isolated virtual network environment within the AWS cloud. It gives you complete control over your virtual networking resources and allows you to customise and adjust your network settings to meet your individual needs.&lt;/p&gt;

&lt;p&gt;Here are some key aspects and benefits of EC2-VPC:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Isolation and Security:&lt;/strong&gt; EC2-VPC enables logical isolation from other networks, enhancing security and privacy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Subnets:&lt;/strong&gt; Divide your virtual network into subnets for IP address allocation and network segmentation, improving security and resource management.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Routing:&lt;/strong&gt; Manage routing tables to control traffic flow between subnets and the internet, allowing for complex network architectures.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Internet Gateway:&lt;/strong&gt; Facilitate outbound internet access and inbound traffic from the internet with an internet gateway.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Security Groups:&lt;/strong&gt; Define virtual firewalls to control inbound and outbound traffic at the instance level, ensuring network security.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Network ACLs:&lt;/strong&gt; Implement stateless packet filters at the subnet level to add an extra layer of network security.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Amazon ECS building blocks
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Containers
&lt;/h3&gt;

&lt;p&gt;The most important block of ECS are the containers. There is a huge misconception that containers are virtual machine but they are not. While virtual machines virtualize the hardware, containers take virtualization a step further by virtualizing the operating system. Containers are composed of processes running on the host system, interconnected through kernel constructs like namespaces and cgroups. However, the detailed inner workings of containers are not necessary to discuss in this post.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdslovhpzo9lyxw0hd7b8.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdslovhpzo9lyxw0hd7b8.png" alt=" " width="508" height="300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Why We Need Containers?
&lt;/h3&gt;

&lt;p&gt;Containers provide a game-changing capability of building, shipping, and running your code effortlessly across diverse environments.&lt;/p&gt;

&lt;p&gt;In the pre-cloud era, self-hosting necessitated the purchase of physical machines, setting up and configuring the operating system (OS), and finally executing your code. However, with the advent of virtualization in the cloud, the process became streamlined by eliminating the hardware concerns and allowing direct focus on OS setup and code execution. Containers take this convenience a step further by simplifying the process to just running your code.&lt;/p&gt;

&lt;h4&gt;
  
  
  Advantages
&lt;/h4&gt;

&lt;p&gt;A key advantage of containers is their ability to package all dependencies along with the code in what is known as an image. This self-contained package enables containers to be deployed on any host machine seamlessly. From an external perspective, hosts appear as holders of multiple containers, all sharing a generic nature that allows them to be deployed on any host.&lt;/p&gt;

&lt;p&gt;Within the realm of ECS, you can effortlessly run your containerized code and applications across a managed cluster of EC2 instances. This powerful capability empowers you to leverage the scalability and flexibility of AWS infrastructure while seamlessly managing and orchestrating your containerized workloads.&lt;/p&gt;

&lt;h3&gt;
  
  
  Container instance
&lt;/h3&gt;

&lt;p&gt;An ECS container instance possesses distinct characteristics, including a precisely defined IAM policy and role, tailored to facilitate seamless integration with the ECS service. Additionally, these container instances are registered into your ECS cluster, forming an essential part of the overall infrastructure.&lt;/p&gt;

&lt;p&gt;As you may have anticipated, within these instances, containers come into play. It is within the ECS container instances that you execute and manage your containerized workloads, leveraging the flexibility and scalability provided by the underlying EC2 infrastructure. By understanding the unique composition of ECS container instances and their pivotal role in the ECS ecosystem, you can harness the power of containerization to effectively deploy and orchestrate your applications with ease and precision.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cluster
&lt;/h3&gt;

&lt;p&gt;In ECS, an ECS cluster is a grouping of container instances* (or tasks in the case of Fargate) within a specific AWS region. These clusters can span multiple Availability Zones, offering redundancy and resilience.&lt;/p&gt;

&lt;p&gt;When launching an instance (or tasks in the case of Fargate) within ECS, it automatically registers with the default cluster named "default" unless specified otherwise. If the default cluster doesn't exist, ECS creates it on the fly. Additionally, you have the flexibility to scale and delete your clusters based on your requirements. ECS clusters provide a streamlined approach to container management, enabling efficient organization and control over your container instances or tasks. By leveraging clusters, you can enhance the reliability and scalability of your containerized applications within the ECS environment.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdtzrqxl2waein8444qg1.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdtzrqxl2waein8444qg1.png" alt=" " width="800" height="348"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Agent
&lt;/h3&gt;

&lt;p&gt;The Amazon ECS container agent, a Go program, operates within its own container on each EC2 instance used with ECS. It serves as the intermediary component, facilitating communication between the scheduler and your instances. Running the agent on your instance is necessary for registering it into a cluster, which provides both a logical boundary and a resource pool.&lt;/p&gt;

&lt;h3&gt;
  
  
  Task &amp;amp; Task Definition
&lt;/h3&gt;

&lt;p&gt;In ECS, containers are executed as part of a task, necessitating the creation of a task beforehand. Tasks serve as a logical grouping of 1 to N containers that run together on the same instance. The value of N can be up to 10 containers.&lt;/p&gt;

&lt;p&gt;However, we can't create a task directly. Instead, you must create a task definition, which specifies the composition of the task. It's comparable to an architectural plan for a city. A task definition defines which containers are part of the task and includes details about container interaction, CPU and memory constraints, and task permissions using IAM roles.&lt;/p&gt;

&lt;p&gt;Once you have a task definition, you can instruct ECS to start a task using that specific definition. While it may seem like extra planning initially, as you encounter scenarios involving multiple tasks, scaling, upgrades, and other real-life situations, the value of task definitions becomes evident. They provide a systematic approach to manage and track tasks within ECS, ensuring efficient container execution and orchestration.&lt;/p&gt;

&lt;h3&gt;
  
  
  Scheduler
&lt;/h3&gt;

&lt;p&gt;The ECS scheduler is a vital component of the hosted orchestration layer provided by ECS. In simple terms, hosted means that ECS takes care of managing the scheduler on your behalf, saving you from the hassle of handling it yourself. While your applications run in containers on your instances, ECS manages the tasks for you, alleviating your concerns.&lt;/p&gt;

&lt;p&gt;The scheduler's role is to decide which containers run on which instances based on specific constraints. For instance, if you need to scale a custom blog engine for high availability, you can create a service that automatically distributes tasks across all zones in your chosen region. By using the distinctInstance task placement constraint, you can ensure that each task runs on a different instance. ECS not only handles these assignments but also takes care of automatically restarting failed tasks.&lt;/p&gt;

&lt;p&gt;With the ECS scheduler, you can focus on your applications, knowing that the task assignment and management are being efficiently handled. This simplifies the process of scaling, distribution, and ensuring high availability for your containerized workloads. Let ECS do the heavy lifting, while you enjoy the benefits of a simplified and streamlined container orchestration experience.&lt;/p&gt;

&lt;h3&gt;
  
  
  Service
&lt;/h3&gt;

&lt;p&gt;A service in ECS is a unique concept that allows you to specify the desired number of tasks to be running at any given time, based on a specific task definition. If you set N=1, it means "ensure that this task is running and restart it if necessary!" This ensures that your task remains operational, with ECS automatically monitoring and restarting it if needed. On the other hand, with N &amp;gt; 1, you can effectively scale your application by running multiple instances of the task, while still ensuring that each task remains running.&lt;/p&gt;

&lt;p&gt;By leveraging ECS services, you can simplify the management and scaling of your application tasks. ECS takes care of the underlying orchestration, enabling you to focus on developing and deploying your applications with confidence. Whether you need a single task or multiple instances running, ECS services provide a convenient mechanism for achieving seamless task management and scaling capabilities.&lt;/p&gt;

&lt;h3&gt;
  
  
  Load Balancer
&lt;/h3&gt;

&lt;p&gt;Amazon ECS distributes incoming traffic among numerous containers or jobs by interacting with Elastic Load Balancing (ELB). This connection enables you to expose your containerized applications to the internet or internal networks, allowing for increased availability and scalability. ECS provides customizable load balancing mechanisms adapted to your application's individual demands, whether you choose Application Load Balancers (ALBs) for advanced routing and HTTP/HTTPS traffic or Network Load Balancers (NLBs) for high-performance load balancing at the transport layer. This ECS/ELB combo ensures that your application can handle increased traffic volumes, optimises resource utilisation, and provides fault tolerance for a resilient and responsive user experience.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;In this blog post, we explored the key concepts and components of Amazon Elastic Container Service (ECS). We learned that ECS provides a managed environment for running containers in the cloud, eliminating the complexities of infrastructure configuration. By leveraging ECS, you can easily deploy and manage containers, whether it's for hosting a simple website or running complex distributed microservices.&lt;/p&gt;

&lt;p&gt;We discussed the importance of understanding ECS building blocks such as clusters, instances, tasks, and services. Clusters act as logical groupings of container instances, while tasks represent a grouping of containers running together on the same instance. Services simplify task management and scaling, ensuring the desired number of tasks are running at all times.&lt;/p&gt;

&lt;p&gt;Additionally, we touched upon the role of the ECS scheduler, which automates the allocation of containers to instances based on defined constraints. The scheduler plays a crucial part in achieving high availability, scalability, and efficient resource utilization.&lt;/p&gt;

&lt;p&gt;You can explore more on ECS from following:&lt;/p&gt;

&lt;p&gt;Amazon ECS Documentation: &lt;a href="https://docs.aws.amazon.com/ecs" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/ecs&lt;/a&gt;&lt;br&gt;
AWS Blog On Containers: &lt;a href="https://aws.amazon.com/blogs/containers" rel="noopener noreferrer"&gt;https://aws.amazon.com/blogs/containers&lt;/a&gt;&lt;br&gt;
AWS ECS GitHub Repository: &lt;a href="https://github.com/aws/amazon-ecs-agent" rel="noopener noreferrer"&gt;https://github.com/aws/amazon-ecs-agent&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Machine Learning 101: A Comprehensive Guide for Beginners</title>
      <dc:creator>Abdul Raheem</dc:creator>
      <pubDate>Mon, 23 Jan 2023 16:07:18 +0000</pubDate>
      <link>https://dev.to/xfarooqi/machine-learning-101-a-comprehensive-guide-for-beginners-4lbp</link>
      <guid>https://dev.to/xfarooqi/machine-learning-101-a-comprehensive-guide-for-beginners-4lbp</guid>
      <description>&lt;p&gt;Machine learning is a method of teaching computers to learn from data, without being explicitly programmed. It is a subset of artificial intelligence that focuses on the development of algorithms and statistical models that can enable machines to improve their performance on a specific task by learning from data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Application:&lt;/strong&gt;&lt;br&gt;
In the real world, machine learning is used in a wide range of applications. Some examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Self-driving cars, which use supervised learning to learn how to drive safely and efficiently.&lt;/li&gt;
&lt;li&gt;Image and speech recognition, which use supervised learning to identify objects and transcribe speech.&lt;/li&gt;
&lt;li&gt;Fraud detection, which uses supervised learning to identify suspicious transactions.&lt;/li&gt;
&lt;li&gt;Recommendation systems, which use unsupervised learning to suggest products or content to users.&lt;/li&gt;
&lt;li&gt;Robotics, which use reinforcement learning to train robots to perform tasks such as grasping objects or walking.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How Machine Learning Works
&lt;/h2&gt;

&lt;p&gt;The process of machine learning typically involves the following steps:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1 - Collecting and preparing the data:&lt;/strong&gt; This step involves acquiring the data, cleaning it, and transforming it into a format that can be used by the machine learning algorithm.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2 - Choosing a model:&lt;/strong&gt; This step involves selecting a machine learning algorithm that is appropriate for the task at hand.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3 - Training the model:&lt;/strong&gt; This step involves using the labeled data to train the model, so that it can make accurate predictions on new data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4 - Evaluating the model:&lt;/strong&gt; This step involves using a separate dataset to evaluate the model's performance, and making adjustments as needed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5 - Deploying the model:&lt;/strong&gt; This step involves using the trained model to make predictions on new data, or using it to control a system in the real world.&lt;/p&gt;




&lt;h2&gt;
  
  
  Main Types of Machine Learning
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Supervised
&lt;/h3&gt;

&lt;p&gt;Supervised learning is a type of machine learning where the computer is given a labeled dataset, and the goal is to train a model to make predictions on new, unseen data. The model learns to make predictions about unseen data by finding patterns in the training data. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
One of the most common application of supervised machine learning model is to classify the different types of objects. For Example, in the figure below, we can see that there are some labeled data of square, triangle and hexagon and supervised machine learning model will tell us whether a new object will be square or triangle or hexagon based on its learning with the dataset.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbi6a2afb2xreovoym911.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbi6a2afb2xreovoym911.png" alt="Himanshu Singh @ Medium" width="600" height="300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Some other examples of supervised learning tasks include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Image classification&lt;/li&gt;
&lt;li&gt;Spam detection&lt;/li&gt;
&lt;li&gt;Predicting stock prices&lt;/li&gt;
&lt;li&gt;Predict whether a person is likely to develop a certain medical condition based on their age, sex, and other factors&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Supervised Machine Learning Models:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are several types of models used in supervised machine learning, including:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Linear Regression:&lt;/strong&gt; Linear regression is a statistical model that is used for predicting a continuous value. It works by finding the best-fitting line through the data points. Real-world examples include: Sales forecasting, Inventory prediction&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Logistic Regression:&lt;/strong&gt; Logistic regression is a statistical model that is used for binary classification tasks, such as determining if an email is spam or not. Real-world examples include: Medical diagnosis, Credit scoring&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Decision Trees:&lt;/strong&gt; A decision tree is a tree-like model that makes decisions based on a series of conditions. It is commonly used for classification and regression tasks. Real-world examples include: Credit scoring, Medical diagnosis&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Random Forest:&lt;/strong&gt; A random forest is an ensemble of decision trees, where each tree is trained on a different subset of the data. The final output is the average of the outputs of all the decision trees. Random forest is commonly used for classification and regression tasks. Real-world examples include: Stock market analysis, Quality control&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Support Vector Machines (SVMs):&lt;/strong&gt; SVMs are a type of model that can be used for both classification and regression tasks. They work by finding a line (or hyperplane) that maximally separates the different classes in the data. Real-world examples include: Handwriting recognition, Gene expression classification&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Neural Networks:&lt;/strong&gt; Neural networks are a type of model that are inspired by the structure and function of the human brain. They are commonly used for image and speech recognition, natural language processing, and other complex tasks. Real-world examples include: Image recognition, Speech recognition, Natural Language Processing&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Summary:&lt;/strong&gt; In supervised machine learning, different models have different use cases and are good at different types of problems. It is important to understand the characteristics and assumptions of each model and choose the appropriate one for the specific problem at hand.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  2. Unsupervised
&lt;/h3&gt;

&lt;p&gt;Unsupervised learning is a type of machine learning where the model is not provided with labeled data, and the goal is to find patterns or relationships in the input data by its own. It is used to discover hidden structure or features in data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
In fruit detection model, we didn't give any label to any of the food to the model. But the model check the characteristics and similarity of the object in dataset and based on that similarity it distinguish the dataset into two parts as shown in the figure. If a new fruit is given to the machine learning model, it will not tell it is apple or orange rather it put that object in one of the category.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foccjg3piggeqdrxdds0i.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foccjg3piggeqdrxdds0i.png" alt=" " width="800" height="441"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Some other examples of unsupervised learning tasks include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Clustering satellite images to identify distinct features in landscapes&lt;/li&gt;
&lt;li&gt;Anomaly detection in manufacturing process to identify faulty equipment&lt;/li&gt;
&lt;li&gt;Identifying patterns in genetic data for disease diagnosis&lt;/li&gt;
&lt;li&gt;Grouping customers by purchase history for targeted marketing&lt;/li&gt;
&lt;li&gt;Identifying patterns in network traffic for cybersecurity&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Unsupervised Machine Learning Models:&lt;/strong&gt;&lt;br&gt;
There are several types of models used in unsupervised machine learning, including:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;K-Means:&lt;/strong&gt; K-means is a clustering algorithm that groups similar data points together. It is used for tasks such as market segmentation and image segmentation. Real-world examples include: Customer segmentation, Image segmentation&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hierarchical Clustering:&lt;/strong&gt; Hierarchical Clustering is a method of clustering which builds a hierarchy of clusters. It is used for tasks such as image segmentation and gene expression analysis. Real-world examples include: Image segmentation, Gene expression analysis&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Principal Component Analysis (PCA):&lt;/strong&gt; PCA is a technique used for dimensionality reduction. It works by finding the principal components of the data, which are the directions of maximum variance. Real-world examples include: Face recognition, Handwriting recognition&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Autoencoder:&lt;/strong&gt; Autoencoder is a neural network used for dimensionality reduction and feature learning. It works by learning a compressed representation of the input data. Real-world examples include: anomaly detection, speech recognition&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Self-Organizing Maps (SOMs):&lt;/strong&gt; SOMs are a type of neural network that is used for visualization and dimensionality reduction. It projects high-dimensional data onto a 2-dimensional grid, preserving the topological structure of the data. Real-world examples include: Fraud detection, Quality control&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Generative Adversarial Networks (GANs):&lt;/strong&gt; GANs are a type of model composed of two neural networks: a generator and a discriminator. The generator creates new data samples that are similar to the training data, while the discriminator attempts to distinguish the generated data from the real data. Real-world examples include: Image synthesis, Text-to-speech&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Summary:&lt;/strong&gt;&lt;br&gt;
Unsupervised machine learning models are good at finding hidden structure and patterns in data, and can be used in a wide range of applications. But it's important to understand the assumptions and limitations of each algorithm and choose the appropriate one for the specific problem at hand.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  3.Reinforcement
&lt;/h3&gt;

&lt;p&gt;Reinforcement learning is a type of machine learning where the computer learns through trial and error. The goal is to train an agent to make decisions that will maximize a reward signal. For example, a reinforcement learning algorithm could be used to train a robot to navigate a maze by receiving a reward for reaching the end and a penalty for hitting a wall.&lt;/p&gt;

&lt;p&gt;Some examples of reinforcement learning tasks include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Training autonomous vehicles to navigate in complex environments&lt;/li&gt;
&lt;li&gt;Improving energy efficiency in data centers&lt;/li&gt;
&lt;li&gt;Training robots to perform tasks such as grasping objects or walking&lt;/li&gt;
&lt;li&gt;Improving the performance of recommendation systems&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Reinforcement Machine Learning Models:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are several types of models used in reinforcement learning, including:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q-Learning:&lt;/strong&gt; Q-learning is a model-free algorithm that learns the optimal policy by estimating the value of each state-action pair. It's used for tasks such as game playing and robotics. Real-world examples include: Game playing, Robotics&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SARSA:&lt;/strong&gt; SARSA is a model-free algorithm that learns the optimal policy by estimating the value of each state-action pair. It's used for tasks such as game playing and robotics. Real-world examples include: Game playing, Robotics&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Policy Gradient Methods:&lt;/strong&gt; Policy gradient methods are a class of algorithms that optimize the policy directly, by gradient descent. It's used for tasks such as robotics and game playing. Real-world examples include: Robotics, Game playing&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Deep Deterministic Policy Gradient (DDPG):&lt;/strong&gt; DDPG is a variant of policy gradient methods that use a deep neural network as a function approximator. It's used for tasks such as robotics and game playing. Real-world examples include: Robotics, Game playing&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Proximal Policy Optimization (PPO):&lt;/strong&gt; PPO is an optimization algorithm that uses a trust region update to improve the policy. It's used for tasks such as robotics and game playing. Real-world examples include: Robotics, Game playing&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Summary:&lt;/strong&gt;&lt;br&gt;
Reinforcement learning has been used to train agents to play games at a superhuman level, to control robots to perform complex tasks, and to drive cars in simulated environments. But it's important to understand that the success of RL depends on the quality of the reward function, which can be difficult to design.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;Machine learning is a rapidly growing field with many potential applications, and it has the potential to revolutionize many industries. With the increasing amount of data being generated, machine learning has the ability to analyze, understand and make predictions that can have significant impact in many areas such as healthcare, finance, education, transportation and many more. The future of machine learning is bright and it is expected to continue to evolve and play an increasingly important role in shaping the way we live and work.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;Follow Me For More Such Content | &lt;a href="https://linktr.ee/abdulraheem01" rel="noopener noreferrer"&gt;My Social Links&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>SQL Queries That Every Data Scientist Should Know!</title>
      <dc:creator>Abdul Raheem</dc:creator>
      <pubDate>Mon, 23 Jan 2023 09:37:12 +0000</pubDate>
      <link>https://dev.to/xfarooqi/sql-queries-that-every-data-scientist-should-know-39a2</link>
      <guid>https://dev.to/xfarooqi/sql-queries-that-every-data-scientist-should-know-39a2</guid>
      <description>&lt;h2&gt;
  
  
  What is SQL
&lt;/h2&gt;

&lt;p&gt;SQL (Structured Query Language) is a programming language used to manage and manipulate relational databases. It is used to insert, update, and retrieve data from databases, as well as to create, modify, and manage database structures. In simple terms, &lt;strong&gt;SQL&lt;/strong&gt; is a way to talk to databases and get information from them or put information into them. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In Data science, we used SQL to read data and manipulate it to get our desired result.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt; &lt;br&gt;
Let's say you have a database of all the students in your school, and each student has a name, an age, and a grade level. You could use SQL to ask the database for a list of all the names of the students in your grade. Or you could use SQL to change a student's grade level if they got promoted.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why we should use SQL?&lt;/strong&gt;&lt;br&gt;
SQL is the most common and easy method to access data in databases. In Data science, we will use SQL to read data and manipulate it to get our desired result. Here we will be focused on manipulating data rather than the creation and removal of data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Some Key Features of SQL&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Easy to understanding-&lt;/strong&gt; SQL is a simple and intuitive language to learn and use.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Direct data access-&lt;/strong&gt; Traditional databases allow users to easily access and retrieve specific data.&lt;/li&gt;
&lt;li&gt;Data audit and replication: It is easy to audit and replicate data in traditional databases.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Multi-table analysis-&lt;/strong&gt; SQL is powerful for analyzing data from multiple tables at once.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Complex analysis-&lt;/strong&gt; SQL allows users to analyze more complex data and questions than dashboard tools like Google Analytics.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  SQL Queries
&lt;/h2&gt;

&lt;p&gt;To understand and execute queries first we need to configure &lt;a href="https://dev.to/xfarooqi/how-to-configure-pgadmin-to-run-sql-queries-1k24"&gt;Parch and Posy Database&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Database Schema:&lt;/strong&gt;&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7wvcnqi5b3utqhgq2hhy.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7wvcnqi5b3utqhgq2hhy.png" alt=" " width="434" height="296"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. SELECT &amp;amp; From&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This statement is used to query a database and retrieve specific data from one or more tables. It is one of the most commonly used SQL commands. The basic syntax of this statement is as follows:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Query&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;SELECT column1, column2 From table_name;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In this query, the &lt;strong&gt;SELECT&lt;/strong&gt; keyword is used to specify that you want to retrieve data from the database. The column1, column2, ... are the names of the columns that you want to retrieve data from. You can also use the * wildcard to select all columns. The &lt;strong&gt;FROM&lt;/strong&gt; keyword is used to specify the table that you want to retrieve data from.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Query&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;SELECT * FROM orders;&lt;/code&gt;&lt;br&gt;
This statement will retrieve all the &lt;strong&gt;columns&lt;/strong&gt; in the &lt;strong&gt;order&lt;/strong&gt; table as shown in figure below.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb6kuf1q12camp9osmgc9.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb6kuf1q12camp9osmgc9.png" alt=" " width="800" height="707"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. LIMIT&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The LIMIT statement allows you to retrieve only a specific number of rows from a table, which can be useful when you only need to see the initial data and don't need to load the entire dataset. This can be much quicker for loading, as it reduces the amount of data that needs to be loaded.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;LIMIT Statement will always used at the last of query.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Query&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;SELECT * FROM orders LIMIT 10;&lt;/code&gt;&lt;br&gt;
This command will limit first 10 rows of all the columns of table.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8asrjvma4oxv9e3e9y9d.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8asrjvma4oxv9e3e9y9d.png" alt=" " width="800" height="709"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. ORDER BY&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;ORDER BY&lt;/strong&gt; statement in SQL allows sorting of query results based on data in any column. However, the sorting effect is only temporary and specific to that query, unlike sorting in spreadsheet software which permanently alters the data. This difference highlights the purpose of a SQL query.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;DESC&lt;/code&gt; can be used after the column in your &lt;strong&gt;ORDER BY&lt;/strong&gt; statement to sort column in descending order, as the default &lt;strong&gt;ORDER BY&lt;/strong&gt; query will sort in ascending order.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Query&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;SELECT id, sales_rep_id&lt;br&gt;
FROM accounts&lt;br&gt;
ORDER BY id&lt;br&gt;
LIMIT 10;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In this statement the columns in the table will be sorted in ascending order with respect to &lt;strong&gt;id&lt;/strong&gt; column.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frphed1mc7vdw9z5viykq.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frphed1mc7vdw9z5viykq.png" alt=" " width="800" height="702"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can even sort by multiple columns using &lt;code&gt;ORDER BY&lt;/code&gt; by providing a list of columns. The sorting process first uses the leftmost column in the list, then the next column and so on. Additionally, it is still possible to reverse the order using the &lt;code&gt;DESC&lt;/code&gt; keyword.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Query&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;SELECT  account_id, total_amt_usd&lt;br&gt;
FROM orders&lt;br&gt;
ORDER By account_id, total_amt_usd DESC;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Here &lt;code&gt;account _id&lt;/code&gt; will be sorted in ascending order as usual and &lt;code&gt;total_amt_usd&lt;/code&gt; will be sorted in descending order as shown in figure below.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fektei9b8purz6p6md6s3.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fektei9b8purz6p6md6s3.png" alt=" " width="800" height="705"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. WHERE&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The WHERE statement in SQL is used to filter the results of a query. It allows you to specify certain conditions that the data in your query must meet in order to be included in the final output. &lt;/p&gt;

&lt;p&gt;Common symbols used in WHERE statements include:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;&amp;gt;&lt;/code&gt; (greater than) &lt;br&gt;
&lt;code&gt;&amp;lt;&lt;/code&gt; (less than)&lt;br&gt;
&lt;code&gt;&amp;gt;=&lt;/code&gt;(greater than or equal to)&lt;br&gt;
&lt;code&gt;&amp;lt;=&lt;/code&gt;(less than or equal to)&lt;br&gt;
&lt;code&gt;=&lt;/code&gt;(equal to)&lt;br&gt;
&lt;code&gt;!=&lt;/code&gt;(not equal to)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Query&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;SELECT *&lt;br&gt;
FROM orders&lt;br&gt;
WHERE account_id = 4251&lt;br&gt;
ORDER BY occurred_at&lt;br&gt;
LIMIT 1000;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In this statement, we are extracting the information, where account_id is equal to 4251.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F04yr1ev05x339p5qtpcl.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F04yr1ev05x339p5qtpcl.png" alt=" " width="800" height="710"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;WHERE&lt;/code&gt; statement will work with non-numeric data as well.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Query&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;SELECT *&lt;br&gt;
FROM accounts&lt;br&gt;
WHERE name = 'Walmart;'&lt;/code&gt;&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxtub0s1m3isaqm0tgzdf.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxtub0s1m3isaqm0tgzdf.png" alt=" " width="800" height="710"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Arithmetic Operators
&lt;/h2&gt;

&lt;p&gt;In SQL, arithmetic operators are used to perform mathematical operations on values in a query. The most common arithmetic operators in SQL are:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;*&lt;/code&gt; (Multiplication)&lt;br&gt;
&lt;code&gt;+&lt;/code&gt; (Addition)&lt;br&gt;
&lt;code&gt;-&lt;/code&gt; (Subtraction)&lt;br&gt;
&lt;code&gt;/&lt;/code&gt; (Division)&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Order of all the arithmetic operation will follow PADMAS rule&lt;/p&gt;
&lt;/blockquote&gt;


&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Query&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;SELECT id, (standard_amt_usd/total_amt_usd)*100 &lt;br&gt;
FROM orders&lt;br&gt;
LIMIT 10;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In the output, you will notice that it created a new column after multiplication and the name of column is unknown. This can be solved using derived column.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu1xrm1arsn901ewrfyss.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu1xrm1arsn901ewrfyss.png" alt=" " width="800" height="709"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Derived Column:&lt;/strong&gt;&lt;br&gt;
A derived column, also known as a calculated or computed column, is a new column created by combining existing columns in a table. This new column can be given a name, known as an alias, using the &lt;code&gt;AS&lt;/code&gt; keyword.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Query&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;SELECT id, (standard_amt_usd/total_amt_usd)*100 AS std_percent&lt;br&gt;
FROM orders&lt;br&gt;
LIMIT 10;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Here, we are dividing the dollar amount of standard paper by the total order amount to calculate the percentage of standard paper used in the order. We named this new column "std_percent" using the &lt;code&gt;AS&lt;/code&gt; keyword.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuwlvvyu775uutiys2dlb.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuwlvvyu775uutiys2dlb.png" alt=" " width="800" height="709"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Logical Operators
&lt;/h2&gt;

&lt;p&gt;In SQL, logical operators are used to combine multiple conditions in a query. Some of the commonly used logical operators are:&lt;/p&gt;

&lt;h3&gt;
  
  
  (i) Like
&lt;/h3&gt;

&lt;p&gt;The LIKE operator in SQL is used to match a specific pattern in a column, it allows you to perform operations similar to using WHERE and =, but when you don't know the exact value.&lt;/p&gt;

&lt;p&gt;It's particularly useful for working with text data. The LIKE operator is frequently used with &lt;code&gt;%&lt;/code&gt; which means search for the text that is in between &lt;code&gt;%&lt;/code&gt; no matter what comes on either side of the text.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;It's case-sensitive, so searching for 'T' is different from searching for 't'&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Query:&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;SELECT *&lt;br&gt;
FROM accounts&lt;br&gt;
WHERE website LIKE '%google%';&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This query will select row that contains the google in it, no matter what comes before or after the google.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F686hvsoua1wfunsuaaos.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F686hvsoua1wfunsuaaos.png" alt=" " width="800" height="712"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  (ii) IN
&lt;/h3&gt;

&lt;p&gt;The IN operator is useful for working with multiple values in both numeric and text columns, it allows you to check for one, two or many values within the same query. It's similar to using = but for multiple values of a particular column. It's a cleaner way of writing queries compared to using the OR operator which also allows you to perform similar tasks.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;SELECT *&lt;br&gt;
FROM orders&lt;br&gt;
WHERE account_id IN (1001,4251);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It will extract the row from 1001 to 4251.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkko19y6jcam4s0egfklk.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkko19y6jcam4s0egfklk.png" alt=" " width="800" height="711"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  (iii) NOT
&lt;/h3&gt;

&lt;p&gt;The NOT operator in SQL is used to negate a condition, it can be used in combination with other operators like IN and LIKE to retrieve rows that do not match specific criteria. &lt;/p&gt;

&lt;p&gt;For example, the NOT IN operator can be used to retrieve rows that do not have a specific value in a column and the NOT LIKE operator can be used to retrieve rows that do not match a specific pattern in a column. It's useful for filtering and retrieving data that does not meet specific conditions.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;SELECT *&lt;br&gt;
FROM orders&lt;br&gt;
WHERE account_id NOT IN (1001,4251);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In this query, all the row that not from 1001 and 4251 will be retrieved.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxq9btyiyl4b8q91eja5v.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxq9btyiyl4b8q91eja5v.png" alt=" " width="800" height="710"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  (iv) AND
&lt;/h3&gt;

&lt;p&gt;In SQL, the AND operator is used to combine multiple conditions in a query. The AND operator is used to match rows where all conditions are true.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Query:&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;SELECT *&lt;br&gt;
FROM orders&lt;br&gt;
WHERE account_id NOT IN (1001,4251) AND id IN(17,26);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In this query, two conditions will be checked if both of them are true then it will retrieve the information as shown in figure.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ttq0j086pfar4x294os.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ttq0j086pfar4x294os.png" alt=" " width="800" height="709"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  (iv) BETWEEN
&lt;/h3&gt;

&lt;p&gt;In SQL, the BETWEEN operator is used to match a range of values within a column. The BETWEEN operator is used to match rows where a column value is between two specified values, inclusive of the specified values. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Query:&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;SELECT *&lt;br&gt;
FROM orders&lt;br&gt;
WHERE account_id BETWEEN 1001 AND 4251&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In this query, all the row between 1001 and 4251 in account_id will be retrieved. &lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhmgaxlzifixb1c1kerz6.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhmgaxlzifixb1c1kerz6.png" alt=" " width="800" height="709"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  (v) OR
&lt;/h3&gt;

&lt;p&gt;The OR operator in SQL is used to combine multiple conditions in a query, it matches rows where at least one condition in query is true. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Query:&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;SELECT standard_qty, gloss_qty&lt;br&gt;
FROM orders&lt;br&gt;
WHERE (standard_qty = 0 OR gloss_qty = 0);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In this query, it will select all the rows where either gloss quantity is zero or standard quantity is zero.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fid31s65s7tjm4uly7p5x.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fid31s65s7tjm4uly7p5x.png" alt=" " width="800" height="709"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;These operator can be used in combination with other operators such as arithmetic operators (+, *, -, /)&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Best Practice For Formatting Query
&lt;/h2&gt;

&lt;p&gt;Following are the best practices that one should follow while writing the SQL queries:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1.&lt;/strong&gt; Capitalize SQL commands like SELECT and FROM, and keep everything else in lower case to make the query more readable.&lt;br&gt;
&lt;code&gt;SELECT account_id&lt;br&gt;
FROM orders;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.&lt;/strong&gt; Use underscores instead of spaces in column and table names.&lt;br&gt;
&lt;code&gt;SELECT account_id, standard_qty&lt;br&gt;
FROM orders;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3.&lt;/strong&gt; Always include a semicolon at the end of each statement, as it may be required in some SQL environments.&lt;br&gt;
&lt;code&gt;SELECT account_id&lt;br&gt;
FROM orders;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4.&lt;/strong&gt; Use double quotes or square brackets to reference tables and columns that have spaces in their names.&lt;br&gt;
&lt;code&gt;SELECT "full name", "age" &lt;br&gt;
FROM "employee information";&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5.&lt;/strong&gt; Use comments in your query for better understanding of your code.&lt;br&gt;
&lt;code&gt;-- This query selects all information from 'customers' table&lt;br&gt;
SELECT * FROM customers;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6.&lt;/strong&gt; Be consistent in formatting throughout your queries and scripts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7.&lt;/strong&gt; Use white space in queries to make them more readable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;8.&lt;/strong&gt; Use indentation to make the query structure more clear.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;9.&lt;/strong&gt; Use meaningful name for columns, tables and variables in order to make it more understandable and readable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;10.&lt;/strong&gt; Avoid using too many subqueries and joins, use them only when it's necessary.&lt;/p&gt;

</description>
      <category>sql</category>
      <category>database</category>
      <category>datascience</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>How To Configure PgAdmin To Run SQL Queries</title>
      <dc:creator>Abdul Raheem</dc:creator>
      <pubDate>Mon, 23 Jan 2023 07:02:53 +0000</pubDate>
      <link>https://dev.to/xfarooqi/how-to-configure-pgadmin-to-run-sql-queries-1k24</link>
      <guid>https://dev.to/xfarooqi/how-to-configure-pgadmin-to-run-sql-queries-1k24</guid>
      <description>&lt;p&gt;Here we will be using &lt;strong&gt;Parch And Posey Database&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Download and install pgAdmin on your computer.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open pgAdmin and connect to your PostgreSQL server by providing the necessary credentials (e.g. host, port, username, and password).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once connected, you should see the server listed under the "Servers" tree in the sidebar.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a new database in pgAdmin by right-clicking on the server, selecting "New" and then "Database".&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open the pgAdmin Query Tool by right-clicking on the server and selecting "Query Tool".&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Copy and paste the SQL queries for creating the "Porch" and "Post" tables into the editor&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After the database is created, you can expand it and see the tables, views, and other objects within it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To run an SQL query, right-click on the database and select "Query Tool".&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Type your query in the editor and press the execute button or use the shortcut key (F5) to run the query.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The results of the query will be displayed in the tab below the editor.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>api</category>
      <category>coding</category>
      <category>developer</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>Generative AI: Shaping the Future of Music Industry using AWS DeepComposer</title>
      <dc:creator>Abdul Raheem</dc:creator>
      <pubDate>Sun, 22 Jan 2023 19:17:17 +0000</pubDate>
      <link>https://dev.to/xfarooqi/generative-ai-shaping-the-future-of-music-industry-using-aws-deepcomposer-4noi</link>
      <guid>https://dev.to/xfarooqi/generative-ai-shaping-the-future-of-music-industry-using-aws-deepcomposer-4noi</guid>
      <description>&lt;h2&gt;
  
  
  What is Generative AI
&lt;/h2&gt;

&lt;p&gt;Generative AI, also known as generative models, is a subfield of artificial intelligence that focuses on creating new and unique outputs, such as text, images, and music, based on a set of inputs or training data. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
We have trained our model with data from a cat and then Generative AI will use that data to create an artificial cat by following the pattern of previous cat data. It is usually an unsupervised machine-learning model where it uses the generative technique that is creating new data by using the pattern learned during the training. This is in contrast to discriminative models, which focus on classifying or identifying inputs based on previously learned information.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Famous Platform that used Generative AI:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Chat GPT&lt;/li&gt;
&lt;li&gt;DALL·E 2&lt;/li&gt;
&lt;li&gt;Amper Music&lt;/li&gt;
&lt;li&gt;AIVA&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Types of Generative AI
&lt;/h2&gt;

&lt;p&gt;There are several types of generative AI:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Generative Adversarial Networks (GANs)-&lt;/strong&gt; These consist of two neural networks, a generator and a discriminator, that work together to generate new data that is similar to a given dataset.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Variational Autoencoders (VAEs)-&lt;/strong&gt; These consist of an encoder network that maps input data to a latent space, and a decoder network that maps the latent space back to the original data space. They are used to generate new data by sampling from the latent space.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Autoregressive Models -&lt;/strong&gt; These models predict the next value in a sequence based on the previous values. Examples include Autoregressive Integrated Moving Average (ARIMA) and Recurrent Neural Networks (RNNs).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Transformer-based Models -&lt;/strong&gt; These models are commonly used for natural language processing tasks and are known for their ability to handle sequential data with long-term dependencies. Examples include BERT and GPT-2&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Deep Convolutional Generative Adversarial Networks (DCGANs) -&lt;/strong&gt; These models use convolutional layers in both generator and discriminator networks, and are used for generating images.&lt;/p&gt;




&lt;h1&gt;
  
  
  Generative AI with AWS DeepComposer
&lt;/h1&gt;

&lt;p&gt;AWS DeepComposer is an Amazon Web Services (AWS) tool that allows users to generate and compose music using generative artificial intelligence (AI) models. &lt;/p&gt;

&lt;p&gt;It consists of the following parts:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. USB Keyboard -&lt;/strong&gt; Connects to your computer to input the melody.&lt;br&gt;
&lt;strong&gt;2. Accompanying Console -&lt;/strong&gt; Includes AWS DeepComposer Music studio to generate music.&lt;br&gt;
&lt;strong&gt;3. Chartbusters -&lt;/strong&gt; To represent your machine-learning skills.&lt;/p&gt;

&lt;p&gt;But is not necessary to have the keyboard all the time, we can import your own MIDI file, use one of the provided sample melodies, or use the virtual keyboard in the AWS DeepComposer Music studio.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Working&lt;/strong&gt;&lt;br&gt;
The AWS DeepComposer Music Studio offers the ability to generate music using three different generative AI techniques: GANs, AR-CNNs, and transformers. The GAN technique can be used to generate accompaniment tracks, the AR-CNN technique can be used to make changes to notes in an input track, and the transformer technique can be used to extend an input track by up to 30 seconds.&lt;/p&gt;

&lt;h2&gt;
  
  
  GANs on AWS DeepComposer
&lt;/h2&gt;

&lt;p&gt;Generative Adversarial Networks (GANs) are a unique type of machine learning model that utilizes two neural networks to generate new content. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1.&lt;/strong&gt;  A generator is the first neural network that learns to create new data resembling the source data on which it was trained.&lt;br&gt;
&lt;strong&gt;2.&lt;/strong&gt; A discriminator is a second neural network trained to assess how closely the generator's data resembles the training data set.&lt;/p&gt;

&lt;p&gt;The generator and discriminator work in a back-and-forth process where the generator improves in creating realistic data and the discriminator becomes more adept at distinguishing between real and generated data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example To Understand:&lt;/strong&gt;&lt;br&gt;
Think of an example where A GAN can be compared to a cooking competition. There is a chef who creates new recipes and a judge who evaluates the quality of the dishes. The chef, like the generator network in a GAN, generates new dishes, and the judge, like the discriminator network, evaluates the dishes and provides feedback on how to improve them. As the chef receives feedback and improves, the dishes become more and more refined, similar to how the generator network in a GAN improves over time. AWS DeepComposer uses GANs in a similar way to create unique and distinctive music compositions.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fljxb6a60bfid9nsb54lw.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fljxb6a60bfid9nsb54lw.png" alt=" " width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Let's Generate a New Melody
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt;&lt;br&gt;
Create an account on AWS &lt;a href="https://aws.amazon.com/deepcomposer/" rel="noopener noreferrer"&gt;DeepComposer&lt;/a&gt; website.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt;&lt;br&gt;
Click on AWS DeepComposer Music Studio or find AWS DeepComposer on the search option.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsk0j6az3yhya45nxkuj1.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsk0j6az3yhya45nxkuj1.png" alt=" " width="800" height="423"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt;&lt;br&gt;
Click on the start composition.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd6p3eo06q14o0l43vngy.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd6p3eo06q14o0l43vngy.png" alt=" " width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4:&lt;/strong&gt;&lt;br&gt;
You will move toward this page where you will have multiple options.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Update the Name of Your Music File&lt;/li&gt;
&lt;li&gt;Import Music or Select Music&lt;/li&gt;
&lt;li&gt;Play Or Stop Music&lt;/li&gt;
&lt;li&gt;Create your own melody&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After selecting a music track, you will hit continue.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhaa20u33wa10b1j37xy4.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhaa20u33wa10b1j37xy4.png" alt=" " width="800" height="422"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is the Machine learning phase where you have to select a model according to your requirements. For example, you can choose any of the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;ARR-CNN can make your music sound more like Bach music by analyzing the patterns and characteristics of the training data, such as harmony, melody, rhythm, and structure, and using this knowledge, it will generate new music that will be similar to the original one. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;GANs can be used to enhance music tracks by working in a collaborative cycle between the generator and discriminator. The generator will take in a single-track piano roll as input and output a multi-track piano roll with added accompaniments. The discriminator will then evaluate the output and provide feedback to the generator to improve the realism of the music generated. This process will continue to iterate until it creates more realistic and enjoyable music.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Transformers can make your music longer by adding 20 seconds. They are like computer programs that can make new music that sounds good. They do this using an autoregressive architecture  where it tries to figure out what the next note, rhythm, or chord should be based on the pattern of the music that has already been played.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgb43ndhphfbrmnskyw83.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgb43ndhphfbrmnskyw83.png" alt=" " width="800" height="391"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6&lt;/strong&gt;&lt;br&gt;
After updating ARR-CNN parameters click continue. You can understand these parameters as:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Maximum Input Notes To Remove:&lt;/strong&gt; Controls the percentage of input melody to be removed during effect. Increasing its value will allow the model to use less of input melody as reference during inference. You can set it to 60(optimal) or other value.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Maximum Notes to Add:&lt;/strong&gt; Controls the number of node that can be added to input melody. Increasing the value might introduce some notes out of place. I will set it to 80.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sampling Iteration:&lt;/strong&gt; Controls the number of time input melody is passed through the model. I will set it to 90.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creative Risk:&lt;/strong&gt; Controls how much the model can deviate from the music that it was trained on. If you set the value too low, model will choose high probability notes and vice versa. I will set its value to 0.8&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgydue044a3by6twpkyrh.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgydue044a3by6twpkyrh.png" alt=" " width="800" height="305"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 7&lt;/strong&gt;&lt;br&gt;
You will get the output melody in this step that is been trained using the Generative AI in AWS DeepComposer.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyrjzt3468scgav9hhn6w.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyrjzt3468scgav9hhn6w.png" alt=" " width="800" height="421"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 8&lt;/strong&gt;&lt;br&gt;
You can edit these melody if you want to by removing some of the nodes by clicking on Edit Melody.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc2jx86sfsfxedgi6okmu.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc2jx86sfsfxedgi6okmu.png" alt=" " width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 9&lt;/strong&gt;&lt;br&gt;
Once you are satisfied with the new melody, click on the continue button. You will be directed toward the Share Composition Page.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhzbv3sir5ecc7tkqow6s.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhzbv3sir5ecc7tkqow6s.png" alt=" " width="800" height="401"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 10&lt;/strong&gt;&lt;br&gt;
This is it, Your Generative AI melody is ready, if you want to do additional changes to it you can do that. Some of the options in AWS DeepComposer are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Generate accompaniment track using GANs&lt;/li&gt;
&lt;li&gt;Extend input track with Transformers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Afterward, you can participate in the AWS DeepComposer Chartbuster challenge as well with your melody.&lt;/p&gt;




</description>
      <category>aws</category>
      <category>ai</category>
      <category>generativeai</category>
      <category>chatgpt</category>
    </item>
    <item>
      <title>All About AWS AI &amp; ML Scholarship Program</title>
      <dc:creator>Abdul Raheem</dc:creator>
      <pubDate>Sun, 22 Jan 2023 10:21:01 +0000</pubDate>
      <link>https://dev.to/xfarooqi/all-about-aws-ai-ml-scholarship-program-o5h</link>
      <guid>https://dev.to/xfarooqi/all-about-aws-ai-ml-scholarship-program-o5h</guid>
      <description>&lt;p&gt;Ever wanted a well-structured course where you can learn about Machine Learning and Artificial Intelligence from scratch to an advance level?&lt;/p&gt;

&lt;p&gt;Your search is over because AWS is providing such an opportunity for students where they can learn about machine learning foundations. After successfully completing the foundation course on the AWS DeepRacer website you can have access to the Udacity Nanodegree "AI Programming with Python" where you can learn the following concepts in detail:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Python &lt;/li&gt;
&lt;li&gt;NumPy&lt;/li&gt;
&lt;li&gt;Pandas&lt;/li&gt;
&lt;li&gt;Matplotlib&lt;/li&gt;
&lt;li&gt;PyTorch&lt;/li&gt;
&lt;li&gt;Linear Algebra&lt;/li&gt;
&lt;li&gt;Calculus Essentials &lt;/li&gt;
&lt;li&gt;Foundations for building your own neural network&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  How To Avail This Opportunity?
&lt;/h2&gt;

&lt;p&gt;It consists of following steps:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; &lt;br&gt;
Sign up for &lt;a href="https://aws.amazon.com/deepracer/student/" rel="noopener noreferrer"&gt;AWS DeepRacer Student&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; &lt;br&gt;
Opt into the AWS AI &amp;amp; ML Scholarship program by starting learning. You will find two learning resources on Introduction to Machine Learning and Reinforcement Learning. You have to complete both.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff9ju8qupz0q81b9aysn4.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff9ju8qupz0q81b9aysn4.png" alt=" " width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt; &lt;br&gt;
After completing the 20 hours of free learning take the quiz. You need to Obtain a score of 80% or higher on all quizzes related to AWS DeepRacer Student while gaining knowledge of the basic concepts of machine learning.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo6ao36mipfhtoje6b6qc.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo6ao36mipfhtoje6b6qc.png" alt=" " width="800" height="438"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4:&lt;/strong&gt; &lt;br&gt;
Once you passed the quiz, you will get a one-time code to apply for &lt;strong&gt;&lt;a href="https://www.udacity.com/course/ai-programming-python-nanodegree--nd089" rel="noopener noreferrer"&gt;AI programming With Python&lt;/a&gt;&lt;/strong&gt; Nanodegree&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8xl1ddix1qrvib79focb.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8xl1ddix1qrvib79focb.png" alt=" " width="800" height="327"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5:&lt;/strong&gt; &lt;br&gt;
Submit your application which is starting from February 1, 2023 on Udacity using a unique code you’ll get once you complete the prerequisites.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's Next?
&lt;/h2&gt;

&lt;p&gt;Once you completed all the steps, you will receive a notification of the selection decision via email on June 12, 2023. Scholarship recipients will have full access to the entirety of their Nanodegree content on June 14, 2023.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What If Get a Scholarship?&lt;/strong&gt;&lt;br&gt;
If you are one of the lucky folks who will get the scholarship, it is time to get prepare for the onboarding. In the email, all the necessary information will be shared with you.&lt;/p&gt;

&lt;p&gt;You will have access to a dedicated Slack Channel where you will find yourself among mentors and like-minded students who are always there to help and support you. There will be a connected session every week where the instructor will teach all the concepts in the nanodegree live. So that if you have any confusion about the content or topic of Nanodegree you can ask it from your instructor in the virtual connect session.&lt;/p&gt;




</description>
      <category>aws</category>
      <category>ai</category>
      <category>datascience</category>
    </item>
  </channel>
</rss>
