<?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 Ammar Shaikh on Medium]]></title>
        <description><![CDATA[Stories by Ammar Shaikh on Medium]]></description>
        <link>https://medium.com/@shaikhammar?source=rss-e7bb5fa536fe------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*vyCbj_eSupGkBVhrITLa5Q.png</url>
            <title>Stories by Ammar Shaikh on Medium</title>
            <link>https://medium.com/@shaikhammar?source=rss-e7bb5fa536fe------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 21:39:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shaikhammar/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[Moving to Texas, first Impression]]></title>
            <link>https://medium.com/@shaikhammar/moving-to-texas-first-impression-19809698d8d4?source=rss-e7bb5fa536fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/19809698d8d4</guid>
            <category><![CDATA[travel]]></category>
            <category><![CDATA[texas]]></category>
            <category><![CDATA[usa]]></category>
            <dc:creator><![CDATA[Ammar Shaikh]]></dc:creator>
            <pubDate>Tue, 13 Aug 2019 16:20:55 GMT</pubDate>
            <atom:updated>2019-08-13T16:20:55.844Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eYxvAeLLjjucAZvHd8_P6w.jpeg" /></figure><p>Finally, I have managed to get some time to write a blog about my first experience in the United States. I had earlier planned to write it as soon as my touchdown(1st August). Well, it really was a hectic week and I had to complete a lot of activities including setting up my new apartment. So, let&#39;s begin.</p><p>As a Mumbaikar (that’s what we call ourselves back in Mumbai), I am used to walking around lanes with huge complexes and highrises on either side. However, the first thing I saw as I landed at Houston airport was houses that barely went beyond the first level. I couldn’t even see one multi-floored building from the bird&#39;s eye view.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*x0QCuuk_XuMjvFy43OGSvA.jpeg" /></figure><p>The next thing obviously someone would notice is the heat. Having survived the summers in India, when I was told that it&#39;s hot in here, I thought it would be nothing as I have spent my childhood playing all-day in Mumbai’s hot and humid summers. This opinion was totally blown away by the hot air as I soon as I stepped outside the airport.</p><p>One thing that I expected would take a lot of time was the customs and security checking procedures. But to my surprise, the entire process took barely 45 minutes after I landed. This might be due to the fact that I booked my flight dates before many other students.</p><p>Next up, I will list 2 things I loved and 2 things that surprised me so far.</p><ol><li>People</li></ol><p>Right from the airport till this day whenever I go for a walk, I have always been greeted with a smile even by total strangers.<strong> </strong>I remember the first day me and my roommate went to Walmart to buy electronics and on our way, we were having a conversation with our lyft driver about things we wanted for our home and we don’t know where to buy it from and she literally stopped the ride and took us to 3 places for free just to look out stuff and help us with buying accessories. Isn’t that awesome?</p><p>Also, during the weekend we were in an Mc Donalds far from our place and the buses were not working so we had to walk all the way back home. But, we were lucky we met a retired professor from our university who approached us and not only dropped us home but also helped us buy groceries and invited for dinner the next day. Couldn’t get a better welcome to the USA then that right?</p><p>2. Culture</p><p>The culture here is unique. I remember I attended a session during this week and the speaker said ‘Everywhere in the world you go if you smile for no reason, people will think you are stupid but here in America we think it is kind to smile and greet people even if you don’t know them’. So smile :)</p><p>The student culture is amazing. Student associations like IGSA(Indian graduate student association) played a huge role throughout my entire transition of moving in as an International student. I remember reaching at 10 pm and the leasing office for our apartment closes at 6 pm. IGSA to our rescue who provide free accommodation to students.</p><p>Texas A&amp;M fact: You don’t need to know anyone to start a conversation, all you need to say is ‘Howdy’. Howdy(How do you do?) is the official greeting in Texas A&amp;M.</p><p>3) Transportation.</p><p>If you don’t have transportation everything here is far. Back in India I would find locations in Texas and check places to be 5 mins by car and 30 mins by walk and be surprised thinking something is wrong with the maps. But coming here you realize it&#39;s not. Going on campus is not a task since you have ‘aggie spirit’(Campus bus)that runs all around campus and some areas off-campus as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/1*1ZlOb0s_xJNmSuYNd8mTBA.jpeg" /></figure><p>The funny part about taking the bus was. Every time you have to get down at a stop you need to pull a string and request a stop. Coming from India where buses will stop at every stop no matter what I thought things would be the same. But, only after missing my stops for 5 days did I understand the string the theory.</p><p>Apart from the campus bus, options like Uber / Lyft are available but it hits you initially because you really aren’t earning to spend on them. There is this cool thing called Veoride which lets you rent bicycles and reach from one place to another. If the weather isn’t too hot Veoride is a great option.</p><p>4) Supermarkets and giveaways</p><p>For me, buying groceries, mattress, electronics, furniture are 4 different places but here its just one ‘Walmart’. Just like there are malls in India Walmart is the mall here. A place with a huge number of options. Like buying a daily item like eggs there were 7 choices! Shopping here is not difficult, shopping here is confusing! It takes you some time to find the items in the first place and then the options. Ahh! That really is some task.</p><p>Giveaways were something completely new for me. Basically, giveaways are events wherein students can come in and get things like furniture, home accessories, kitchenware for free. I mean you get a bed, recliners, study table, bike, lamps all for free. Not just that, all you have to do is just select the items you wish to have and it is delivered, Again for free!!</p><p>To sum up, my first impression has been amazing. Especially when you come to a new culture with new people and see how they appreciate and welcome you with a smile is something which makes it feel like home.</p><p>Thank you for your time! :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19809698d8d4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Analyzing World Cup History!]]></title>
            <link>https://medium.com/@shaikhammar/analyzing-world-cup-history-25c963ef6b18?source=rss-e7bb5fa536fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/25c963ef6b18</guid>
            <category><![CDATA[cricket]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[Ammar Shaikh]]></dc:creator>
            <pubDate>Mon, 15 Apr 2019 12:25:07 GMT</pubDate>
            <atom:updated>2019-04-15T12:25:07.760Z</atom:updated>
            <content:encoded><![CDATA[<p>Cricket is the second most popular sport in the world, it has an estimated fan base of 2.5 billion. One of the main events happening in Cricket is the World Cup, once in every 4 years. It is the biggest trophy to have as all the top quality teams participate and fight for the title.</p><p>The first world cup happened in 1975 and its been happening since then every 4 years. If your numbers are strong you might have realized that this year is going to be the next World Cup. I have been playing and the following cricket since my childhood days and so given how much the world cup is looked up to and my recent learning from analytics, I decided to analyze the world cup history.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*AX8h-K9qZIyrybuWf1UChg.jpeg" /></figure><p>Though the world cup started in 1975 I have done my analysis from 1991 as the first few world cups were not played in the same format as the current ones.</p><p>So let us start!</p><p>Below were my top 5 analysis from world cup history.</p><ol><li>How dominant were the winning teams</li></ol><p>World cup is initially played in a group stage and then later converted to knock out format. Let us see how was the performance of the winning team all throughout the tournament in each worldcup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f74ZgN_qA9Rw_V_gvmFnjA.png" /></figure><p>Interesting! isn’t it?, all the winning team have had a dominant performance throughout the tournament with Australia having a 100% win record in two world cups. As you can see that the most a winning team has lost are 3 matches, this shows that winning matches right from the start and keeping that consistency is very important in a tournament like a world cup.</p><p>2) How important is winning a toss?</p><p>Winning or losing a match surely depends upon the team performance but unlike other games like football or tennis where toss doesn’t make much of a difference, in cricket, it sure does like a lot of time the conditions of the pitch changes and also factors like dew or rain come in depending upon the weather conditions. Winning the toss gives you an upper hand as you decide to play in better conditions and the game goes as per your teams planning. But did that actually work in the world cup? How many teams who won the toss actually ended up winning the match? Let us see.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0RILVMCc5DtcU_lQhlod2Q.png" /></figure><p>Except in the year 1991, you can see that more than 50% of teams who have lost the toss have ended up winning it, One of the main reason is that world cup is highly competitive and there are many factors that contribute to a teams win of which toss is just one of the factor.</p><p>3) To set a target or to a chase one?</p><p>While to bat first or to field first is dependent on a pitch and also how the team’s performance has been throughout the series, let us see if batting first or second made a difference in the world cup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Eg7EUTdnJOGfi2idQD8ZA.png" /></figure><p>Well, you might see there is not much of a clear picture here as to batting first or field first can help a team. But when you consider individual year for analysis you sure can get some information. Like the 2003 world cup was hosted by South Africa, Zimbabwe, and Kenya wherein the pitch were more bowlers friendly during the second half and hence team batting first ended up getting an advantage, similar case for 2015 world cup hosted by Australia and New Zealand wherein the pitch is hard and the bowl comes on the bat easily so the teams tried to opt for field first as with the time it would have got easier to bat on these pitches.</p><p>4) Who is a bigger deal for winning, a Batsman, Bowler or an All rounder?</p><p>In a match even though teams would like to get a balance of batsman, bowler and All rounder in order to get a perfect blend. In every match, there is a key player who plays an important role in winning the match. I tried to analyze in all the matches of the world cup which role among batsman, bowler, or all-rounder had a bigger role to play.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rpZVhrgNBPT-rGZW4HMWHA.png" /><figcaption>Man of the matches won by Batsman, Bowler, All rounder till 2015 world up</figcaption></figure><p>Clearly, the Batsman seem to be a game changer for a match. The reason for this is because if a team is batting first batsman have a responsibility of getting a good start and setting a reasonable target and if chasing they have to do the same thing with an added pressure of a particular target to reach. When it comes to bowlers, unlike batsman they have limited overs to perform i.e 10. Even if they bowl well their performance is also dependent upon the other 10 fielders who should not to miss any catch or save a run or a four to back their bowlers. When it comes to all-rounder though their numbers might seem to be less for you but their job is the most crucial they have to come late down the line and finish the game by hitting big shot and even maintain partnership with tail end batsman, also while bowling they have to perform as good as the main bowlers in order to back them and prove to be a perfect blend for the team. Hence even though the numbers don’t go in favor of Bowler and All-rounder their responsibility in itself is complex and requires a team effort for their better performance.</p><p>5) Which teams have been popular ones?</p><p>Since the world cup is like the main event, getting through semi-finals is also a bigger deal, I tried to find out which were the popular teams and how many times did they make it to the end game.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HbE1TOj2-qha0YH0ugaUtw.png" /></figure><p>Clearly, Australia seems to be the most consistent performer, every time they have reached semis they have won and gone up to win the finals 3 out of the 5 times. On the other hand, South Africa seems to be having a curse, they have reached semi-finals 4 times and have lost the semis all the time. The next time you hear someone calling South Africa as chokers, now you would know why!</p><p>This brings us to the end of this blog, the entire analysis was performed by scraping data from ESPN Cricinfo and analysis was done in python.</p><p>If you need to know behind the scenes for this blog, you can check out the code <a href="https://github.com/ammarshaikh123"><strong>here</strong></a>. Thank you for your time! :)</p><p>Who am I?</p><p>I am an aspiring Data Scientist and I am actively working on projects related to Data Manipulation and Machine Learning and I am open to collaborate and work as well.</p><p>You can check out my blogs <a href="https://medium.com/@shaikhammar.7"><strong>here</strong></a><strong>.</strong></p><p>You can check out my GitHub Projects <a href="https://github.com/ammarshaikh123"><strong>here</strong></a>.</p><p>You can connect with me on my LinkedIn Profile <a href="https://www.linkedin.com/in/ammar-shaikh-4264bb76/"><strong>here</strong></a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=25c963ef6b18" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Suicide Analytics]]></title>
            <link>https://medium.com/@shaikhammar/suicide-analytics-c12f979fc078?source=rss-e7bb5fa536fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/c12f979fc078</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[suicide]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[visualization]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Ammar Shaikh]]></dc:creator>
            <pubDate>Sat, 06 Apr 2019 18:29:46 GMT</pubDate>
            <atom:updated>2019-04-06T18:29:46.091Z</atom:updated>
            <content:encoded><![CDATA[<p>One of the causes of death that has taken a plunge in the recent decades is suicide, according to BBC reports there has been an increase of 30% in suicide rates in the past 17 years. When it comes to questioning when did suicide began to increase is a question of another day and another topic. Today we will analyze factors that might show us important information regarding the reasons behind committing suicide. For this, I have taken data from the government of India’s website and have analyzed it based on 3 factors basically.</p><ol><li>Education.</li><li>Profession.</li><li>Social Status.</li></ol><p>First Let us see the top 10 states in terms of suicide rates and also compare it with results from the previous year.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9tPwBPDOh5YTl6b0dtYUNQ.png" /><figcaption>Comparison of top10 states in terms of suicide rate for 2013 &amp; 2014</figcaption></figure><p>As we can see Maharashtra tops the table in both the years along with Tamil Nadu, while West Bengal, Karnataka, and Telangana showed an Increase in their suicide rates as compared to the previous year, Uttar Pradesh managed to get off the list. Now that we know which were the top states in terms of suicide rate, I further analyzed to find how many Male and Female suicides occurred in each of these states.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N0F2EIaFuD8FcNoDf05REA.png" /></figure><p>As we can see that sex ratio for male and female is around 2:1 for almost all the states. We can see that although Maharashtra recorded the highest suicide rate, West Bengal had the highest suicide rate among women.</p><ol><li><strong>Education</strong></li></ol><p>One thing to note from the previous case was West Bengal, Maharashtra, Tamil Nadu are states with higher literacy than States like Andhra Pradesh and Chattisgarh including even in terms of female literacy rates. This makes us question can education/literacy be a factor when it comes to a person committing suicide or not? Let’s see what I could find out from my analysis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_D-dNBOxj9058fm0ssqMQQ.png" /><figcaption>Education wise suicide rates</figcaption></figure><p>Well, the graph might give you some mixed feelings but let me put a point of view in it. We can see that the suicide rate for people with education reduces gradually as the level of education increases. Especially there is a huge difference between students in class 10th and people with a Diploma or a certificate. Maybe because by the time you receive a diploma or a certificate you start earning and that reduces your financial and educational stress as well. And w.r.t to no education category, it might include people from various categories like labors or local businessmen who are in debt or any other financial/mental stress so we cannot state a definite reason for them.</p><p>2. <strong>Profession</strong>.</p><p>Now that we have seen how the suicide rates are in terms of state, sex and education, let us dig deeper and find what kind of jobs had the most occurrence of suicide. As per the data which was used for the analysis there were quite a few subcategories and subtotals mentioned, I performed some data manipulation and concluded the below top 7 categories in terms of suicide rates. You can check the code in the GitHub link at the end of the blog.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NzGwiTj0J6lRa13iXxUUvA.png" /><figcaption>The suicide rate in terms of professional status</figcaption></figure><p>Something important that I noticed there was, the top 3 categories are the minimum paid jobs and a significant amount of people in the category of daily wage earners and agriculture also come under people with no education.</p><p>While most of our news is highlighted by students committing suicide and exam stress, How much have we stressed on the factors for Housewives? Something which we should be really concerned about from the above information.</p><p>3. <strong>Social Status.</strong></p><p>We might have always felt that being a housewife would not be as stressful as a worker in a blue-collar job, but so far that clearly isn&#39;t the true story. I further tried to analyze based on people’s social status because we have considered professional aspects in terms analysis so it might as well be good to include a personal factor as well. Rather than considering total people in each category, I tried to make an analysis based on gender as that gave a much clear picture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/899/1*egkr9kJpOIvuyTqRUac3RQ.png" /></figure><p>As we can see while for all the categories the gender ration is almost 1:1, when it comes to married category there is such a huge difference, as much 75k suicide cases where women were married, we can also refer from the previous section that there were 60k Housewife we can say that the remaining 15k were working-class women. Can it be concluded that working women have a much better life than housewives?. Also when we compare total people married vs unmarried from the above graph, we see such a huge difference. Although there might not be a definite and sure shot reason to provide here but we can often see that people do have to get a shift in their lifestyle once they get married, especially for women, moving out and living in a completely new environment with completely new people and adding to that the social obligations that come with marriage, that is what might be one of the few reasons leading to such a big difference.</p><p>To conclude we can say that educational and economic status might be one of the most important factors when it comes to suicide rates. We might hear about students from top colleges, rich businessman and actors committing suicide. Well, unfortunately, their importance might sure be high for the media but there are other sections who have much higher suicide rates as per our analysis and they sure need some attention. Can improving educational and economic status reduce the suicide rates? Only time can answer that.</p><p>I hope this article was worth your time, please let me know your opinions.</p><p>The whole analysis was done by using government data for suicide reports. If you would like to know the behind the scenes for this blog you can check out the code in my below GitHub profile along with other projects as well.</p><p>Who am I?</p><p>I am an aspiring Data Scientist and I am actively working on projects related to Data Manipulation and Machine Learning and I am open to collaborate and work as well.</p><p>You can check out my blogs <a href="https://medium.com/@shaikhammar.7"><strong>here</strong></a><strong>.</strong></p><p>You can check out my Github Projects <a href="https://github.com/ammarshaikh123"><strong>here</strong></a>.</p><p>You can connect with me on my LinkedIn Profile <a href="https://www.linkedin.com/in/ammar-shaikh-4264bb76/"><strong>here</strong></a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c12f979fc078" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 thing you should know to master SQL for Data Science]]></title>
            <link>https://medium.com/@shaikhammar/5-thing-you-should-know-to-master-sql-for-data-science-911933056a2d?source=rss-e7bb5fa536fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/911933056a2d</guid>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Ammar Shaikh]]></dc:creator>
            <pubDate>Fri, 22 Mar 2019 18:04:21 GMT</pubDate>
            <atom:updated>2019-03-22T18:04:21.804Z</atom:updated>
            <content:encoded><![CDATA[<p>We know that Data Science is the next big thing in the industry and we have a lot of tools and languages like R, Python, Tableau, Power BI used in some or the other way to bring about some wonderful insight about the Data. But using any of the mentioned tool or language has one thing in common i.e Extracting data from the database. Most of the time when companies use data to gather meaningful insights they use it from the past records stored in their database. For example, a company who has its presence in 6 countries wants to generate a sales report to understand which country provides a maximum profit. To extract any valuable information the company will require the data to be first extracted from the database and then perform any operations in any of the above-mentioned applications. And to perform this extraction we use SQL (Structured Query Language).</p><p>SQL is not just used to type in a query and extract the data. You can manipulate, perform various operations like add columns, sort the data, add conditions. But the question that would come here is, we could perform all these operations on any applications like R, Python etc. so why do we have to use SQL. The answer is yes we can surely do that but I want you to imagine it in a corporate perspective, continuing with our same example of sales report we might have a dataset of each country with millions of row so that when we extract this data we will feed millions of rows in our next step which will automatically increase our processing time, instead by simply adding a few conditions like generating the report for only last 5 years for analysis, we can easily reduce the number of unnecessary rows and voila! reducing the time required to process the data in further steps.</p><p>Now that you know the importance of SQL with respect to Data Science workflow. Let us look at the top 5 things in SQL you should know to make its best use.</p><ol><li>Grouping data and computing aggregates.</li><li>Using Subqueries.</li><li>Using the case clause.</li><li>Using Co-related subqueries.</li><li>Using Joins.</li></ol><p>Before we begin, if you are completely new to SQL and are not aware of its syntax you can go <a href="https://www.w3schools.com/sql/"><strong>here </strong></a>and familiarize yourself so that you can understand the code ahead clearly.</p><p>Let’s Start!</p><h3><strong>1)Grouping data and computing aggregates.</strong></h3><p>Consider an example of a company which wants to analyze the distribution of its employee salaries in different departments, here there might be multiple employees in a single department so here we use the ‘Group by’ statement and group the dataset as per departments giving us a clear and better picture to analyze the salary.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/412/1*H3CUDIPccRZQ0UCwSl4-ZA.png" /><figcaption>Sample Code and Output for a group by function.</figcaption></figure><h3>2) Using Subqueries.</h3><p>A subquery is exactly what it sounds like. It’s actually a query that exists within a query. So a query within a query or a select statement within a select statement can be called a subquery. Some important points to know about subqueries is :</p><ul><li>The subquery can be placed in a number of places in SQL clauses like WHERE clause, HAVING clause, FROM clause.</li><li>The outer query is called as the <strong>main query</strong> and the inner query is called <strong>a subquery</strong>.</li><li>The subquery executes first, and its output is used to complete the query condition for the main or outer query.</li><li>The subquery must be enclosed in parentheses.</li><li>If a subquery is used in the FROM clause, it needs to have an alias</li><li>ORDER BY command <strong>cannot</strong> be used in a Subquery.</li></ul><p>Sample Code :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7RuzPfzLE0Ftbzju_-_jNw.png" /><figcaption><strong>This query helps us select all those employees who are working in a department having the division as Electronics</strong></figcaption></figure><h3>3) Using the case clause.</h3><p>Case clause works based on cases/conditions provided in the query. If a case is true it will return otherwise it will move on to the next case. One of the most used applications of case clause is to transpose the data i.e to convert rows into columns. Let&#39;s take an example.</p><p>In the below example we count total employees working in each department.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/1*15eq-OeRq0hxRmD60E5S0g.png" /></figure><p>But what if we wanted to see the same result in below manner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/891/1*23XaqcDWQOQsUrhJ_EtO_w.png" /></figure><p>That’s where the CASE clause makes the difference, just write the below query and Voila!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yes5zxqxUAhyD1NJ4eAERQ.png" /><figcaption>Using the CASE clause to Transpose the Data.</figcaption></figure><h3>4) Using Co-related subqueries.</h3><p>Now that we have been introduced to the group by clause and a subquery, using a co-related subquery will be fairly comfortable to understand. Basically, both a subquery and co-related subqueries have query within a query, so how do we make it out that a query is a correlated subquery and what does that mean.</p><p>Well, a correlated subquery basically means that the subquery portion is correlated with the outer query. Let me put it another way. A correlated subquery is a query nested inside another query that uses values from the outer query. Let us look at an example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*VwyMFFrcrBDi-aBSxTdp8g.png" /></figure><p>As we can see in the example the subquery is using the ‘employee’ table from outer query to make a comparison on a column ‘region_id’ and this is what co-related subqueries do.</p><h3>5) Using Joins.</h3><p>Joins are one of the most widely used and important function when it comes to Data analysis, as we might require data to be fetched from multiple tables in order to gather consolidated information and then perform the analysis.</p><p>Joins are of multiple types and you can read about their syntax and types <a href="https://data36.com/sql-join-data-analysis-tutorial-ep5/"><strong>here</strong></a><strong>.</strong></p><p>I am going to show you how joins make our work easier. As we have already discussed that we can use subquery and co-related subqueries to use query within a query and obtain useful information. However, it does make our query look more complicated, that’s where joins come in and make our work easier.</p><p>Consider the above example where we wrote a co-related subquery</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*VwyMFFrcrBDi-aBSxTdp8g.png" /></figure><p>We can simplify this same code by using Joins as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1019/1*AKthmOE1cMTo2f9J7pQP9Q.png" /><figcaption>Using Joins</figcaption></figure><p>Although this might not look much of difference but consider working on a project where you have to analyze 1000 lines of code, which of the above two options would you prefer ? or I can ask which of the above options will you prefer to use while writing a query so that when you come back in future it would be easier to understand what your query is trying to do?</p><p>Using a subquery would be helpful when you have to use conditions in a clause like SELECT, WHERE, HAVING as Joins can only be used in the FROM clause!</p><p>These were the 5 must know thing for using SQL in data science. I hope I could help you have a better understanding after reading this blog. Thank you!</p><p>References:-</p><ol><li><a href="https://www.geeksforgeeks.org/sql-case-statement/">https://www.geeksforgeeks.org/sql-case-statement/</a></li><li><a href="https://www.essentialsql.com/what-is-the-difference-between-a-join-and-subquery/">https://www.essentialsql.com/what-is-the-difference-between-a-join-and-subquery/</a></li><li><a href="https://www.udemy.com/master-sql-for-data-science/">https://www.udemy.com/master-sql-for-data-science/</a></li></ol><p>Who am I?</p><p>I am an aspiring Data Scientist and I am open to collaborate and work on projects related to Data Manipulation and Machine Learning.</p><p>You can check out my blogs <a href="https://medium.com/@shaikhammar.7"><strong>here</strong></a><strong>.</strong></p><p>You can check out my Github Projects <a href="https://github.com/ammarshaikh123"><strong>here</strong></a>.</p><p>You can connect with me on my LinkedIn Profile <a href="https://www.linkedin.com/in/ammar-shaikh-4264bb76/"><strong>here</strong></a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=911933056a2d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What’s missing?]]></title>
            <link>https://medium.com/@shaikhammar/whats-missing-c8bcc4c86281?source=rss-e7bb5fa536fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/c8bcc4c86281</guid>
            <category><![CDATA[data-preprocess]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[feature-engineering]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Ammar Shaikh]]></dc:creator>
            <pubDate>Fri, 15 Mar 2019 18:25:24 GMT</pubDate>
            <atom:updated>2019-03-15T18:25:24.456Z</atom:updated>
            <content:encoded><![CDATA[<p>Hey there! Today I will be discussing one of the most important topics when it comes to data preprocessing i.e Handling missing values.</p><p>Firstly why are even missing values present in the dataset? There is no single answer to this question.</p><ol><li>It may be that data is missing for a specific parameter because that parameter has been recently added and the past records were not maintained for it.</li><li>It might be that parameter is not applicable for a particular record, for example, if we have data set from a survey of the user using one of the three models of mobile(A, B or C) but the user is using a model D which is not in the options and hence the data is missing.</li><li>Uncertainty: It could be that the person who entered the data did not know the right value, or missed filling in.</li><li>No means to know the information: In one of the few data sets we will see in this post is about the iconic Titanic dataset. We will see that quite a few people who were present on the ship have their age values missing, this is because a lot of people did not survive the accident and hence their age could not be recorded as no one could find it.</li></ol><p>We can further classify the mechanisms by which missing fields are introduced in a dataset.</p><h3>Missing Data Mechanisms</h3><p>There are 3 mechanisms that lead to missing data, the first two involve missing data randomly, and the third one involves a relation between the missingness of data and other parameters.</p><h3>1) Missing data Completely At Random (MCAR)</h3><p>A variable is missing completely at random (MCAR) if the probability of being missing is the same for all the observations. When data is MCAR, there is absolutely no relationship between the data missing and any other values, observed or missing, within the dataset. In other words, if the data is MCAR removing those specific rows will not have any effect on the performance of your model in the later stage.</p><p>Let&#39;s take an example:-</p><p>Here we have the iconic Titanic data set</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iN1ysVYA6_gzb7xxLV25vA.png" /><figcaption>First few rows of the Titanic dataset</figcaption></figure><p>Let us see how many missing values does each column have</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/406/1*2EDopRfr6YpWRZVqlzeppQ.png" /><figcaption>Total missing values in each column containing around 1000 rows.</figcaption></figure><p>We can surely see that the column Cabin has a lot of missing values present</p><p>but for now, let us see the Embarked columns which contain only two missing values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w3ZruA3lrx10lPLKaGapHA.png" /><figcaption>Missing values from the Embarked Column</figcaption></figure><p>As we can see these two records are of female passengers who survived and hence their data could have been recorded after the accident. This shows that this data was missing completely at random and we can very well remove it from our dataset as it will not affect our performance.</p><h3>2) Missing data At Random (MAR)</h3><p>MAR occurs when data is missing from a particular column but the reason why it is missing is dependent on the other column. In other words, the probability an observed data is missing depends on the other information from the data set. For example, in the below example we can see that younger people are more likely to not disclose their IQ scores as compared to their seniors, this shows that there is a dependency of missing values in the column ‘IQ score’ on the column ‘Age’. However, we cannot conclude it directly that they are related but we can surely check out the relationship between the two parameters by checking out how <a href="http://benalexkeen.com/correlation-in-python/"><strong>correlated</strong></a><strong> </strong>they are.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/345/1*iLV09aEDadJnmw577fw6lg.png" /><figcaption>Example of MAR data</figcaption></figure><h3>3) Missing data Not At Random (MNAR)</h3><p>Just as we saw in the previous case that the missingness present in a particular column is dependent on another column from the dataset if the data missing is MNAR it will be dependent on another information which is not present in the dataset. A very common example will be of detecting fraudsters from loan applications. If the person is impersonating as someone else he/she will not upload the documents for identity verification, because they don’t have them, precisely because they are fraudsters. Therefore, there is a systematic relationship between the documents missing in the upload section and the loan application being detected as fraud.</p><p>To give you a clear picture lets take a look at the Titanic data set again. As we saw that the ‘Cabin’ column had a lot of missing values present in it, could the missing value be more for the people who did not survive? As they were not present after the accident to provide the information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/503/1*N-jxT4CYKs4sgbizRY4z_Q.png" /></figure><p>Over here we have grouped all the null values in cabin column under a new column ‘cabin_null’ and we can see that people who did not survive(indexed as 0)were more likely to have a missing value in the null column than the people who survived the accident(indexed as 1).</p><p>However, whether the data is missing not at random, we would need to get extremely familiar with the way data was collected. Analyzing datasets, can only point us in the right direction or help us build assumptions.</p><p>That was all about the missingness of data and its mechanism. I hope you got to have a better understanding after reading my blog.</p><p>References :</p><ol><li><a href="http://benalexkeen.com/correlation-in-python/">http://benalexkeen.com/correlation-in-python/</a></li><li><a href="https://www.iriseekhout.com/missing-data/missing-data-mechanisms/">https://www.iriseekhout.com/missing-data/missing-data-mechanisms/</a></li><li><a href="https://en.wikipedia.org/wiki/Missing_data">https://en.wikipedia.org/wiki/Missing_data</a></li></ol><p>I am an aspiring Data Scientist and open to collaborate and work on projects.</p><p>You can check out my Github Projects <a href="https://github.com/ammarshaikh123"><strong>here</strong></a>.</p><p>You can check out my LinkedIn Profile <a href="https://www.linkedin.com/in/ammar-shaikh-4264bb76/"><strong>here</strong></a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c8bcc4c86281" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>