<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Esraa Ahmed on Medium]]></title>
        <description><![CDATA[Stories by Esraa Ahmed on Medium]]></description>
        <link>https://medium.com/@essraaahmed?source=rss-8e9f0b92b993------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*thEz7vYLj0oaf4-loS-lUw.png</url>
            <title>Stories by Esraa Ahmed on Medium</title>
            <link>https://medium.com/@essraaahmed?source=rss-8e9f0b92b993------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 13:37:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@essraaahmed/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Imbalanced Data Techniques Pros and Cons]]></title>
            <link>https://medium.com/@essraaahmed/imbalanced-data-techniques-pros-and-cons-8fa3782a49af?source=rss-8e9f0b92b993------2</link>
            <guid isPermaLink="false">https://medium.com/p/8fa3782a49af</guid>
            <category><![CDATA[imbalanced-data]]></category>
            <category><![CDATA[data-cleaning]]></category>
            <category><![CDATA[smote]]></category>
            <category><![CDATA[data-preprocessing]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Esraa Ahmed]]></dc:creator>
            <pubDate>Thu, 21 Nov 2024 00:02:00 GMT</pubDate>
            <atom:updated>2024-11-23T02:07:44.219Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Generated by DALL.E" src="https://cdn-images-1.medium.com/max/1024/1*QsOV_0FLt7iuqhKsIFw8IQ.png" /><figcaption>Generated by Chatgpt</figcaption></figure><p>Imbalanced data is a common challenge when dealing with real-world data. <br>If you are working on a classification task, for example: you will notice that class 0 and class 1 are not equal. So, this can lead to Bias or Skewness.<br>In this case, the Accuracy metric will be misleading, so it’s better to focus on other metrics like: Precision, recall, and F1 score.</p><p>In this article, we will explore the Pros and Cons of some imbalanced techniques.</p><ol><li><em>Random UnderSampling</em></li><li><em>Random OverSampling</em></li><li><em>SMOTE</em></li><li><em>SMOTE + ENN</em></li><li><em>Borderline SMOTE</em></li><li><em>Safe-level SMOTE</em></li><li><em>ADASYN</em></li></ol><h4><strong>1. Random Undersampling</strong></h4><p>Choosing Random Undersampling based on data size, if working on very large data. This technique randomly picks data points from the majority class and removes them.</p><p><strong><em>Pros</em></strong></p><ul><li>Improve runtime due to a small dataset, and reduce the data size.</li></ul><p><strong><em>Cons</em></strong></p><ul><li>Removing samples could cause bias.</li><li>It could remove information from our data, and poor performance.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6574fe0fb6e3c9d106190bacf66a334f/href">https://medium.com/media/6574fe0fb6e3c9d106190bacf66a334f/href</a></iframe><h4>2. Random OverSampling</h4><p>Picks data points from the minority class randomly and duplicates them.</p><p><strong><em>Pros</em></strong><br>- No loss of Data, and Balancing the data.</p><p><strong><em>Cons<br></em></strong>- May lead to overfitting.<br>- If the data is large, the training time will increase.</p><h4>3. SMOTE (Synthetic Minority Oversampling Technique)</h4><p>SMOTE picks a point in the minority class and identifies its <em>k</em> nearest neighbor point, then randomly places a point along vectors between neighbors and the minority point, and repeats.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*yzVMr0Jma3Hald4LNyhd0A.png" /><figcaption>SMOTE</figcaption></figure><p><strong><em>Pros</em></strong></p><ul><li>No loss of information, and reduce the overfitting.</li></ul><p><strong><em>Cons</em></strong></p><ul><li>Poor performance with high dimensionality data.</li><li>Not suitable with categorical data, it will require preprocessing.</li><li>SMOTE does not account for noisy data, and synthetic samples may amplify noise.</li><li>Requires some Preprocessing or Standardization.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f2854b263ce47a2e8f738a0600066689/href">https://medium.com/media/f2854b263ce47a2e8f738a0600066689/href</a></iframe><h4>4. SMOTE + ENN</h4><p>A combination of SMOTE and ENN (Edited Nearest Neighbors), removes samples that differ from a majority of its neighbors based on k-nearest neighbor.<br>Apply SMOTE first, then ENN to remove any noisy data.<br>Recommended when data is noisy or has outliers.</p><p><strong><em>Pros</em></strong></p><ul><li>Remove noisy data and misclassified points.</li><li>Enhance Model Performance.</li><li>Better balance the data.</li></ul><p><strong><em>Cons</em></strong></p><ul><li>Risk of losing data.</li><li>Increase computational costs, especially with large data.</li></ul><pre>import sklearn<br>from sklearn.model_selection import train_test_split<br>from imblearn.combine import SMOTEENN<br><br>#split the dataset into train and test<br>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42, stratify=y)<br><br>#apply SMOTEENN for imbalancing data<br>smote_enn = SMOTEENN(random_state=42)<br>X_train_res, y_train_res = smote_enn.fit_resample(X_train, y_train)</pre><h4>5. BorderLine SMOTE</h4><p>Generates synthetic points from the minority class that are closer to the boundary decision. These points are misclassified (Hard to Classify Points). One of the algorithms that can be used for classification is KNN.</p><p>How it works:</p><ul><li>KNN fits the data, identifies the points that lie close to the Majority Class (near to decision boundary).</li><li><strong>Noisy Point</strong>: If the points from the minority class and its neighbors are from the majority points, these points will be ignored.</li><li><strong>Safe Points:</strong> If the points from the minority class and its neighbors are the other minority points, these points will be ignored because they are easy to classify.</li><li><strong>Border/Dangerous Points (Danger Group):</strong> If the minority points are surrounded by a mix of majority and minority points, then those are the points we want to focus on for classification.</li><li>Generates new points only for the danger group.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b7qCkcccRmaKy2GmQqcXwg.png" /><figcaption>Borderline SMOTE</figcaption></figure><p>Recommended if there is a misclassification in the minority class.</p><p><strong><em>Pros</em></strong></p><ul><li>Avoid problems of SMOTE, it oversamples the points that are difficult to classify.</li><li>Improve the performance of the model by correctly classifying the points of the minority class.</li></ul><p><strong><em>Cons</em></strong></p><ul><li>Some points that are hard to classify could be noise.</li><li>Computational costs.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c75d37466096c62659a6dd868ce488b7/href">https://medium.com/media/c75d37466096c62659a6dd868ce488b7/href</a></iframe><h4>6. Safe-Level-SMOTE</h4><p>Oversampling the minority class points, by assigning a <em>safe level </em>to each point<em> </em>to avoid oversampling noisy points.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/336/1*BMiIK7j1Wn7-_-Y5lPXJYg.png" /><figcaption>Self-Level-SMOTE</figcaption></figure><blockquote>How to determine Safe Level:<br>By the nearest neighbor points, Safe Level = Number of Minority Neighbors / Number of Majority Neighbors + Number of Minority Neighbors. <br>= 4/2+4 = 0.6, it’s a Safe point.</blockquote><blockquote>If the safe level of a point is closer or equal to 1, then it’s Safe. <br>If the safe level of a point is 0, then it’s Noisy.</blockquote><p><strong><em>Pros</em></strong></p><ul><li>Avoid Noisy data.</li><li>Reduce Overfitting.</li></ul><p><strong><em>Cons</em></strong></p><ul><li>High Computational Costs, especially with large data.</li></ul><h4>7. ADASYN <strong>(Adaptive Synthetic Sampling)</strong></h4><p>Instead of Randomly generating minor points, it assigns weights to the minority class. It gives high weights to the samples more difficult to learn, and low weights to the ones that are easy to learn.</p><p>How to assign wights</p><ul><li>Calculate the ratio <em>d = Ms/Ml, </em>Minority, and Majority.</li><li>Calculate G, the generated synthetic minority samples<br>G = (Ml-Ms)β<br>β = 1 means fully balanced data, β &lt; 1 means minority samples are less than majority samples, and if β &gt; 1 means minority samples are more than majority samples.</li><li>Calculate k-nearest neighbors.<br>Ni: number of nearest neighbors that belong to the majority class.<br>Ex: Majority points: 3, k: 7, <em>Ri</em> = 3/7 = 0.4</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/354/1*KqWKZdetiFLrAPwlry1OCQ.png" /></figure><ul><li>Normalize <em>Ri </em>across all values, the sum of all Ri is 1 to give us the weights.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/266/1*2ENDxu6K8jj_C47pxiMb7g.png" /></figure><ul><li>Calculate the number of samples we need to generate for the minority class.<br>Ex: Ri = 0.4 and ∑Ri = 20, so ^Ri = 0.4/20 = 0.02<br>G = 500(majority) — 200 (minortiy)= 300<br>gi: number of synthetic samples, gi = 0.02 * 300 = 6<br>so we need to generate 6 samples for the selected minority class.</li><li>Generate new samples for each neighborhood</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/1*a9__xhQXgCJ0jlc83KHYvQ.png" /></figure><p>Xi: For each minority class sample, generate Gi, Xzi: randomly select a different minority example from the k-nearest neighbors.<br>λ: random number between 0 and 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*dT1CxXRObhIVvunIqLBJlg.png" /></figure><p><strong><em>Pros</em></strong></p><ul><li>Creates Hard-to-learn data.</li><li>Better Decision Boundary.</li></ul><p><strong><em>Cons</em></strong></p><ul><li>Minority samples may not generate much data.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ebbcfba18e01657b56fcef10a4bdcbc6/href">https://medium.com/media/ebbcfba18e01657b56fcef10a4bdcbc6/href</a></iframe><p>Handling Imbalanced data improves the model’s performance, and it’s important to choose the most suitable technique for your case to avoid imbalance or bias.<br>I hope you gain information from this article and know the pros and cons of each technique.</p><p>Read More about <a href="https://medium.com/@essraaahmed/ways-to-detect-and-handle-outliers-696f5fcf0f29">Ways to Detect and Handle Outliers</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8fa3782a49af" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ways to Detect and Handle Outliers]]></title>
            <link>https://medium.com/@essraaahmed/ways-to-detect-and-handle-outliers-696f5fcf0f29?source=rss-8e9f0b92b993------2</link>
            <guid isPermaLink="false">https://medium.com/p/696f5fcf0f29</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[isolation-forests]]></category>
            <category><![CDATA[anomaly-detection]]></category>
            <category><![CDATA[dbscan]]></category>
            <category><![CDATA[outliers]]></category>
            <dc:creator><![CDATA[Esraa Ahmed]]></dc:creator>
            <pubDate>Tue, 05 Nov 2024 00:35:13 GMT</pubDate>
            <atom:updated>2024-11-05T00:35:13.652Z</atom:updated>
            <content:encoded><![CDATA[<p>Detecting outliers and how to handle them is a very important step in data preprocessing, to enhance data quality and improve the machine-learning model.</p><p>An Outlier is a data point that differs from other observations in the dataset. It arises because of errors in data collection, unexpected events, skewness in the data, etc.</p><p>In this article, I will introduce ways to detect outliers and how to handle them.</p><h3><strong>Detecting Outliers</strong></h3><ol><li><strong>Box Plot</strong></li></ol><p>Box Plot detects the outliers if they are greater than or lower than 1.5 times the IQR.</p><p>Interquartile (IQR): The difference between Q3 and Q1</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GVe5yXP6810-B1EzbYrtHQ.png" /></figure><p>Steps</p><ul><li>Calculate Q1 (1st quantile) and Q3 (3rd quantile).</li><li>Get the IQR = Q3 — Q1.</li><li>Get the upper bound and lower bound.</li><li>The data points outside the bounds will be identified as outliers.</li></ul><pre>q1 = np.quantile(arr, 0.25)<br>q3 = np.quantile(arr, 0.95)<br>med = np.median(arr)<br><br>#get IQR<br>iqr = q3 - q1<br><br>#get the upper and lower bounds<br>up_bound = q3+(1.5*iqr)<br>low_bound = q1-(1.5*iqr)<br><br>outliers = arr[(arr &lt;= low_bound) | (arr &gt;= up_bound)]<br>print(&quot;Outliers are {}&quot;.format(outliers))</pre><p><strong>2. Z-Score</strong></p><p>It helps to measure how far data points are from the mean. We can also choose the percentile to use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*QzPMrN5fcAuVWJDacnMKZQ.png" /></figure><pre>outliers(df[&#39;col1&#39;], lower_bound = -1.95, upper_bound = 1.95)</pre><p><strong>3. Isolation Forest</strong></p><p>Isolation Forest is an Unsupervised Anomaly Detection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/336/1*O3Forg2aIqe4gI3wS1hyZQ.png" /></figure><p><strong><em>How it works</em></strong></p><p>It creates multiple trees by recursively splitting the dataset if there are unusual data points the algorithm isolates the outliers/anomalies in fewer splits. Outliers would be easy to detect without going too into the depth of a tree.</p><ul><li>Compute the Anomaly score for each data point.</li><li>If the score crosses a specific threshold then it will be an outlier.</li></ul><p>Unlike the Decision Tree uses <strong><em>Entropy</em></strong> or <strong><em>Gini impurity</em></strong> to determine split points, the Isolation Forest uses an approach<strong><em> </em></strong>like the<strong><em> Extra(Extremely Randomized) Tree Regressor </em></strong>and chooses splits randomly.</p><p><strong>Anomaly Score Formula</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*uhAF5-B49pm9wF9TerrkDQ.png" /></figure><p><strong><em>E(h(x))</em></strong>: Represents the average path length for isolation data point x in a tree.<br><strong><em>n</em></strong>: Number of points.<br><strong><em>x</em></strong>: Data point.<br><strong><em>c(n)</em></strong>: Represents the average depth of data points in the tree.</p><p>So, if the score is greater than 0.5 or closer to 1, it’s <strong>Anomaly.</strong><br>If the score is 0 or less than 0.5, it’s <strong>Normal</strong>.</p><h3>Handling Outliers</h3><p>There are many ways to treat outliers, but first, we need to understand the nature of outliers to decide what approach will be more suitable to our case. I will discuss some of them:</p><ol><li><strong>Remove Outliers</strong></li></ol><p>If the number of data points is small or not valuable, we can use Z-score or percentile removal, to remove outliers, above or lower the specific threshold.</p><p><strong>2. Winsorizing</strong></p><p>Instead of removing outliers, we will replace outliers with the nearest value. So, any value above a specific threshold (Ex: 0.96) is replaced with that threshold value, if the value falls below the lower threshold, we will replace it with that threshold value.</p><p>This method will not eliminate any data points.</p><p><strong>3. Tree-Based Models</strong></p><p>Tree-based models like Random Forest and Gradient Boosting are more robust to outliers than the Decision Tree model.<br>Gradient Boosting Trees are dependent trees, each tree minimizes the previous tree’s error.</p><p><strong>4. Loss Function</strong></p><p>The loss function is to measure the error between the predicted values and the actual values, by minimizing this error.</p><p>Some types of Loss Function</p><ul><li><strong><em>MSE</em></strong>: calculates the average of squared difference between predicted and actual values, it’s more sensitive to outliers. Also, MSE is useful when we want to avoid large errors in the model. MSE is commonly used in regression tasks.</li><li><strong><em>MAE</em></strong>: More robust to outliers and noise. MAE is commonly used with skewed data.</li></ul><p><strong>5. DBSCAN Cluster</strong></p><p>DBSCAN (Density-Based Spatial Clustering of Applications with Noise), groups the data based on density, adds the data points to the cluster iteratively based on proximity, and data points that are not in the cluster will be identified as outliers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*Tl0YcozAW2prEP4DaYUqSw.jpeg" /></figure><p><strong><em>How DBSCAN works</em></strong></p><p><strong>First</strong>, Identify core points.<br><strong>Second</strong>, Add all neighbor points to the same cluster.<br><strong>Third</strong>, Identify the outliers.<br>- <strong><em>Core point</em></strong>: data point within a specified neighborhood of a minimum number of other data point.<br>- <strong><em>Border points</em></strong>: Neighbor of core point.<br>- <strong><em>Outlier</em></strong>: Neither a core point nor a border point.</p><p><strong>Epsilon</strong>: Radius of the cluster.<br><strong>Minimum points</strong>: Minimum number of points in the cluster.</p><h3>Conclusion</h3><p>Detecting and Handling Outliers is essential for getting meaningful data, and improving the performance of the model. I have explored with you some ways how to detect and handle outliers. I hope you find this article useful and take advantage of it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=696f5fcf0f29" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Warehouse With Amazon Redshift and Visualizing Redshift data using Power BI]]></title>
            <link>https://medium.com/@essraaahmed/data-warehouse-with-amazon-redshift-and-visualizing-redshift-data-using-power-bi-9c0cf23060a3?source=rss-8e9f0b92b993------2</link>
            <guid isPermaLink="false">https://medium.com/p/9c0cf23060a3</guid>
            <category><![CDATA[data-warehouse]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[etl]]></category>
            <dc:creator><![CDATA[Esraa Ahmed]]></dc:creator>
            <pubDate>Sat, 21 Jan 2023 14:01:34 GMT</pubDate>
            <atom:updated>2023-01-21T14:01:34.863Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*6FvY1AdhkvOm41iBFKML_w.png" /></figure><p>Building ETL Pipeline that extracts the data from S3 stages them in Redshift, and transforms data into a set of dimensional tables.</p><h3>Overview</h3><p>A music streaming startup Sparkify has grown its user base and song database and wants to move its processes and data onto the cloud. Their data resides in the AWS S3, in a directory of JSON logs on user activity on the app, as well as a directory with JSON metadata on the songs in their app.</p><p>So as a data engineer, I will build an ETL pipeline that extracts the data from S3, stages them in <a href="https://medium.com/u/f9cda0c7024f">Amazon Web Services AWS</a> Redshift, and transforms data into a set of dimensional tables for their analytics team to continue finding insights into what songs their users are listening to.</p><h4>Data Source</h4><p>There are two datasets that reside in S3</p><ul><li>Song data: s3://udacity-dend/song_data</li><li>Log data: s3://udacity-dend/log_data</li></ul><p>Log data JSON path: s3://udacity-dend/log_json_path.json</p><p><strong><em>Song Dataset</em></strong></p><p>The first dataset is a subset of real data from the Million Song Dataset. Each file is in JSON format and contains metadata about a song and the artist of that song. The files are partitioned by the first three letters of each song’s track ID. An example of what a single song file, looks like:</p><p>{“num_songs”: 1, “artist_id”: “ARJIE2Y1187B994AB7”, “artist_latitude”: null, “artist_longitude”: null, “artist_location”: “”, “artist_name”: “Line Renaud”, “song_id”: “SOUPIRU12A6D4FA1E1”, “title”: “Der Kleine Dompfaff”, “duration”: 152.92036, “year”: 0}</p><p><strong><em>Log Dataset</em></strong></p><p>The second dataset consists of log files in JSON format generated by this event simulator based on the songs in the dataset above. These simulate activity logs from a music streaming app based on specified configurations.</p><p>The log files in the dataset you’ll be working with are partitioned by year and month.</p><figure><img alt="An example of what the data in a log file, 2018–11–12-events.json, looks like." src="https://cdn-images-1.medium.com/max/1024/1*oRpxn6fvZ3QKoHpp2ne5jg.png" /><figcaption>An example of what the data in a log file, 2018–11–12-events.json, looks like.</figcaption></figure><h3>Redshift Cluster</h3><ol><li>Create Redshift IAM Role and On the <strong>Attach permissions policies</strong> page, search for and select the <strong>AmazonS3ReadOnlyAccess</strong>.</li><li>Create a Security Group (through the EC2 security group) to authorize access to the Redshift cluster.</li><li>Create a Redshift cluster, then put the database info.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*EtYxeDqilpf2I6U1wOdQZg.png" /></figure><p>4. Delete the Redshift cluster when finished.</p><h3>Database Schema Design</h3><p>Here are the staging tables for events &amp; songs, will create from them dimension tables and fact table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fgMfdscphuDv7RDw0SJSXg.png" /></figure><p>Staging Tables:</p><p>staging_event: for log data.<br>staging_song: for song data.</p><p>Fact Table:</p><p>songplays: records in log data associated with song plays i.e. records with page NextSong -songplay_id, start_time, user_id, level, song_id, artist_id, session_id, location, user_agent</p><p>Dimension Tables</p><p>users — users in the app -user_id, first_name, last_name, gender, level<br> songs — songs in music database -song_id, title, artist_id, year, duration<br> artists — artists in music database -artist_id, name, location, latitude, longitude<br> time — timestamps of records in songplays broken down into specific units start_time, hour, day, week, month, year, weekday</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c11135562082e23aab79ba720ff29dfd/href">https://medium.com/media/c11135562082e23aab79ba720ff29dfd/href</a></iframe><h3>ETL Pipeline</h3><p>The ETL Pipeline consists of 2 steps:</p><ol><li>Load data from S3 to staging tables on Redshift.</li><li>Execute SQL statements in sql_queries.py that create the analytics tables from these staging tables.</li></ol><p>First, I will extract data from S3 and staging them in Redshift using COPY Command.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/87db449d2cf06a420b2a4c8d58fde981/href">https://medium.com/media/87db449d2cf06a420b2a4c8d58fde981/href</a></iframe><p>The staging tables are: <em>staging_event</em> &amp; <em>staging_song</em>. Transform data into a set of dimensional tables and fact table with Star Schema. Then, load data from staging tables to analytics tables on Redshift with INSERT INTO statement. To avoid duplication data, use SELECT DISTINCT.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f0a4313b4a38f38a54f34e771a783f32/href">https://medium.com/media/f0a4313b4a38f38a54f34e771a783f32/href</a></iframe><p>Query in Redshift</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*mx3eBWxoGN8zWabOpyN9KQ.png" /></figure><h3>Analysis</h3><p>After loading data, I created some SQL queries and Visualization. Here’s an example of SQL queries:<br> df_song = pd.read_sql(“SELECT COUNT(*) FROM song;”, conn)<br> df_song<br> output &gt;&gt; 14896</p><h3>Visualizing Redshift data with Power BI</h3><p>Connect Power BI to Redshift to create a dashboard:<br>1. To connect to an Amazon Redshift database, select Get data &gt; Database &gt; Amazon Redshift.<br>2. In the Amazon Redshift window that appears, type your Amazon Redshift Server and Database.<br>3. Then put in your username and password.<br>4. Once you successfully connect, click load &gt; Import.<br>5. Build your Dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*1dtI8Lc1LRc5cXjiDf0xIg.png" /></figure><h4>Summary:</h4><p>The project is about building ETL Pipeline that extracts the data from S3 stages them in Redshift, and transforms data into a set of dimensional tables. After making the design schema We created a Redshift cluster and Security Group (through the EC2 security group) to authorize access to the Redshift cluster. Load data from S3 to staging tables on Redshift. Execute SQL statements that create the analytics tables from these staging tables. After loading the data Connect Power BI to Redshift to create a dashboard.</p><p><em>My GitHub </em><a href="https://github.com/essraahmed/Data-Warehouse-With-Redshift"><em>Repository </em></a><em>for the full project</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9c0cf23060a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>