<?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 Isfaque Ansari on Medium]]></title>
        <description><![CDATA[Stories by Isfaque Ansari on Medium]]></description>
        <link>https://medium.com/@isfaque45?source=rss-c7c851989e99------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*5Qj4sFTilzXS3w0j</url>
            <title>Stories by Isfaque Ansari on Medium</title>
            <link>https://medium.com/@isfaque45?source=rss-c7c851989e99------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 15:39:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@isfaque45/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[Project: Phyllotaxis: Draw Flowers Using Mathematics.]]></title>
            <link>https://isfaque45.medium.com/project-phyllotaxis-draw-flowers-using-mathematics-20352289c127?source=rss-c7c851989e99------2</link>
            <guid isPermaLink="false">https://medium.com/p/20352289c127</guid>
            <dc:creator><![CDATA[Isfaque Ansari]]></dc:creator>
            <pubDate>Fri, 01 Sep 2023 04:22:14 GMT</pubDate>
            <atom:updated>2023-09-01T04:22:14.910Z</atom:updated>
            <content:encoded><![CDATA[<p><em>The scientist does not study nature because it is useful; he studies it because he delights in it, and he delights in it because it is beautiful.” (Henri Poincaré)</em></p><p>There are many examples of <em>natural facts</em> that can be described in mathematical terms. Nice examples are the shape of snowflakes, the <em>fractal geometry</em> of romanesco broccoli or how self-similarity rules the growth of plants.</p><p>R is a tool for doing serious analysis, but not everything in life is serious. Life is also funny, and R can be used to have fun and to do beautiful things. Its graphical power can be used to produce artistic images like the one that illustrates this section, which is inspired by how plants arrange their leaves. This fact is called <em>phyllotaxis</em> and will serve as the basis of this project.</p><p>In this notebook, we are using the ggplot2 package. Apart from having fun, we will learn many important features of it that will be useful not only to do art but also to represent data in real-life problems. Let&#39;s start by loading the library.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/0*DNW3V2nfg3itJjAe.png" /></figure><p># Set plot images to a nice size<br>options(repr.plot.width = 4, repr.plot.height = 4)</p><p># Load the ggplot2 package<br> library(ggplot2)</p><h3>2. Warming up: drawing points on a circle</h3><p>There are many ways to represent data with ggplot2: from simple scatter plots to more complex violin plots. The functions that start with geom_ define the type of plot. In this notebook, we will only work with geom_point() which plots points in two dimensions. We&#39;ll need a dataset with two variables; let&#39;s call them x and y.</p><p>We’ll start by drawing 50 points on a circle of radius 1. As every (x, y) point should be in the unit circle, it follows that x² + y² = 1. We can get this using the <em>super famous</em> Pythagorean trigonometric identity which states that sin²(θ) + cos²(θ) = 1 for any real number θ.</p><p>t &lt;- seq(0, 2*pi, length.out = 50)<br>x &lt;- sin(t)<br>y &lt;- cos(t)<br>df &lt;- data.frame(t, x, y)</p><p># Make a scatter plot of points in a circle<br>p &lt;- ggplot(df, aes(x, y))<br>p + geom_point()</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*fgtmk_iu0Q02ptnFzaSEqA.png" /></figure><h3>3. Make it harmonious with the Golden Angle<a href="https://sessions.datacamp.com/proxy/absolute/7c0177d9-3d87-4984-903b-7e16c61744e4/notebooks/production/users/10929734/bo5uz39hdq/notebooks/notebook.ipynb#3.-Make-it-harmonious-with-the-Golden-Angle">¶</a></h3><p>Plants arrange their leaves in spirals. A spiral is a curve which starts from the origin and <em>moves away</em> from the origin as it revolves around it. In the plot above all our points are the same distance from the origin. A simple way to arrange them in a spiral is to multiply x and y by a factor which increases for each point. We <em>could</em> use t as that factor, as it meets these conditions, but we will do something more <em>harmonious</em>. We will use the <a href="https://en.wikipedia.org/wiki/Golden_angle">Golden Angle</a>:</p><p>Golden Angle = π(3 − √5)</p><p>This number is inspired by the Golden Ratio, one of the most famous numbers in the history of mathematics. Imagine that you have a circumference and you break up it into two arcs with lengths a and b, with a&gt;b (an arc is a portion of the circumference). The angle that <em>breaks</em> the circle so that a/b=(a+b)/a is called the Golden Angle. In other words: the Golden Angle <em>breaks up</em> a circle so that the ratio of the big arc to the little arc is the Golden Ratio. This image (from Wikipedia) illustrates the previous definition:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/357/0*jOPiQ0E7bH23Trw5.png" /></figure><p>The Golden Angle is the angle subtended by the smaller (red) arc. Both the Golden Ratio and the Golden Angle appear in unexpected places in nature. Apart of flower petals and plant leaves, you’ll find them in seed heads, pine cones, sunflower seeds, shells, spiral galaxies, hurricanes, etc.</p><p># Define the number of points<br>points &lt;- 500</p><p># Define the Golden Angle<br>angle &lt;- pi * (3 — sqrt(5))</p><p>t &lt;- (1:points) * angle<br>x &lt;- sin(t)<br>y &lt;-cos(t)<br>df &lt;- data.frame(t, x, y)</p><p># Make a scatter plot of points in a spiral<br>p &lt;- ggplot(df, aes(x*t, y*t))<br>p + geom_point()</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*gbVkMjbdTLutFPDC8uUcyw.png" /></figure><h3>4. Remove everything unnecessary<a href="https://sessions.datacamp.com/proxy/absolute/7c0177d9-3d87-4984-903b-7e16c61744e4/notebooks/production/users/10929734/bo5uz39hdq/notebooks/notebook.ipynb#4.-Remove-everything-unnecessary">¶</a></h3><p>Apart from data, a plot includes many other components that define its final appearance. Our previous plot contains:</p><ul><li>a <strong>background</strong> filled with grey color</li><li>a <strong>grid</strong> of horizontal and vertical white lines</li><li><strong>ticks</strong> along the axis</li><li>a <strong>title</strong> on each axis</li><li><strong>text</strong> along axes to label marks</li></ul><p>Art does not get along with most of these elements, so it’s time to move to action.</p><p>df &lt;- data.frame(t, x, y)</p><p># Make a scatter plot of points in a spiral and remove some plot components<br>p &lt;- ggplot(df, aes(x*t, y*t))<br>p + geom_point() +<br>theme(title = element_blank(),<br> text = element_blank(),<br> panel.grid = element_blank(),<br> panel.background = element_rect(fill = “white”))</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*oVXjyEHK98kXbyjV5tptyw.png" /></figure><h3>5. A bit of makeup: size, color and transparency<a href="https://sessions.datacamp.com/proxy/absolute/7c0177d9-3d87-4984-903b-7e16c61744e4/notebooks/production/users/10929734/bo5uz39hdq/notebooks/notebook.ipynb#5.-A-bit-of-makeup:-size,-color-and-transparency">¶</a></h3><p>Our drawing is starting to look like a plant, but we can better. By changing color, transparency (also called <em>alpha</em>), and size of the points, the image will become more appealing.</p><p># Change the code from Task 4 to modify the <br># size, transparency, and color of the points<br>p &lt;- ggplot(df, aes(x*t, y*t))<br>p + geom_point(size = 8, alpha = 0.5, color = “darkgreen”) +<br> theme(title = element_blank(),<br> text = element_blank(),<br> panel.grid = element_blank(),<br> panel.background = element_rect(fill = “white”))</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*LPeIkiuUDn-s-_6D9pwzxw.png" /></figure><h3>6. Play with aesthetics: the dandelion<a href="https://sessions.datacamp.com/proxy/absolute/7c0177d9-3d87-4984-903b-7e16c61744e4/notebooks/production/users/10929734/bo5uz39hdq/notebooks/notebook.ipynb#6.-Play-with-aesthetics:-the-dandelion">¶</a></h3><p>Until now, all points have the same appearance (size, color, shape, and alpha). Sometimes we will want to make the appearance of the points dependent on a variable in the dataset. Now we will make the size variable. We will also change the shape of the points. Although we won&#39;t be able to blow on it, the resulting image should remind you of a dandelion.</p><p># Copy the code from Task 5 and modify the <br># color, size, and shape of the points<br>p &lt;- ggplot(df, aes(x*t, y*t))<br>p + geom_point(aes(size = t), alpha = 0.5, color = “black”, shape = 8) +<br> theme(title = element_blank(),<br> text = element_blank(),<br> panel.grid = element_blank(),<br> legend.position = “none”, <br> panel.background = element_rect(fill = “white”))</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*ITTFnY4rmoPt4mqC3S3L0Q.png" /></figure><h3>7. Put all it together: the sunflower<a href="https://sessions.datacamp.com/proxy/absolute/7c0177d9-3d87-4984-903b-7e16c61744e4/notebooks/production/users/10929734/bo5uz39hdq/notebooks/notebook.ipynb#7.-Put-all-it-together:-the-sunflower">¶</a></h3><p>Plants not only use the Golden Angle to arrange leaves. The Golden Angle is also found in the arrangement of sunflower seeds. We don’t need anything new to draw a sunflower; we just need to combine some of the things we already know.</p><p># Copy the code from Task 6 and modify the color and<br># shape of the points, and the background color<br>p &lt;- ggplot(df, aes(x*t, y*t))<br>p + geom_point(aes(size = t), alpha = 0.5, color = “yellow”, shape = 17) +<br> theme(title = element_blank(),<br> text = element_blank(),<br> panel.grid = element_blank(),<br> legend.position = “none”, <br> panel.background = element_rect(fill = “darkmagenta”))</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*ap-UU_p3HlFA1kGjA1nIFA.png" /></figure><h3>8. What if you modify the angle?<a href="https://sessions.datacamp.com/proxy/absolute/7c0177d9-3d87-4984-903b-7e16c61744e4/notebooks/production/users/10929734/bo5uz39hdq/notebooks/notebook.ipynb#8.-What-if-you-modify-the-angle?">¶</a></h3><p>These patterns are very sensitive to the angle between the points that form the spiral. Small changes to the angle can generate very different images. Let’s look at an example of that.</p><p># Change the value of the angle<br>angle &lt;- 2.0 #pi*(3-sqrt(5))<br>points &lt;- 1000</p><p>t &lt;- (1:points)*angle<br>x &lt;- sin(t)<br>y &lt;- cos(t)<br>df &lt;- data.frame(t, x, y)</p><p># Copy the plotting code from Task 7<br>p &lt;- ggplot(df, aes(x*t, y*t))<br>p + geom_point(aes(size = t), alpha = 0.5, color = “yellow”, shape = 17) +<br> theme(title = element_blank(),<br> text = element_blank(),<br> panel.grid = element_blank(),<br> legend.position = “none”, <br> panel.background = element_rect(fill = “darkmagenta”))</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*eBGbzzS1KV4gGaP11yl26g.png" /></figure><h3>9. All together now: imaginary flowers<a href="https://sessions.datacamp.com/proxy/absolute/7c0177d9-3d87-4984-903b-7e16c61744e4/notebooks/production/users/10929734/bo5uz39hdq/notebooks/notebook.ipynb#9.-All-together-now:-imaginary-flowers">¶</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Qkae5OhCvF3oTuwM.png" /></figure><p>The techniques we’ve used so far allow us to create an <em>infinite</em> number of patterns inspired by nature: the only limit is our imaginations. But making art has also been a fun excuse to learn to use ggplot2. All the tricks we have seen in this notebook are useful when plotting <em>real</em> data too.</p><p>The image on the left is a simple variation of the previous flower and is in essence very similar to the first figure in which we plotted 50 points in a circle. I hope you’ve enjoyed the journey between that simple circle and this beautiful flower.</p><p># Change the values of angle and points<br>angle &lt;- 13*pi/180 #pi*(3-sqrt(5))<br>points &lt;- 2000</p><p>t &lt;- (1:points)*angle<br>x &lt;- sin(t)<br>y &lt;- cos(t)<br>df &lt;- data.frame(t, x, y)</p><p># Adjust the plot parameters to create the magenta flower<br>p &lt;- ggplot(df, aes(x*t, y*t))<br>p + geom_point(size = t, alpha = 0.1, shape = 1, color = “magenta4”)+<br> theme(legend.position=”none”,<br> panel.background = element_rect(fill = “white”),<br> panel.grid=element_blank(),<br> axis.ticks=element_blank(),<br> axis.title=element_blank(),<br> axis.text=element_blank())</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*CxSD-ToC-zvcJ8ODe3w7vg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20352289c127" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Customer Satisfaction Analysis using SQL]]></title>
            <link>https://isfaque45.medium.com/customer-satisfaction-analysis-using-sql-7dacd7b0fb6f?source=rss-c7c851989e99------2</link>
            <guid isPermaLink="false">https://medium.com/p/7dacd7b0fb6f</guid>
            <dc:creator><![CDATA[Isfaque Ansari]]></dc:creator>
            <pubDate>Wed, 16 Aug 2023 17:07:10 GMT</pubDate>
            <atom:updated>2023-08-16T17:07:10.991Z</atom:updated>
            <content:encoded><![CDATA[<p>Description: This project involves analyzing customer satisfaction survey data using SQL to extract insights and trends.</p><p>Certainly! Here’s an example project outline for conducting a Customer Satisfaction Analysis using SQL:</p><p>Project Name: Customer Satisfaction Analysis using SQL</p><p>Description: This project involves analyzing customer satisfaction survey data using SQL to extract insights and trends.</p><p>Tasks:</p><ol><li>Database Setup and Data Import:</li></ol><ul><li>Set up a database or use an existing database management system.</li><li>Create tables to store survey data, including fields for survey responses, customer IDs, and timestamps.</li><li>Import the customer satisfaction survey data into the database.</li></ul><p>2.Data Exploration and Cleansing:</p><ul><li>Write SQL queries to explore the data’s structure and distribution.</li><li>Identify and handle missing values, if any.</li><li>Ensure the data is clean and ready for analysis.</li></ul><p>3.Calculating Satisfaction Scores:</p><ul><li>Use SQL functions to calculate satisfaction scores from survey responses.</li><li>Create calculated fields for overall satisfaction, product satisfaction, service satisfaction, etc.</li></ul><p>4.Segmentation and Cross-Tabulations:</p><ul><li>Divide customers into segments based on satisfaction scores or other attributes.</li><li>Use SQL queries to perform cross-tabulations to understand relationships between satisfaction and demographic variables.</li></ul><p>5.Trend Analysis and Time Series:</p><ul><li>Analyze satisfaction trends over time using SQL.</li><li>Calculate averages, changes, and other metrics to identify patterns in customer satisfaction.</li></ul><p>6.Joining with Demographic Data:</p><ul><li>Join survey data with demographic information (if available) to analyze satisfaction by customer segments.</li><li>Extract insights about how satisfaction varies across different customer group</li></ul><pre>-- Calculate overall satisfaction score<br>SELECT customer_id,<br>       AVG(response_score) AS overall_satisfaction<br>FROM survey_data<br>GROUP BY customer_id;</pre><pre>-- Cross-tabulation of satisfaction scores by product<br>SELECT product_name,<br>       AVG(CASE WHEN response_score &gt;= 4 THEN 1 ELSE 0 END) AS satisfied_percentage<br>FROM survey_data<br>JOIN products ON survey_data.product_id = products.product_id<br>GROUP BY product_name;</pre><pre>-- Trend analysis of satisfaction over time<br>SELECT DATE_FORMAT(timestamp, &#39;%Y-%m&#39;) AS year_month,<br>       AVG(response_score) AS avg_satisfaction<br>FROM survey_data<br>GROUP BY year_month<br>ORDER BY year_month;</pre><pre>-- Customer segmentation based on satisfaction scores<br>SELECT customer_id,<br>       CASE<br>           WHEN overall_satisfaction &gt;= 4.5 THEN &#39;Highly Satisfied&#39;<br>           WHEN overall_satisfaction &gt;= 3.5 THEN &#39;Moderately Satisfied&#39;<br>           ELSE &#39;Less Satisfied&#39;<br>       END AS satisfaction_segment<br>FROM (SELECT customer_id,<br>             AVG(response_score) AS overall_satisfaction<br>      FROM survey_data<br>      GROUP BY customer_id) AS satisfaction_scores;</pre><pre>-- Joining with demographic data<br>SELECT customers.customer_id,<br>       customers.age,<br>       customers.gender,<br>       satisfaction_scores.overall_satisfaction<br>FROM customers<br>JOIN (SELECT customer_id,<br>             AVG(response_score) AS overall_satisfaction<br>      FROM survey_data<br>      GROUP BY customer_id) AS satisfaction_scores<br>ON customers.customer_id = satisfaction_scores.customer_id;</pre><p>Please note that you should replace the table and field names (survey_data, customer_id, response_score, etc.) with your actual database schema and column names. Adapt the queries based on your specific requirements and database structure.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7dacd7b0fb6f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Market Segmentation Analysis using R]]></title>
            <link>https://isfaque45.medium.com/market-segmentation-analysis-using-r-e142eceedbe5?source=rss-c7c851989e99------2</link>
            <guid isPermaLink="false">https://medium.com/p/e142eceedbe5</guid>
            <dc:creator><![CDATA[Isfaque Ansari]]></dc:creator>
            <pubDate>Wed, 16 Aug 2023 17:00:46 GMT</pubDate>
            <atom:updated>2023-08-16T17:00:46.492Z</atom:updated>
            <content:encoded><![CDATA[<p>Description: This project involves performing a market segmentation analysis on survey data to identify distinct consumer segments based on demographic and preference variables.</p><p>Certainly! Here’s an example project outline for conducting a Market Segmentation Analysis using R:</p><p>Project Name: Market Segmentation Analysis using R</p><p>Description: This project involves performing a market segmentation analysis on survey data to identify distinct consumer segments based on demographic and preference variables.</p><p>Tasks:</p><ol><li>Data Preprocessing and Exploration:</li></ol><ul><li>Load and import the survey data into R.</li><li>Explore the dataset’s structure, missing values, and variable types.</li><li>Clean the data by handling missing values and outliers.</li></ul><p>2.Feature Selection and Transformation:</p><ul><li>Select relevant demographic and preference variables for segmentation.</li><li>Normalize or standardize variables as needed for clustering.</li></ul><p>3.Clustering Analysis:</p><ul><li>Utilize K-means clustering algorithm to segment the market.</li><li>Determine the optimal number of clusters using techniques like the elbow method.</li><li>Perform K-means clustering using the selected variables.</li></ul><p>4.Visualizing Segment Profiles:</p><ul><li>Create visualizations to understand the distribution of each segment.</li><li>Develop scatter plots, histograms, or bar charts to visualize differences between segments.</li><li>Use R’s ggplot2 library for creating high-quality visualizations</li></ul><p>5.Interpreting and Profiling Segments:</p><ul><li>Analyze the characteristics of each segment based on the selected variables.</li><li>Interpret the results and assign descriptive names to the segments.</li><li>Compare segment profiles and identify key differences.</li></ul><p>6.Recommendations for Targeted Marketing:</p><ul><li>Provide recommendations for targeted marketing strategies for each segment.</li><li>Suggest ways to tailor marketing messages, products, or services to each segment’s preferences.</li></ul><p># Load necessary libraries<br>library(ggplot2)<br>library(dplyr)<br>library(cluster)</p><p># Load and preprocess survey data<br>survey_data &lt;- read.csv(“survey_data.csv”) # Replace with actual file path<br>cleaned_data &lt;- survey_data %&gt;% <br> na.omit() # Remove rows with missing values</p><p># Select relevant variables<br>selected_vars &lt;- cleaned_data %&gt;% <br> select(age, income, preference1, preference2)</p><p># Standardize variables<br>scaled_vars &lt;- scale(selected_vars)</p><p># Determine optimal number of clusters (e.g., using elbow method)<br>wss &lt;- (nrow(scaled_vars) — 1) * sum(apply(scaled_vars, 2, var))<br>for (i in 2:10) {<br> wss[i] &lt;- sum(kmeans(scaled_vars, centers = i)$withinss)<br>}<br>plot(1:10, wss, type = “b”, xlab = “Number of Clusters”, ylab = “Within-Cluster Sum of Squares”)</p><p># Perform K-means clustering<br>num_clusters &lt;- 3 # Set the determined number of clusters<br>kmeans_result &lt;- kmeans(scaled_vars, centers = num_clusters)</p><p># Add cluster assignments to cleaned_data<br>cleaned_data$cluster &lt;- kmeans_result$cluster</p><p># Visualize segment profiles<br>ggplot(cleaned_data, aes(x = age, y = income, color = factor(cluster))) +<br> geom_point() +<br> labs(title = “Market Segmentation Analysis”,<br> x = “Age”, y = “Income”,<br> color = “Cluster”)</p><p># Interpret and profile segments<br>segment_profiles &lt;- cleaned_data %&gt;%<br> group_by(cluster) %&gt;%<br> summarize(mean_age = mean(age),<br> mean_income = mean(income),<br> preference1_avg = mean(preference1),<br> preference2_avg = mean(preference2))</p><p># Print segment profiles<br>print(segment_profiles)</p><p># Provide targeted marketing recommendations based on segment profiles<br># Add your insights and recommendations here based on the analysis results</p><p>Remember to adapt the code to your specific dataset and requirements. This example provides a basic framework for conducting market segmentation analysis using R and the kmeans function for clustering.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e142eceedbe5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploratory Data Analysis (EDA)]]></title>
            <link>https://isfaque45.medium.com/exploratory-data-analysis-eda-e29c3b88952?source=rss-c7c851989e99------2</link>
            <guid isPermaLink="false">https://medium.com/p/e29c3b88952</guid>
            <dc:creator><![CDATA[Isfaque Ansari]]></dc:creator>
            <pubDate>Tue, 18 Jul 2023 12:33:09 GMT</pubDate>
            <atom:updated>2023-07-18T12:33:09.642Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tnfDG-4jAkfzv6qV-q9GUA.gif" /></figure><p>Exploratory data analysis is the initial stage of data analysis that focuses on discovering patterns, relationships, and trends in the data. EDA involves the use of visual and statistical methods to explore and summarize the data, and to generate hypotheses that can be further tested using more advanced statistical techniques.</p><p>For this analysis, we will be using the bestseller books dataset from Amazon, which contains information on the top selling books in various categories. We will start by exploring the dataset to gain an understanding of its structure and content, and then use visualizations and statistical techniques to explore relationships between variables.</p><p>We will begin by looking at basic statistics of the dataset, such as mean, median, and standard deviation, as well as examining the distribution of variables using histograms and box plots. Then, we will use bar charts to visualize the frequency of categorical variables, such as genre, and examine the relationship between genre and book reviews using bar charts and box plots.</p><p>Additionally, we will explore the relationship between price and genre using a box plot and examine the top 20 best-selling authors by reviews using a bar chart. Finally, we will explore the relationship between price and book reviews by creating price ranges and examining the mean reviews for each range using a box plot.</p><p>Overall, this article aims to provide a comprehensive overview of EDA techniques and how they can be applied to real-world data analysis. By the end of this article, you should have a good understanding of how to use visual and statistical techniques to explore and summarize data.</p><h3>Importing Libraries</h3><p>Here are some of the libraries that will keep Amazon’s bestsellers in this article, which we’ll analyze: pandas, numpy, matplot, and the seaborn library.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/382/1*wfLgWwXfjDhDUhFNrekOHw.png" /></figure><h3>Reading and understanding the dataset</h3><p>Using pandas <strong>read_csv </strong>function to read the loaded dataset and<strong> head()</strong> and tail() functions to look at the first and last five rows of data and the variables with their respective values. The column values are basically features that will be used to analyse the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*f-ZSF07bux5Fg9c80P9sbQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*p4RXioZzvcydzr2MMh6fiQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*GK5tJJSBK4fEDllZU8dweA.png" /></figure><p>The <strong>.info()</strong> function is used to get additional details about these features as shown. It can be inferred from this that there are 4 numerical features and 3 categorical features by referring to their data types.</p><h3>Getting insights and visualizations</h3><p>Now let’s get some statistics for the given features using <strong>.describe() or describe().T</strong>,</p><h3>Numerical Features Statistics:</h3><p>By the way, I’m thinking of making it more readable by taking the transpose</p><h3>Categorical Feature Statistics:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*bW2_g0RdqU1rliGNoLODMg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*UT2GzbvOoPOh-qTM9-azHg.png" /></figure><p>Using <strong>value_count()</strong> to get the count of fiction and non-fiction in genre column and visualizing it using seaborn’s countplot function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*ymwcWNi7Bq-Zq5cxpmoWBA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/921/1*iJVd7-okpUFpyCygKn79Jw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/545/1*0owP8l-DXYwu1Fwm2fGmtA.png" /></figure><p>We can also implement boxplots for visualizing the distribution of books across various features, as an example here, the price distribution of books is shown across the genre and price.</p><p>We can also implement boxplots for visualizing the distribution of books across various features, as an example here, the price distribution of books is shown across the genre and price.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/1*ED63sxt1DJSG96H4ZgE5pA.png" /></figure><p>Next up, a double bar plot is shown, they can come in handy in cases like these when we have two sets of data such as fictional and non-fictional books here. So, the data both of these sets can be visualized in one plot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*ALkZqv69JaXlgQBTEfS06w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/1*QPusH6f02SYM6zcjjPg8Hg.png" /></figure><p>It is also seen that there are recurrent values in this particular dataframe, which can be removed by <strong>drop_duplicates() </strong>function to have a clear picture of what one is dealing with.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*e-n01dFo_WIVnekYH-CIDA.png" /></figure><p>We can also explore the statistics of each feature exclusively, such as of Price shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/503/1*ir8oU96WtIQrFTQMHlXVIQ.png" /></figure><p>It is also possible to split data into ranges to get meaningful insights, here the Price values are divided into three ranges as shown using cut function from pandas and a new feature called<strong> PriceRange</strong> is made. This is used to get a distribution of reviews depending on the price, and clearly low-priced books have the highest number of reviews.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e29c3b88952" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spotify Data Analysis — EDA]]></title>
            <link>https://isfaque45.medium.com/spotify-data-analysis-eda-b6a8f27c9785?source=rss-c7c851989e99------2</link>
            <guid isPermaLink="false">https://medium.com/p/b6a8f27c9785</guid>
            <dc:creator><![CDATA[Isfaque Ansari]]></dc:creator>
            <pubDate>Sun, 09 Jul 2023 06:26:57 GMT</pubDate>
            <atom:updated>2023-07-09T06:26:57.007Z</atom:updated>
            <content:encoded><![CDATA[<h3>Spotify Data Analysis — EDA</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*Xpyxl6IDlr7lKoUQ9lxXgg.png" /><figcaption><em>Spotify is a popular app for music lovers. For our analysis, we are going to be using a dataset from Kaggle that has data of all Top Spotify songs between the years 2010–2019.We will be using R programming to clean,Transform,Analyse and visualize data.Here is a link to the Kaggle dataset used:</em></figcaption></figure><h3>About the dataset:</h3><h3>About the dataset:</h3><p>These are the most popular songs organized by year and there are 13 variables to be explored. The dataset contains different fields for each song release such as song title, and artist. genre, Energy, Loudness, etc.Here are all the fields and their descriptions:</p><ul><li><strong>title:</strong> Song’s title</li><li><strong>artist:</strong> Song’s artist</li><li><strong>top genre: </strong>the genre of the track</li><li><strong>year: </strong>Song’s year in the Billboard</li><li><strong>bpm:</strong> Beats Per Minute — The tempo of the song.</li><li><strong>nrgy:</strong> Energy: The energy of a song — the higher the value, the more energetic. song</li><li><strong>dnce:</strong> Danceability — The higher the value, the easier it is to dance to this song.</li><li><strong>dB:</strong> Volume: The higher the value, the louder the song</li><li><strong>live: </strong>Liveness — The higher the value, the more likely the song is a live recording</li><li><strong>val:</strong> Valence — The higher the value, the more positive mood for the song.</li><li><strong>dur: </strong>Length — The duration of the song.</li><li><strong>acous:</strong> Acousticness.. — The higher the value the more acoustic the song is.</li><li><strong>spch:</strong> Speechiness — The higher the value the more spoken word the song contains.</li><li><strong>pop: </strong>Popularity- The higher the value the more popular the song is.</li></ul><h3>QUESTIONS TO BE ANSWERED:</h3><p>This will be an Exploratory data analysis of the Spotify dataset and we will be discovering some useful and interesting insights.</p><p>1) What can we know about the genre?</p><p>2) What is the mean of minutes that top music has?</p><p>3) 10 most popular songs through 2010–2019</p><p>4) Total songs released genre-wise and year wise</p><p>5) Artist vs no.of.songs released</p><p>6) Correlation b/w different aspects:</p><p>· Beats Per Minute Vs Popularity</p><p>· Energy vs Popularity</p><p>· Beats Per Minute vs Energy</p><p>· Beats Per Minute vs Dance</p><p>· Energy vs Dance</p><p>· Volume vs Popularity</p><p>· Valence vs Popularity</p><p>· Speechiness vs Popularity</p><h3>DATA CLEANING:</h3><ul><li>The first column name missing was replaced.</li><li>Statistics and Summary of all columns were checked.</li><li>Ensured data was indeed for years between 2010–2019.</li><li>One song with serial number 443, Million Years Ago by Adele has NULL values in most fields.</li><li>Removed Duplicate entry for the song “The Hills”. Removed the entry for the year 2016.</li></ul><p><em>Here are code snippets in R for Setting Up and data wrangling:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/0*u9WDVJyb11thcuxb.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/0*b4RjThtDyXCuR2sR.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/0*99SQIO5Sn_pcprll.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/0*Sv8jm4BvkWOlU8wL.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/849/0*lXeTxL3HSpbvPnMY.png" /></figure><h3>DATA TRANSFORMATION:</h3><p>Simplify the genres into 29 categories from over 50. Categorized all types of pop as “pop” and all types of hip hop as “hip hop”.</p><p><em>Here are code snippets in R for data transformation:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*8h5RDGrTWO9i9_11.png" /></figure><h3>DATA ANALYSIS:</h3><p>Various statistics were obtained through the analysis process:</p><ol><li>Top 10 songs over 2010–2019</li><li>Top 1 song of the year.</li><li>Mean Duration Genre-wise.</li><li>Number of songs released by every artist.</li><li>Highest positivity, energy, and danceability songs.</li><li>Longest and Shortest song of all time.</li><li>Most popular artist in 2019.</li></ol><p><em>Here are code snippets in R for data analysis:</em></p><ol><li>Finding the Top 10 Popular Songs(2010–2019): Memories by Maroon 5 was the top-most song. Most of these songs were from the “pop” genre.</li></ol><p><em>Here are code snippets in R for data analysis:</em></p><ol><li>Finding the Top 10 Popular Songs(2010–2019): Memories by Maroon 5 was the top-most song. Most of these songs were from the “pop” genre.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/0*e5XQnlcX8Al1ey6K.png" /></figure><p>2. Looking at the Top 1 Song for every single year between 2010–2019.This is also dominated by the genre “pop”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/0*5aNE3wKrBmw3KAaH.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*isH50HmX3OENwprk.png" /></figure><p>3. The genre with the longest song duration on average is: “chicago rap”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*cC6mE_v-5xvC6lt6.png" /></figure><p>4. The artist with the highest number of songs released between the years 2010–2019 is Katy Perry with 17 songs released over the years 2010–2019.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Rcdm9ah4CaBPz_jC.png" /></figure><p>5. The genre with the highest positivity, songs that have high energy, and dance numbers were analyzed to recommend appropriate songs for activities like workout beats/motivational songs/dance numbers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/0*MZMERlhcwZxw0jC8.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/0*ghXobOimuLed6wpZ.png" /></figure><p>6. Most popular artist in the recent year 2019 was also found to be Ed Sheeran.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/0*qAYNgAu_a9rQ-BDU.png" /></figure><h3>DATA VISUALIZATION:</h3><p>Various bar, scatter, and point+ smooth plotting functions were used to derive insights into the dataset. Plotting was done with the information we found in the Analysis phase.</p><p><strong>Plot 1: </strong><em>Plot 2019 popular artist data:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/0*WGN3JGLsSFcfZZ0W.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*iRikJN5meEyiMROF.png" /></figure><p>Ed Sheeran was the most popular artist in the year 2019 with the most number of songs — 5 followed by The Chainsmokers with 3 songs in the year 2019. All of Ed Sheeran’s songs were from the “pop” genre.</p><p><strong>Plot 2: </strong><em>Top 1 song of every year.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*JeHd-hfCD76ckQo2.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*rtvCif_BqWxqTeyf.png" /></figure><p>It is evident from the plot that “pop” is again the most popular genre and 9 songs are from “pop”.</p><p><strong>Plot 3:</strong> T<em>op 10 songs of all time based on popularity.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*AsJfS_rCuaOTvb0g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*aCh_b875wwimRTcO.png" /></figure><p>Top songs of all time also have a lot of “pop” genres. The Top 1 song of all time is Memories by Maroon 5 followed by Lose You To Love Me by Selena Gomez.</p><p><strong>Plot 4: </strong><em>Top 10 artists vs Total no.of.songs released &amp; arranging the bars.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*VrLrL78nrwhXC3tT.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*-jKWT0SATt5RiU-8.png" /></figure><p>Katy Perry has released the most number of songs throughout the years 2010–2019 followed closely by Justin Bieber and Rihanna.</p><p><strong>Plot 5:</strong> <em>Are all the popular songs from a single genre?</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*h4ttTEzKWNbsdLBY.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*UHxyg4C7sJBEq0Ux.png" /></figure><p>You guessed it right! Pop seems to be dominating in every aspect!</p><p><strong>Plot 6: </strong><em>Let us do some plots to find the correlation between various variables.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/0*qJnMWDqA7a9z8wbQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/0*N4d7MrdkL4p0CYZh.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/0*J2R3pifK0Kkx8kZ3.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/0*YS_M8Lw8mmlL-ecO.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/0*8PDwg03xGTqdOA8r.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/0*-W2_NhurcyDdVHKc.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/0*cNMosx-otGhYcc5F.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/0*Tv-NdgC6RAWhX5DM.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/0*-TQXH1J4AzRP4q3z.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/0*uPxuAabsa0KL24vx.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/0*1ep7oPdOAs29yIfk.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/0*HUckpNboNjg_N1PQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/0*8HBTFOG96sbxmzkr.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/0*sI2_QFSvTa9mXOF2.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/0*knuTKCu1kSjBY3PW.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/0*csFpeCgm5cwZBnRC.png" /></figure><p>The correlation value was also calculated and they are as follows:</p><p>1. Beats Per Minute Vs Popularity → 0.019</p><p>2. Energy vs Popularity → -0.055</p><p>3. Beats Per Minute vs Energy → 0.125</p><p>4. Beats Per Minute vs Dance → -0.131</p><p>5. Energy vs Dance → 0.166</p><p>6. Volume vs Popularity → 0.158</p><p>7. Valence vs Popularity → 0.042</p><p>8. Speechiness vs Popularity → -0.040</p><p>None of these variables have any correlation between them.</p><p><strong>Plot 7: </strong><em>Let us find the correlation between Positivity and energy and let us see which genres are dominant.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*uKPpgXpSLl63M56N.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*zOUTPEyP9AEeXrC0.png" /></figure><p>The correlation value for positivity and energy is 0.408 which means they are correlated. The results are more evident in the genres like pop, hip-hop, neo-mellow, and Australian dance.</p><p><em>A correlation between two variables is known to exist if the value is closer to 1/-1 and no correlation if it is closer to zero.</em></p><h3>CONCLUSIONS:</h3><ol><li>Katy Perry is the artist with the most top songs from 2010–2019, with 17 songs.</li><li>Maroons 5 Memories is the most popular song from 2010–2019 with a score of 99.</li><li>Most of the popular songs throughout the years are from the “pop” genre, the most popular genre is also pop.</li><li>For some positive songs to relieve stress and motivate yourself go for: Mmm Yeah (feat. Pitbull)by Austin Mahone, There’s Nothing Holdin’ Me Back by Shawn Mendes, and the pop genre seems to have a lot of positive songs.</li><li>For some high-energy workout beats go for: Hello by Martin Solveig and Pom Poms by Jonas Brothers. This category is also dominated by pop but the genre of boy band also seems to be doing good with high-energy songs.</li><li>For some good dance numbers at your party go for songs like Bad Liar by Selena Gomez and Drip (feat. Migos) by Cardi B. This category is dominated by hip-hop, dance-pop, and pop.</li><li>Correlations between many variables were plotted. However, the highest correlation seems to exist between Positivity and Energy, especially in the genres: Pop, hip-hop, Australian dance, neo-mellow, and boy band.</li><li>The longest song is TKO by Justin Timberlake with 424 sec and the shortest is Mark My Words by Justin Bieber with 134s as the duration.</li><li>The most popular songs were produced by Ed Sheeran in the year 2019.</li></ol><p>Thanks for reading!</p><p><a href="https://medium.com/tag/data-analysis?source=post_page-----b585970d8bd2---------------data_analysis-----------------">Data Analysis</a></p><p><a href="https://medium.com/tag/data-analyst?source=post_page-----b585970d8bd2---------------data_analyst-----------------">Data Analyst</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/306/1*flYzhXVMPHwJxmQyLmdvMQ.jpeg" /></figure><h3><a href="https://medium.com/@jananibalaji20?source=post_page-----b585970d8bd2--------------------------------">Written by </a>Isfaque Ansari</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b6a8f27c9785" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Analysis — Bellabeat]]></title>
            <link>https://isfaque45.medium.com/data-analysis-bellabeat-e09738a24f66?source=rss-c7c851989e99------2</link>
            <guid isPermaLink="false">https://medium.com/p/e09738a24f66</guid>
            <dc:creator><![CDATA[Isfaque Ansari]]></dc:creator>
            <pubDate>Thu, 09 Feb 2023 19:39:00 GMT</pubDate>
            <atom:updated>2023-02-09T19:39:00.380Z</atom:updated>
            <content:encoded><![CDATA[<h3>Data Analysis — Bellabeat</h3><p>Google Data Analytics Capstone Project</p><p>For this project I was tasked as part of the Bellabeat marketing analytics team with <strong>providing analysis and marketing / growth recommendations for Bellabeat</strong> — a high-tech manufacturer of health-focused products for women. They’re a smaller company competing in the global smart device market and they’re looking for growth opportunities in the space.</p><h3>Stakeholders</h3><p>The target audience for this presentation were the cofounder executives of the company:</p><p>.Urška Sršen — Chief Creative Officer</p><ul><li>Sando Mur — Mathematician</li></ul><h3>Bellabeat Products</h3><ul><li><strong>Leaf </strong>— flagship wellness tracker</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/0*pX9VP1hGW-9l-C2r.png" /></figure><ul><li><strong>Time</strong> — tracks activity, sleep and stress</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/195/0*t5lK3ITEdgdLF9zC.png" /></figure><ul><li><strong>Ivy (Bellabeat app)</strong> — pairs with all Bellabeat smart products to track heart rate, respiration, activity, sleep and cycle. Calculates <em>Readiness score </em>as well as <em>Wellness score</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/397/0*uHcZxN2x4IR_fpfv.png" /></figure><h3>Case Study Presentation</h3><p><strong>Overview</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*ad8Km-1y6XFfYGFg.jpeg" /></figure><p><strong>Business Task — </strong>what are we trying to accomplish with this analysis?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*9FOKzrnI87aTpJ_Q.jpeg" /></figure><p><strong>Data Source</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*zLnjnrMpjSKALI1n.jpeg" /></figure><p><strong>Cleaning and Manipulation — SQL</strong></p><p>The biggest issue with the data was inconsistency related to the number of days the data was tracked. In a perfect world all 33 users would report data for all 30 days of tracking but this was not the case. This was made obvious with <strong>SQL:</strong></p><p>SELECT <br>DISTINCT id,<br>COUNT(activitydate)<br>FROM bellabeast.activity<br>GROUP BY id<br>ORDER BY COUNT(activitydate)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/222/0*l1AbLjH9itgWoodd.png" /></figure><p>User <strong>…2912</strong> was therefore eliminated from further analysis of activity data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*XV67v--nmoJAYAac.jpeg" /></figure><p>Similar queries discovered similar reporting issues at larger scale with sleep and weight data. Sleep data users with less than 8 sleep days were eliminated from the analysis and weight data was not used at all as there were only two users with enough sleep days to warrant analysis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*vhw7jm-An_QKEums.jpeg" /></figure><p>It was important to note the data tracks both men and women since Bellabeat focuses exclusively on women. The lack of certain data was an indicator of user pain points which represented opportunities for Bellabeat.</p><p><strong>Data Visualization — Tableau</strong></p><p>From here data was uploaded to tableau to visually understand trends and relationships and usage was broken down by average daily minutes to be more intuitive.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*_dToME1-I1Smelij.jpeg" /></figure><p>It became obvious there was a strong relationship between two groups of activity levels and two outlier users were eliminated from this data set to make the relationship more visually obvious.</p><p>From here the data was segmented to make it more useful for marketing to understand who they should be targeting and how.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*EnKnHktdFs7lXGYx.jpeg" /></figure><p>In order to understand if there was a relationship between sleep and activity, I used SQL to join the two tables and then uploaded it to tableau to visually analyze the data. The sleep minutes were converted to hours to make the data more intuitive since most people aim for 7–8 hours a night, not 450 minutes.</p><p>SELECT <br> a.id,<br> a.activitydate,<br> a.totalsteps,<br> a.totaldistance,<br> a.veryactivedistance,<br> a.moderatelyactivedistance,<br> a.lightactivedistance,<br> a.SedentaryActiveDistance,<br> a.veryactiveminutes,<br> a.fairlyactiveminutes,<br> a.lightlyactiveminutes,<br> a.sedentaryminutes,<br> a.calories,<br> s.TotalMinutesAsleep,<br> s.totaltimeinbed,<br> AVG(s.TotalMinutesAsleep) / 60 AS avgsleephours<br>FROM activity a<br>JOIN sleep s USING (id)<br>WHERE a.activitydate = s.sleepday<br>GROUP BY <br>s.id</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*ceIuacSNKGnhgZjO.jpeg" /></figure><p>Here it was discovered that there was a relationship between Light Activity and sleep — a useful observation and potential marketing selling point.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*vedDdidJpz3RRc-g.jpeg" /></figure><p>Three potential marketing campaigns grew out of this analysis, the first targeting “Power Users”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*kBX8bLuY1IyoIstX.jpeg" /></figure><p>Power Users were defined as users with activity levels &gt; 30 minutes per day of fairly or intense levels of exercise and this niche group is likely to be more responsive to highly targeted or niche activities listed in the above slide.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*W9tWu2YjtXrs8Mmi.jpeg" /></figure><p>The Active Casual group represented a larger segment of the more active group and so it makes more sense to have a broader marketing scope when appealing to these potential customers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*msPCDfbrY_8YML0V.jpeg" /></figure><p>For marketing there was a useful relationship discovered between sleep and Light Activity and this forms the basis for the 3rd marketing campaign — GET SHIT DONE. It’s important here to note this doesn’t mean there’s a causal relationship but it’s enough that users can infer additional health-related benefits of higher levels of Light Activity, specifically in relation to sleep.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*saukurqp7bCGL39-.jpeg" /></figure><p>The issues with sleep and weight data prompted some questions and potential growth opportunities for Bellabeat. There were some useful insights here not only for marketing but for the product team as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*F6ksf4PjJvfOmg2f.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*YsTCx6nkU8AsokUz.jpeg" /></figure><p>If sleep is indeed an area Bellabeat wants to grow in, then it’s important to consider which product should focus on that and whether that product is “sleep friendly” as suggested by the above slide.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*0zbl-l-pqGEd_y-b.jpeg" /></figure><p>It could even be an opportunity for a new product altogether. The design of the “Time” watch served as a useful baseline as some of the features with this specific product are more “sleep friendly”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*jxb4gDN4s_vgWEGl.jpeg" /><figcaption>The weight data was highly problematic and prompted more questions to guide us towards better ways to implement weight tracking as there are clear pain points when recording this data. Only 2% of users recorded enough data to be useful. Or perhaps this metric was just less important for the fitbit users? Either way, the data suggests further inquiry is needed by Bellabeat to better understand this metric and tailor user experience.</figcaption></figure><h3>Summary</h3><p>The vast majority of my cleaning and manipulation was done by uploading the excel data to SQL and querying the data there. The sleep analysis would have been much more difficult, if not impossible with excel pivot tables which is where I originally started.</p><p>Tableau was highly useful as it essentially combines Excel pivot tables with SQL and adds highly compelling visuals which helped me better understand trends and relationships. It also allowed me to segment users into buckets which was necessary to guide future marketing campaigns.</p><p>Lastly, the lack of data or inconsistency of data discovered by using SQL opened up new questions and potential growth opportunities, both of which could be highly valuable for Bellabeat in the form of a new product line or modifications to current products.</p><p><a href="https://medium.com/tag/data-visualization?source=post_page-----5c1bbb7e4688---------------data_visualization-----------------">Data Visualization</a>,<a href="https://medium.com/tag/data-analytics?source=post_page-----5c1bbb7e4688---------------data_analytics-----------------">Data Analytics</a>,<a href="https://medium.com/tag/mysql?source=post_page-----5c1bbb7e4688---------------mysql-----------------">My SQL</a>,<a href="https://medium.com/tag/bellabeat?source=post_page-----5c1bbb7e4688---------------bellabeat-----------------">Bellabeat</a>,<a href="https://medium.com/tag/tableau?source=post_page-----5c1bbb7e4688---------------tableau-----------------">Tableau</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e09738a24f66" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Wrangling and Visualizing Musical Data]]></title>
            <link>https://isfaque45.medium.com/wrangling-and-visualizing-musical-data-ba97f22c6e85?source=rss-c7c851989e99------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba97f22c6e85</guid>
            <dc:creator><![CDATA[Isfaque Ansari]]></dc:creator>
            <pubDate>Mon, 10 Oct 2022 16:11:15 GMT</pubDate>
            <atom:updated>2022-10-10T16:11:15.324Z</atom:updated>
            <content:encoded><![CDATA[<h3>1. Introduction<a href="#1.-Introduction">¶</a></h3><p>How do musicians choose the chords they use in their songs? Do guitarists, pianists, and singers gravitate towards different kinds of harmony?</p><p>We can uncover trends in the kinds of chord progressions used by popular artists by analyzing the harmonic data provided in the <a href="http://ddmal.music.mcgill.ca/research/billboard">McGill Billboard Dataset</a>. This dataset includes professionally tagged chords for several hundred pop/rock songs representative of singles that made the Billboard Hot 100 list between 1958 and 1991. Using the data-wrangling tools available in the dplyr package, and the visualization tools available in the ggplot2 package, we can explore the most common chords and chord progressions in these songs, and contrast the harmonies of some guitar-led and piano-led artists to see where the &quot;affordances&quot; of those instruments may affect the chord choices artists make.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*hY7tCj0xz4XLMBwv3gIEow.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*HusnP1plRKW4goUMD8tn5w.png" /></figure><h3>2. The most common chords<a href="#2.-The-most-common-chords">¶</a></h3><p>As seen in the previous task, this is a <em>tidy</em> dataset: each row represents a single observation, and each column a particular variable or attribute of that observation. Note that the metadata for each song (title, artist, year) is repeated for each chord — like “I Don’t Mind” by James Brown, 1961 — while the unique attributes of each chord (chord symbol, chord quality, and analytical designations like integer and Roman-numeral notation) is included once for each chord change.</p><p>A key element of the style of any popular musical artist is the kind of chords they use in their songs. But not all chords are created equal! In addition to differences in how they sound, some chords are simply easier to play than others. On top of that, some chords are easier to play on one instrument than they are on another. And while master musicians can play a wide variety of chords and progressions with ease, it’s not a stretch to think that even the best musicians may choose more “idiomatic” chords and progressions for their instrument.</p><p>To start to explore that, let’s look at the most common chords in the McGill Billboard Dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/333/1*EGPaOEsRjx-BmfImWZWgog.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*rAxlE3g4b8ZeWiL0kNC5Tg.png" /></figure><h3>3. Visualizing the most common chords<a href="#3.-Visualizing-the-most-common-chords">¶</a></h3><p>Of course, it’s easier to get a feel for just how common some of these chords are if we graph them and show the percentage of the total chord count represented by each chord. Musicians may notice right away that the most common chords in this corpus are chords that are easy to play on both the guitar and the piano: C, G, A, and D major — and to an extent, F and E major. (They also belong to keys, or scales, that are easy to play on most instruments, so they fit well with melodies and solos, as well.) After that, there is a steep drop off in the frequency with which individual chords appear.</p><p>To illustrate this, here is a short video demonstrating the relative ease (and difficulty) of some of the most common (and not-so-common) chords in the McGill Billboard dataset</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kNj5YsP12b6Y8k2KCmpQUg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*qpZQz5tPp5ZmeYFp7z4MUg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*nZbSYjhLbMsSXUgfXnsw2A.png" /></figure><h3>4. Chord “bigrams”</h3><p>Just as some chords are more common and more idiomatic than others, not all chord <em>progressions</em> are created equal. To look for common patterns in the structuring of chord progressions, we can use many of the same modes of analysis used in text-mining to analyze phrases. A chord change is simply a <em>bigram</em> — a two-”word” phrase — composed of a starting chord and a following chord. Here are the most common two-chord “phrases” in the McGill Billboard dataset. To help you get your ear around some of these common progressions, here’s a short audio clip containing some of the most common chord bigrams.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/416/1*BejQANChPS3dTYzmFQD7kQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*g3Bl7mJDaVJ19bZG692WnA.png" /></figure><h3>5. Visualizing the most common chord progressions<a href="#5.-Visualizing-the-most-common-chord-progressions">¶</a></h3><p>We can get a better sense of just how popular some of these chord progressions are if we plot them on a bar graph. Note how the most common chord change, G major to D major, occurs more than twice as often than even some of the other top 20 chord bigrams.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*FmKOLgyTjijs5_PbGHQ3rw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*boZD9MqzIaQmlJdo1JfAUg.png" /></figure><h3>6. Finding the most common artists<a href="#6.-Finding-the-most-common-artists">¶</a></h3><p>As noted above, the most common chords (and chord bigrams) are those that are easy to play on both the guitar and the piano. If the degree to which these chords are idiomatic on guitar or piano (or both) <em>determine</em> how common they are, we would expect to find the more idiomatic guitar chords (C, G, D, A, and E major) to be more common in guitar-driven songs, but we would expect the more idiomatic piano chords (C, F, G, D, and B-flat major) to be more common in piano-driven songs. (Note that there is some overlap between these two instruments.)</p><p>The McGill Billboard dataset does not come with songs tagged as “piano-driven” or “guitar-driven,” so to test this hypothesis, we’ll have to do that manually. Rather than make this determination for every song in the corpus, let’s focus on just a few to see if the hypothesis has some validity. If so, then we can think about tagging more artists in the corpus and testing the hypothesis more exhaustively.</p><p>Here are the 30 artists with the most songs in the corpus. From this list, we’ll extract a few artists who are obviously heavy on guitar or piano to compar</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/1*fgIvQeXe2saa8XRPQi2RHA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*pNOX1Otn9JwW0k2J3Us0Gg.png" /></figure><h3>7. Tagging the corpus</h3><p>There are relatively few artists in this list whose music is demonstrably “piano-driven,” but we can identify a few that generally emphasize keyboards over guitar: Abba, Billy Joel, Elton John, and Stevie Wonder — totaling 17 songs in the corpus. There are many guitar-centered artists in this list, so for our test, we’ll focus on three well known, guitar-heavy artists with a similar number of songs in the corpus: The Rolling Stones, The Beatles, and Eric Clapton (18 songs).</p><p>Once we’ve subset the corpus to only songs by these seven artists and applied the “piano” and “guitar” tags, we can compare the chord content of piano-driven and guitar-driven songs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*NbBurHirDbRc6dHAQafGTg.png" /></figure><h3>8. Comparing chords in piano-driven and guitar-driven songs</h3><p>Let’s take a look at any difference in how common chords are in these two song groups. To clean things up, we’ll just focus on the 20 chords most common in the McGill Billboard dataset overall.</p><p>While we want to be careful about drawing any conclusions from such a small set of songs, we can see that the chords easiest to play on the guitar <em>do</em> dominate the guitar-driven songs, especially G, D, E, and C major, as well as A major and minor. Similarly, “flat” chords (B-flat, E-flat, A-flat major) occur frequently in piano-driven songs, though they are nearly absent from the guitar-driven songs. In fact, the first and fourth most frequent piano chords are “flat” chords that occur rarely, if at all, in the guitar songs.</p><p>So with all the appropriate caveats, it seems like the instrument-based-harmony hypothesis does have some merit and is worth further examination.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*U8DowZI2OSEFG863DXWfjA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/1*YcL2JlSoqfPlHfE6FT7krA.png" /></figure><h3>9. Comparing chord bigrams in piano-driven and guitar-driven songs<a href="#9.-Comparing-chord-bigrams-in-piano-driven-and-guitar-driven-songs">¶</a></h3><p>Since chord occurrence and chord bigram occurrence are naturally strongly tied to each other, it would not be a reach to expect that a difference in chord frequency would be reflected in a difference in chord bigram frequency. Indeed that is what we find</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*QkSryRm4dBNs7S-0JRtLdw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/1*KcbQwFAt1Uqcb9ZaLr_zAQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*iDOcKEPt9s1535Blp4H2qw.png" /></figure><h3>10. Conclusion</h3><p>We set out asking if the degree to which a chord is “idiomatic” on an instrument affects how frequently it is used by a songwriter. It seems that is indeed the case. In a large representative sample of pop/rock songs from the historical Billboard charts, the chords most often learned first by guitarists and pianists are the most common. In fact, chords commonly deemed <em>easy</em> or <em>beginner-friendly</em> on <strong>both</strong> piano and guitar are far and away the most common in the corpus.</p><p>We also examined a subset of 35 songs from seven piano- and guitar-heavy artists and found that guitarists and pianists tend to use different sets of chords for their songs. This was an extremely small (and likely not representative) sample, so we can do nothing more than hypothesize that this trend might carry over throughout the larger dataset. But it seems from this exploration that it’s worth a closer look.</p><p>There are still more questions to explore with this dataset. What about band-driven genres like classic R&amp;B and funk, where artists like James Brown and Chicago build chords from a large number of instruments each playing a single note? What about “progressive” bands like Yes and Genesis, where “easy” and “idiomatic” may be less of a concern during the songwriting process? And what if we compared this dataset to a collection of chords from classical songs, jazz charts, folk songs, liturgical songs?</p><p>There’s only one way to find out!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*lrj5wFa61oVTxDZpRxe7jg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba97f22c6e85" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basic SQL]]></title>
            <link>https://isfaque45.medium.com/basic-sql-7364a48cad6d?source=rss-c7c851989e99------2</link>
            <guid isPermaLink="false">https://medium.com/p/7364a48cad6d</guid>
            <dc:creator><![CDATA[Isfaque Ansari]]></dc:creator>
            <pubDate>Fri, 16 Sep 2022 12:08:53 GMT</pubDate>
            <atom:updated>2022-09-16T12:08:53.493Z</atom:updated>
            <content:encoded><![CDATA[<p><em>For anyone looking for a hands-on tutorial, this is the right place. We’ll go into the specifics soon but first, let’s start with the basics</em></p><p>Source: <a href="https://www.flaticon.com/free-icon/interfaces_2621100?related_id=2621100&amp;origin=pack">https://www.flaticon.com/free-icon/interfaces_2621100?related_id=2621100&amp;origin=pack</a></p><p><strong>What is a Database?</strong></p><p>A database is a repository of structured information or data. A database is usually controlled by a <em>Database Management System</em> (DBMS). DBMS is a system that allows us to import, save, organize, manipulate, retrieve, and manage data from a database. DBMS saved tabular data format. You may have heard terms like RDBMS or <em>Relational Database Management System. RDBMS</em> is software that is specifically for relational databases. We can establish the relationship between multiple tables. Now you may wonder how to access the data and communicate with them.</p><p><strong>What is SQL?</strong></p><p>SQL stands for <em>Structured Query Language</em>. SQL is a standardized programming language used to communicate with data stored in RDBMS. For example, imagine you have an app that remembers all your friend’s birthdays. SQL is the most popular language you would use to talk to that app. It’s like:</p><blockquote><em>English:</em></blockquote><blockquote><em>“Hey, app. When is Hannah’s birthday?”</em></blockquote><blockquote><em>SQL:</em></blockquote><blockquote><em>SELECT * FROM birthdays WHERE person = ‘Hannah’</em></blockquote><p>People write an SQL query that is used for finding and displaying data. It is the most common type of SQL query that you’ll see. The next section is a quick-start guide for writing SQL queries. In this tutorial, I used <a href="https://www.postgresql.org/download/">PostgreSQL</a> to run the query. You can try the queries in the next section. Find the study case data for this hands-on tutorial in this <a href="https://drive.google.com/drive/folders/1A4xWHgBETrFE2xgqEZgVqpMRR3pfUmFf?usp=sharing"><strong>link</strong></a>. Are you ready? Here we go…</p><h3>Case Study:</h3><p>Buah Box Company is an online supermarket that provides fresh fruit needs for customers. Buah Box as an online supermarket makes it easier for consumers to buy high-quality fresh fruit. This company has several departments. Currently, Sales Department wants to know sales data, the HR Department wants to know employee data, and the Delivery Department wants to know transportation data. Data Department is asked to display the data according to the department’s request.</p><ul><li>A table often contains many duplicated values. What if we only want to know a list of the unique values in the table? Yes, we can use SELECT DISTINCT. This syntax is used to return only distinct (different) values. So, we can access sales data for products that are only sold from 1 — 10 January 2021 with SELECT DISTINCTandWHEREsyntax. Let’s give it a try.</li></ul><p>SELECT DISTINCT(product_name)</p><p>FROM sales</p><p>WHERE purchase_date BETWEEN ‘2021–01–01’ AND ‘2021–01–10’;</p><ul><li>If we only want to access data with some conditions, use IN and AND operations like this. For example, we want to know only ‘Mangga’ and ‘Apel’ sales in store 9.</li><li>SELECT product_name, store_city_id</li><li>FROM sales</li><li>WHERE product_name IN (‘Mangga’, ‘Apel’)</li><li>AND store_city_id = 9;</li><li>Then we want to show data when the minimum number of ‘Mangga’ sales is. Use WHEREto filter the <em>product_name </em>by only ‘Mangga’. Sort the data in ascending order with ORDER BY criteria ASC and LIMIT to see the least sales quantity.</li></ul><p>SELECT product_name,</p><p>purchase_date,</p><p>quantity</p><p>FROM sales</p><p>WHERE product_name = ‘Mangga’ ORDER BY quantity ASC</p><p>LIMIT 2;</p><ul><li>Show all salary data of employees whose first names contain the letter ‘Ba’. For this case, use LIKE to find a match pattern. &#39;%Ba%’ is used to find any values that have ‘Ba’ in any position. If you need to find values that start with ‘Ba’, use &#39;Ba%’ instead. or &#39;%ba’ to find values that end with ‘ba’.</li></ul><p>SELECT first_name, salary_2020,</p><p>salary_2021, salary_2022</p><p>FROM employees</p><p>WHERE first_name LIKE ‘%Ba%’;</p><ul><li>What if we want to calculate the average salary of employees per year and round it 2 digits after the comma? AVGfunction returns the average value of a numeric column. Then just type ROUND before AVG to make a round number, like this.</li></ul><p>SELECT ROUND (AVG (salary_2020),2) AS average_salary2020, ROUND (AVG (salary_2021),2) AS average_salary2021, ROUND (AVG (salary_2022),2) AS average_salary2022</p><p>FROM employees;</p><p>Hope you gained ideas on how to use SQL practically to perform analysis. Thanks to <a href="https://myskill.id/">MySkill</a>, I value the insights and guidance you provide in Bootcamp. For any further information, please do not hesitate to comment below.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7364a48cad6d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>