<?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 Shubham Goyal on Medium]]></title>
        <description><![CDATA[Stories by Shubham Goyal on Medium]]></description>
        <link>https://medium.com/@goyal.shubh15?source=rss-6789e44c6d7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*WxfDbsNnAtAruiXZylp-6A.jpeg</url>
            <title>Stories by Shubham Goyal on Medium</title>
            <link>https://medium.com/@goyal.shubh15?source=rss-6789e44c6d7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 04:15:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@goyal.shubh15/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[Navigating a Challenging Job Market: Strategies for Success]]></title>
            <link>https://medium.com/@goyal.shubh15/navigating-a-challenging-job-market-strategies-for-success-500fc23e937f?source=rss-6789e44c6d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/500fc23e937f</guid>
            <category><![CDATA[careers]]></category>
            <category><![CDATA[preparation]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[jobs]]></category>
            <dc:creator><![CDATA[Shubham Goyal]]></dc:creator>
            <pubDate>Sun, 12 Jan 2025 20:40:40 GMT</pubDate>
            <atom:updated>2025-01-12T20:41:40.333Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>This article will help you strategize, and provide resources to prepare for data science interviews. It is written with an assumption you have relevant experience/project work in your field of interest.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9r-7yXu0d7REc_Ae" /><figcaption>Photo by <a href="https://unsplash.com/@asoggetti?utm_source=medium&amp;utm_medium=referral">Alessio Soggetti</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>It’s a well-known fact that the job market is tough out there. The competition is fierce, and the opportunities are limited. While there’s only so much you can do to stand out, it’s crucial to do it as effectively as possible.</p><p>A basic ladder to climb while searching for jobs —</p><ol><li>Representation (Resume + Portfolio)</li><li>Strategy</li><li>Search</li><li>Preparation — (Tips, best practices)</li><li>Negotiation</li></ol><h3>1) Representation (Resume + Portfolio)</h3><p>When starting your job search, you must first understand how to represent yourself; in most scenarios, your resume is your primary tool. You should invest most of your time crafting a resume with well-thought-out content that aligns with job expectations. Terms like spearheading, innovating,cross-functional collaboration, mentoring, documentation, etc serve their purpose well.</p><p>Some essential resources to get started on developing your resume are publicly available platforms like —</p><ul><li><strong>Overleaf</strong> (<a href="https://www.overleaf.com/">https://www.overleaf.com/</a>) — For LaTex format</li><li><strong>OpenReusme</strong>(<a href="https://www.open-resume.com/">https://www.open-resume.com/</a>) — To check whether your resume is parsable through an automated system, you can also create a resume here.</li></ul><p>Some other websites score your resume based on certain hard-coded rules like quantifying the impact in numbers, common word usage, etc that can help you identify basic stuff too. Some examples —</p><ul><li><strong>Rezi AI</strong> (<a href="https://www.rezi.ai/">https://www.rezi.ai/</a>)</li><li><strong>ResumeWorded</strong> (<a href="https://resumeworded.com/score.php">https://resumeworded.com/score.php</a>)</li></ul><p>Another essential component of representation is a <strong>Portfolio</strong>, generally an online website. Many might think that it is an add-on and might not be relevant but I assure you that doing basic add-ons is what makes you stand apart because many others would not be doing it. There are ample resources to create a portfolio by just replacing content in an already-built template and hosting it on GitHub pages for free. Some resources —</p><ul><li><strong>Matt Chapman</strong> (<a href="https://medium.com/@mattchapmanmsc">https://medium.com/@mattchapmanmsc</a>) has written some amazing articles on this, one that could help can be found <a href="https://medium.com/towards-data-science/the-portfolio-that-got-me-a-data-scientist-job-513cc821bfe4?source=user_profile---------40----------------------------">here</a>.</li></ul><h3>2) Strategy</h3><p>The second step is to strategize your approach to job search. It should not be random, or untargeted, but rather carefully thought through. I felt like finding a job was a full-time job, so I approached it that way too. It is essential to understand your prior experience and to whom that might be relevant. If you plan to change your role or industry, you have to showcase why someone should give you a break in that new thing (which is always hard, but not impossible).</p><p>Some things you ideally should think about before starting are —</p><blockquote><strong>Target Industry &gt; Target Companies &gt; Target Role &gt; Preparation</strong></blockquote><p>It is also essential to plan how you should be preparing for the interviews, along with knowing when you should be applying vs preparing. It cannot happen that you’re just preparing and not applying, if you’re not getting callbacks then your focus should be on applying more, and if otherwise then preparation should be given more focus.</p><ul><li><strong>Jeff Li</strong> in this <a href="https://youtu.be/Pkrf8sGe_TQ?si=HmlT7D8bYp0OCWYs">interview</a> gives great advice on how he strategized his approach to get multiple offers in the toughest job market. (Would highly recommend watching Jeff’s mock interview videos on the Ytb channel <a href="https://www.youtube.com/@iqjayfeng/videos">InterviewQuery</a> as well)</li></ul><h3>3) Search</h3><p>Often, candidates are unaware of many existing companies unless they’re well-known names like FAANG, or their friends/acquaintances work there. So looking for companies maybe on LinkedIn/Google and creating a list becomes essential so that the search is comprehensive enough. Another way to find new companies is to look for ex-colleagues new/prior companies on LinkedIn, or current workplace of alumni from your alma mater. Some resources —</p><ul><li>Linkedin Jobs + Linkedin Posts (with keywords like &lt;role&gt;)</li><li>Glassdoor</li><li><a href="https://wellfound.com/discover/startups">Wellfound</a> — Discover Page for Startups</li><li>Google search — Trick (site: greenhouse.io &lt;role&gt; &lt;location&gt;) and in tools change the recency to a week or 24 hours</li></ul><p>Ideally, it is recommended to take referrals, but IMHO referrals or a cold application would only work if your resume has relevant experience to catch the recruiter’s eye. So it is good to have a referral but not a necessity, I’d suggest not fretting about it too much. Also, LinkedIn should be sufficient enough for you to find the latest jobs, as it is the most prominent job board out there. So use it religiously.</p><h3>4) Preparation</h3><p>A good strategy, which worked well for me, is to start preparation slowly and ramp up as interviews begin to be scheduled. The preparation must be comprehensive and could have a wide scope depending on what role one applies to. For eg. when I was interviewing for a Data scientist/ Machine learning Engineer role my preparation involved —</p><ul><li>Leetcode Questions — Python Programming</li><li>SQL — Medium/Hard problems</li><li>Machine learning/Deep learning theory</li><li>Probability + Statistics Theory</li><li>Experimentation — A/B test &amp; Statistical Tests</li><li>Puzzles/Brain Teasers</li><li>Case Study Questions — Guesstimates, Market Entry, Profitability</li><li>End-to-End ML Model Building/ML System Design</li><li>Programming Basic ML Algorithms from Scratch</li></ul><p>As you might think this is a huge list, and honestly not all interviews required everything but it was in bits and pieces. Some would require a couple of topics and others would require the remaining, I hope you get what I mean. Having a comprehensive preparation enables you to be prepared for unseen questions and allows you to improvise at that instant.</p><p>Now coming to the crux, the resources to prepare —</p><ul><li>Competitive programming in Python — <a href="https://leetcode.com/">Leetcode</a>, <a href="https://www.youtube.com/@NeetCode">NeetCode</a> — For Leetcode solutions (Do the blind 75 <a href="https://www.youtube.com/playlist?list=PLot-Xpze53ldVwtstag2TL4HQhAnC8ATf">Playlist</a>)</li><li>SQL Programming — <a href="https://platform.stratascratch.com/coding?code_type=3">Stratascratch</a>, <a href="https://datalemur.com/questions">Datalemur</a>, <a href="https://www.youtube.com/@tryexponent">Exponent</a>** mock interviews, <a href="https://www.interviewquery.com/dashboard/my-plan">Interview Query</a> (Also their YouTube <a href="https://www.youtube.com/@iqjayfeng">channel</a>)</li><li>Case-study questions — <a href="https://www.youtube.com/@caseinterviewscracked6984/videos">Case Interviews Cracked</a>, <a href="https://www.youtube.com/@iqjayfeng">Interview Query</a>, <a href="https://www.youtube.com/@tryexponent">Exponent</a>, <a href="https://www.youtube.com/@DataInterview">DataInterview</a></li><li>Experimentation — <a href="https://www.youtube.com/@DataInterview">DataInterview</a>, <a href="https://www.youtube.com/@iqjayfeng">Interview Query</a>, <a href="https://www.youtube.com/@tryexponent">Exponent</a></li><li>Puzzles — <a href="https://www.geeksforgeeks.org/">GeeksforGeeks</a></li><li>Statistics + ML— <a href="https://www.youtube.com/@statquest">StatQuest</a>, <a href="https://www.youtube.com/@3blue1brown">3blue1brown</a></li><li>Python + ML theory questions — <a href="https://learn.365datascience.com/exams/">365 Data Science</a></li><li>For other types, either Google Search or ChatGPT/Perplexity works best</li><li>Some Notebooks I created — <a href="https://colab.research.google.com/drive/1zf0HuHEasZOsWUaqtMezHCUxZj-rRKUC?usp=sharing">ML Interview Prep</a>, <a href="https://colab.research.google.com/drive/1i8oExzJ02r1SNGwQTQmHR0uW5HNa7AtJ?usp=sharing">Python Programming</a></li></ul><h3>5) Offer + Negotiation</h3><p>Getting the offer of your liking, and being fairly compensated for it is also an essential component in the job search. Numerous videos would say different things, but Exponent did a great job creating this <a href="https://youtu.be/fyn0CKPuPlA?si=ntFwBHnmudK4921N">video </a>with the Level.fyi’s CEO which comprehensively covers the different stages of salary negotiations one comes across.</p><p>Ultimately, accepting an offer depends on numerous factors, including an individual’s risk appetite, which plays a significant role. It may happen that a person with a low-risk appetite would take the first option that comes to them irrespective of the pay or quality of work, but essentially I would recommend planning things well and taking time to think them through. Getting a job is a matter of time if you’re confident in yourself. If you know that given an opportunity you’ll be able to perform, then taking time, having patience, and persisting become important to achieve the success you deserve.</p><p>Lastly, there are many resources to study and practice data science/ Machine learning. So feel free to add, and use others than the ones listed, some more I’m aware of —</p><ul><li><a href="https://arxiv.org/">ArXiv</a>, <a href="https://towardsdatascience.com/">TowardsDataScience </a>— For the latest research</li><li><a href="https://www.kaggle.com/">Kaggle</a> — Best for practicing hands-on Data science problems</li><li>Books —<a href="https://www.google.com/search?q=elements+of+statistical+learning&amp;oq=elements+of+statis&amp;sourceid=chrome&amp;ie=UTF-8"> Elements of statistical learning</a>, <a href="https://www.amazon.com/Doing-Bayesian-Data-Analysis-Tutorial/dp/0124058884">Doing Bayesian Data Analysis</a></li><li>Jeremy Howard’s Youtube <a href="https://www.youtube.com/@howardjeremyp">Channel</a> — Fast.ai course for Practical ML</li><li>Corey Schafer’s Youtube <a href="https://www.youtube.com/@coreyms">Channel</a> — for Programming</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=500fc23e937f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A/B Test — Understanding causal relationships in experiments]]></title>
            <link>https://medium.com/aiskunks/a-b-test-understanding-causal-relationships-in-experiments-2a7a0661b276?source=rss-6789e44c6d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/2a7a0661b276</guid>
            <category><![CDATA[product-analytics]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[marketing]]></category>
            <category><![CDATA[a-b-testing]]></category>
            <category><![CDATA[causal-inference]]></category>
            <dc:creator><![CDATA[Shubham Goyal]]></dc:creator>
            <pubDate>Thu, 27 Apr 2023 17:22:31 GMT</pubDate>
            <atom:updated>2023-04-28T20:55:46.051Z</atom:updated>
            <content:encoded><![CDATA[<h3>A/B Test — Understanding causal relationships in experiments</h3><p><em>In this article, we’ll be going through A/B tests in-depth to understand implementation and how they can help understand causal relationships in experiments.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*anMiE3EhonCXUbkP" /><figcaption>Photo by <a href="https://unsplash.com/pt-br/@diesektion?utm_source=medium&amp;utm_medium=referral">Robert Anasch</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Table of Contents</h3><ol><li>Introduction</li><li>Setting up A/B test</li><li>Conducting A/B test</li><li>Practical application w/ Example</li><li>Conclusion</li><li>References</li></ol><h3>Introduction</h3><p>I remember the last time I conducted an A/B test at my job, I wasn’t fully aware of the nitty-gritty of how an A/B test needs to be conducted but had a basic construct in mind that there is some bifurcation between the test and control population and then we compare the performance using multiple metrics. The unaddressed question (which I presume is very important) at that time was if the difference in the metrics are significant enough to change the strategies in place. At that time we compared the metrics and tried to calculate additional metrics based on profit/loss to the company, but it lacked the statistical significance analysis which would have acted as proof to our derived analysis that was solely based on business logic.</p><p>In this article, we’ll go through in-depth how A/B tests are conducted and the statistical inference involved. As a data scientist, many times you would come across problems for which you don’t have much background knowledge, in such situations statistical tests come in handy to support your analysis and act as proof of concept.</p><h3>Setting up A/B test</h3><p>So what is an A/B test and what’s their importance? Say you’re working in a product team as an analyst and your manager hands you an analysis to differentiate user reaction to a new feature on the website. Essentially, you need to check if the new feature had an impact on user interaction and if it&#39;s beneficial to bring that change into production. In such a case, what comes first to your mind? I hope it is comparing some users with the old feature and some with the new feature and analyzing their behavior!</p><p>That’s it, that’s an A/B test for you! My job is done, Chao!</p><h3>Conducting A/B Test</h3><p>Just kidding, but on a high level, that’s what an A/B test is. We have two populations —</p><p>1) <strong>Test</strong> — population on which the new feature is tested<br>2) <strong>Control</strong> — a population that is restricted to an old feature</p><p>An important thing to note here is that we assume that only the feature that we are introducing affects the performance of that feature and is <strong>independent of any external interference</strong>. The experiment has to be conducted in a controlled environment, which basically means no interference from external factors.</p><p>Once we have the populations defined, we deploy the test to gather the user behavior on the change. Now, the timeframe of the test is upon our discretion and business logic, however, some standard time frames can be 3 months, 6 months, etc.</p><p>As we start getting the user behavior data our major goal to is develop a hypothesis if the change in feature affected the user behavior or not. If it did, was it significant enough or not? Which requires further testing of the hypothesis and drawing inferences based on the results.</p><h3>Practical Application w/ Example</h3><p><em>We’ll be using this data set available on </em><a href="https://www.kaggle.com/datasets/zhangluyuan/ab-testing?datasetId=33220&amp;sortBy=voteCount"><em>Kaggle</em></a><em> for our practical application.</em></p><h4>Defining the problem</h4><p>Suppose you’re working as an analyst at an e-commerce company and the product manager (PM) tells you that the current <strong>conversion rate</strong> (how many people buy the shampoo over how many people view the Web page) is about 13% on average throughout the year and that the team would be happy with an increase of 2%, meaning that the new UI design will be considered a success if it raises the conversion rate to 15%. So let’s dive into it</p><pre>#importing the data, it can be downloaded from the above provided link<br>df = pd.read_csv(&#39;ab_data.csv&#39;)<br>df.head()<br># To make sure all the control groupg are seeing the old page and viceversa<br>pd.crosstab(df[&#39;group&#39;], df[&#39;landing_page&#39;])</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/294/1*JpWUMFZ3tL3FrYgLXqBmsg.png" /><figcaption>Crosstab for Test/Control groups</figcaption></figure><p>There are 294,478 rows in the data frame, each representing a user session. Before we go ahead and sample the data to get our subset, we’ll make sure there are no users that have been sampled multiple times and do basic sanity checks on the data.</p><pre>session_counts = df[&#39;user_id&#39;].value_counts(ascending=False)<br>multi_users = session_counts[session_counts &gt; 1].count()<br><br>print(f&#39;There are {multi_users} users that appear multiple times in the dataset&#39;)<br><br>users_to_drop = session_counts[session_counts &gt; 1].index<br><br>df = df[~df[&#39;user_id&#39;].isin(users_to_drop)]<br>print(f&#39;The updated dataset now has {df.shape[0]} entries&#39;)</pre><h4>Formulating the Hypothesis</h4><p>First things first, we want to make sure we formulate a hypothesis at the start of our project. This will make sure our interpretation of the results is correct as well as rigorous.</p><p>Given we don’t know if the new design will perform better or worse (or the same?) as our current design, we’ll choose a <a href="https://en.wikipedia.org/wiki/One-_and_two-tailed_tests">two-tailed test</a> (assuming a 95% confidence level). To assess whether we have statistical evidence that the two pages’ conversion rates truly differ, we perform a hypothesis test:</p><p>- The <strong>null hypothesis </strong>that we want to test for is that the two pages’ conversion rates are equal</p><p>- The <strong>alternative</strong> is that they differ (one is higher than the other).</p><p>Or put in another way, the null hypothesis says that the factors page version and outcome are statistically i<em>ndependent</em> of each other. In words, this means knowing which page someone is sent to, tells you nothing about the chance that they will have a successful outcome. Now that we know what hypothesis test we’re interested in, we’ll have to derive the appropriate test statistic.</p><h4>Classical Frequentist Statistics</h4><p>In statistics, an <a href="https://en.wikipedia.org/wiki/Effect_size">effect size</a> is a number measuring the strength of the relationship between two variables in a population, or a sample-based estimate of that quantity.</p><p>Examples of effect sizes include the correlation between two variables, the mean difference, or the risk of a particular event happening.</p><p>We know that the current conversion rate is about 13% on average throughout the year and that the PM will be happy with 15%. So the effect size can be determined from these numbers. We need a <em>standard</em> way to convert it to a universal math factor.</p><pre>effect_size = sms.proportion_effectsize(0.13, 0.15)    # Calculating effect size based on our expected rates</pre><h4>Sample Size for Test</h4><p>Now, what’s the right sample size based on our significance level (alpha = 5%), effect size (above), and power (80%)?</p><p>We specify the three key components of power analysis:</p><ul><li>A decision rule of when to reject the null hypothesis. We reject the null when the p-value is less than 5%</li><li>Our tolerance for committing type 2 error (1 − 80% = 20%)</li><li>The detectable difference, i.e. the level of impact we want to be able to detect with our test</li></ul><p>Statistical <strong>power</strong> is the probability of rejecting the null hypothesis when it is false.</p><p>Hence for us to calculate the power, we need to define what <em>false</em> means to us in the context of the study. In other words, how much impact, i.e., the <em>difference between test and control</em>, do we need to observe in order to reject the null hypothesis and conclude that the action worked?</p><p>If we think that an event rate reduction of, say, 10−10% is enough to reject the null hypothesis, then we need a <strong><em>huge</em></strong> sample size to get a power of 80%!</p><p>That is because if the difference in event rates between the experimental group and the control group is such a small number, the null and alternative probability distributions will be nearly indistinguishable. Hence we will need to increase the sample size in order to move the alternative distribution to the right and gain power.</p><p>Conversely, if we only require a reduction of 2% in order to claim success, we can make do with a much smaller sample size.</p><pre>required_n = sms.NormalIndPower().solve_power(<br>    effect_size, <br>    power=0.8, <br>    alpha=0.05, <br>    ratio=1<br>    )                                      # Calculating sample size needed<br><br>required_n = ceil(required_n)            # Rounding up to next whole number                          <br>required_n<br>#gives a result of 4720</pre><p>We get a result of 4720 observations which means we need at least 4,720 observations for each group.</p><p>Having set the power parameter to 0.8 means that if there exists an actual difference in conversion rate between our designs, assuming the difference is the one we estimated (13% vs. 15%), we have about an 80% chance to detect it as statistically significant in our test with the calculated sample size.</p><p>Now that our data frame is nice and clean, we can proceed and sample 𝑛=4720 entries for each of the groups.</p><p>We can use the pandas DataFrame.sample() method to do this, which will perform Simple Random Sampling for us.</p><pre>control_sample = df[df[&#39;group&#39;] == &#39;control&#39;].sample(n=required_n, random_state=22)<br>treatment_sample = df[df[&#39;group&#39;] == &#39;treatment&#39;].sample(n=required_n, random_state=22)<br><br>ab_test = pd.concat([control_sample, treatment_sample], axis=0)<br>ab_test.reset_index(drop=True, inplace=True)<br>ab_test</pre><h4>Visualizing the results</h4><p>Judging by the stats below, it does look like our two designs performed very similarly, with our new design performing slightly better, approx. 12.3% vs. 12.6% conversion rate</p><pre>conversion_rates = ab_test.groupby(&#39;group&#39;)[&#39;converted&#39;]<br><br>std_p = lambda x: np.std(x, ddof=0)              # Std. deviation of the proportion<br>se_p = lambda x: stats.sem(x, ddof=0)            # Std. error of the proportion (std / sqrt(n))<br><br>conversion_rates = conversion_rates.agg([np.mean, std_p, se_p])<br>conversion_rates.columns = [&#39;conversion_rate&#39;, &#39;std_deviation&#39;, &#39;std_error&#39;]<br><br><br>conversion_rates.style.format(&#39;{:.3f}&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*tjhhCzpaqjOEsr8H2-cwFw.png" /><figcaption>Results of the A/B Test</figcaption></figure><p>We’ll also plot the results —</p><pre>plt.figure(figsize=(8,6))<br><br>sns.barplot(x=ab_test[&#39;group&#39;], y=ab_test[&#39;converted&#39;], ci=False)<br><br>plt.ylim(0, 0.17)<br>plt.title(&#39;Conversion rate by group&#39;, pad=20)<br>plt.xlabel(&#39;Group&#39;, labelpad=15)<br>plt.ylabel(&#39;Converted (proportion)&#39;, labelpad=15);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*e-_tAixjzHGpEsBkooGHiw.png" /><figcaption>Visualization of our A/B Test Results</figcaption></figure><p>The conversion rates for our groups are indeed very close. Also, note that the conversion rate of the control group is lower than what we would have expected given what we knew about our avg. conversion rate (12.3% vs. 13%). This goes to show that there is some variation in results when sampling from a population.</p><p>So… the treatment group’s value is higher. Is this difference actually <em>statistically significant</em>?</p><h4>Testing the Hypothesis</h4><p>The last step of our analysis is testing our hypothesis. Since we have a very large sample, we can use the normal (gaussian) approximation for calculating our p-value, i.e. we use the <a href="https://en.wikipedia.org/wiki/Z-test">z-test</a>.</p><p>If we had assumed a student-T statistic, we would perform a <a href="https://en.wikipedia.org/wiki/Student%27s_t-test">t-test</a>.</p><p>We use the statsmodels.stats.proportion module to get the p-value and confidence intervals:</p><pre>from statsmodels.stats.proportion import proportions_ztest, proportion_confint<br><br>control_results = ab_test[ab_test[&#39;group&#39;] == &#39;control&#39;][&#39;converted&#39;]<br>treatment_results = ab_test[ab_test[&#39;group&#39;] == &#39;treatment&#39;][&#39;converted&#39;]<br>n_con = control_results.count()<br>n_treat = treatment_results.count()<br>successes = [control_results.sum(), treatment_results.sum()]<br>nobs = [n_con, n_treat]<br><br>z_stat, pval = proportions_ztest(successes, nobs=nobs)<br>(lower_con, lower_treat), (upper_con, upper_treat) = proportion_confint(successes, nobs=nobs, alpha=0.05)<br><br>print(f&#39;z statistic: {z_stat:.2f}&#39;)<br>print(f&#39;p-value: {pval:.3f}&#39;)<br>print(f&#39;ci 95% for control group: [{lower_con:.3f}, {upper_con:.3f}]&#39;)<br>print(f&#39;ci 95% for treatment group: [{lower_treat:.3f}, {upper_treat:.3f}]&#39;)<br><br># z statistic: -0.34<br># p-value: 0.732<br># ci 95% for control group: [0.114, 0.133]<br># ci 95% for treatment group: [0.116, 0.135]</pre><p>Since our 𝑝−𝑣𝑎𝑙𝑢𝑒=0.732 is way above our α=0.05 threshold, <em>we cannot reject the Null hypothesis </em>𝐻ₒ, which means that our new design did not perform significantly different (let alone better) than our old one</p><p>Additionally, if we look at the confidence interval for the treatment group ([0.116, 0.135], or 11.6–13.5%) we notice that:</p><ul><li>It includes our baseline value of a 13% conversion rate</li><li>It does not include our target value of 15% (the 2% uplift we were aiming for)</li></ul><p>What this means is that it is more likely that the true conversion rate of the new design is similar to our baseline, rather than the 15% target we had hoped for. This is further proof that our new design is not likely to be an improvement on our old design, and that, unfortunately, we are back to the drawing board!</p><h3>Conclusion</h3><p>Hence, we conclude our learnings on A/B testing and practical application on a website UI data set.<br><em>The complete code in a colab notebook can be found </em><a href="https://colab.research.google.com/drive/19mWbcOGmvn5j70Gog1CsSLbeqfysFVSV?usp=sharing"><em>here</em></a><em>.</em></p><h3>Ideas for future work</h3><p>Comparative analysis b/w A/B tests and Multi-arm bandits based on Thompson sampling, as one approach is frequentist while the other is Bayesian. One important differentiator is the reduced amount of samples and trials in the Bayesian approach which makes it interesting, but we’ll go through this in detail in the coming article.</p><p><em>I hope you liked it and had some learnings, please show your support with a clap or feedback in the comments. If possible help me fund my medium membership by gifting one </em><a href="https://medium.com/gift-plans#giftMembership"><em>here</em></a>, <em>I would greatly appreciate the help.</em></p><h3>References</h3><p><a href="https://www.kaggle.com/code/yanadav/a-b-testing-new-version-of-a-site">A/B-testing new version of a site</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a7a0661b276" width="1" height="1" alt=""><hr><p><a href="https://medium.com/aiskunks/a-b-test-understanding-causal-relationships-in-experiments-2a7a0661b276">A/B Test — Understanding causal relationships in experiments</a> was originally published in <a href="https://medium.com/aiskunks">AI Skunks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Daily Climate Forecasting — Time Series Forecasting using LSTM, Recurrent Neural Nets]]></title>
            <link>https://medium.com/aiskunks/daily-climate-forecasting-time-series-forecasting-using-lstm-recurrent-neural-nets-bbe6f425c688?source=rss-6789e44c6d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/bbe6f425c688</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[lstm]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[climate-change]]></category>
            <category><![CDATA[time-series-forecasting]]></category>
            <dc:creator><![CDATA[Shubham Goyal]]></dc:creator>
            <pubDate>Sun, 16 Apr 2023 04:13:21 GMT</pubDate>
            <atom:updated>2023-04-16T22:26:40.486Z</atom:updated>
            <content:encoded><![CDATA[<h3>Daily Climate Forecasting — Time Series Forecasting using LSTM, Recurrent Neural Nets</h3><blockquote>In this article we’ll be going through in detail on implementation of deep learning model - LSTM,RNN for forecasting time series data of daily climate attributes. We’ll be briefly covering the architecture of LSTMs, but will majorly focus on application part of it</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fZh_rL4f6fWp2-xn" /><figcaption>Photo by <a href="https://unsplash.com/@loic?utm_source=medium&amp;utm_medium=referral">Djim Loic</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Table of Contents:</h3><ol><li>Introduction</li><li>Background</li><li>Data Preprocessing</li><li>LSTM Model Building</li><li>Model Training &amp; Evaluation</li><li>Conclusion</li><li>References</li></ol><h3>Introduction</h3><p>Time series forecasting is a statistical technique used to make predictions about future values of a sequence of data points that are ordered in time. It involves analyzing historical data patterns to identify trends, patterns, and seasonality in the data, and then using that information to forecast future values. Time series forecasting is essential in various domains due to its wide range of applications, including Finance, weather prediction, sales forecasting etc.</p><p>Time series forecasting presents unique challenges due to the characteristics of time series data, which include trends, seasonality, and noise. Understanding and addressing these challenges is essential to ensure accurate and reliable forecasts, which we will cover in upcoming sections.</p><p>In this article we focus on LSTMs, which stands for Long Short-Term Memory, is a type of recurrent neural network (RNN) that has gained popularity for its ability to effectively model long-range dependencies in sequential data, making it well-suited for time series forecasting tasks. LSTMs are a variant of RNNs that were specifically designed to address the vanishing gradient problem, which is a common issue in training deep neural networks.</p><h3>Background</h3><p>LSTMs have a unique architecture that allows them to capture and store information over extended sequences, making them capable of handling time series data with long-term dependencies. The key feature of an LSTM is its memory cell, which can store information over long periods of time and selectively forget or update this information as new data points are processed. This allows LSTMs to effectively capture patterns in time series data, including trends, seasonality, and other complex dependencies.</p><p>The ability of LSTMs to capture long-term dependencies in sequences comes from the combination of the <strong>memory cell and the gating mechanisms</strong>. The memory cell allows LSTMs to store information over long sequences, and the gating mechanisms (input gate, forget gate, and output gate) allow LSTMs to selectively update and forget information, enabling them to capture relevant long-term dependencies while ignoring irrelevant information.</p><p>The architecture of LSTM models:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*q-y5JULGBlWE8j0mZZ8Xhw.png" /><figcaption>LSTM Architecture (Source: <a href="https://databasecamp.de/en/ml/lstms">https://databasecamp.de/en/ml/lstms</a>)</figcaption></figure><ol><li><strong>Memory Cell (Remember Gate)</strong>: allows LSTM to capture and store information over long sequences. It has an internal state that is updated at each time step based on the input and the outputs from the gates</li><li><strong>Input Gate</strong>: determines how much of the input at the current time step should be stored in the memory cell. It takes the input feature and the hidden state from the previous time step as inputs and passes them through a sigmoid activation function, which produces a value between 0 and 1 for each feature.</li><li><strong>Forget Gate</strong>: determines how much of the information in the memory cell from the previous time step should be forgotten or erased. It takes the input feature and the hidden state from the previous time step as inputs and passes them through a sigmoid activation function. The output of the forget gate is multiplied element-wise with the current memory cell state, allowing the LSTM to selectively erase information from the memory cell.</li><li><strong>Output Gate</strong>: determines how much of the memory cell state should be output at the current time step. It takes the input feature and the hidden state from the previous time step as inputs and passes them through a sigmoid activation function. The current memory cell state is then passed through a tanh activation function, and the output of the tanh activation is multiplied element-wise with the output of the output gate, producing the final output of the LSTM.</li></ol><h3>EDA &amp; Data Preprocessing</h3><p>As mentioned earlier we’ll be working on Daily Climate data sourced from Kaggle (Source: <a href="https://www.kaggle.com/datasets/sumanthvrao/daily-climate-time-series-data?datasetId=312121&amp;sortBy=voteCount&amp;searchQuery=LSTM">https://www.kaggle.com/datasets/sumanthvrao/daily-climate-time-series-data?datasetId=312121&amp;sortBy=voteCount&amp;searchQuery=LSTM</a>).</p><p>The data has a timeframe from Jan’13 to April’17 for Delhi, India with attributes like temperature, humidity, wind speed, and pressure.</p><h4>EDA</h4><p>We start off with the basic EDA of the time series and observe quite stable graphs for all the variables across the time period. There is certainly seasonality in mean temperature which we’ll be discussing going forward</p><pre>plt.figure(figsize=(20, 10))<br>colors = [&#39;#FF7F50&#39;, &#39;#DDA0DD&#39;, &#39;#66CDAA&#39;, &#39;#BC8F8F&#39;]<br>for i, j in enumerate(df.set_index(&#39;date&#39;).columns):<br>  plt.subplot(len(df.set_index(&#39;date&#39;).columns) + 1, 1, i + 1)<br>  plt.plot(df.set_index(&#39;date&#39;)[j], color=colors[i]);<br>  plt.ylabel(j, fontsize=16)<br>  plt.grid()<br>plt.xlabel(&#39;Date&#39;, fontsize=16)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jiS3Rb8LDtX2v8FWJR9kYg.png" /><figcaption>Plot for all variables in the data</figcaption></figure><h4>ADF Test for Stationarity</h4><p>We check then check the stationarity of the time series by leveraging ADF Test and observe a &gt;0.05 p-value of 0.15 indicating non-stationarity in the time series</p><pre>test_results = adfuller(df[&quot;meantemp&quot;])<br><br>print(f&quot;ADF test statistic: {test_results[0]}&quot;)<br>print(f&quot;p-value: {test_results[1]}&quot;)<br>print(&quot;Critical thresholds:&quot;)<br>for key, value in test_results[4].items():<br>  print(f&quot;\t{key}: {value}&quot;)</pre><p>To correct the non-stationarity in the time series we do a log transform on the data to make it stationary</p><pre>fig, ax = plt.subplots(3, 1, figsize=(20, 15))<br><br>ax[0].plot(df[&quot;date&quot;], df[&quot;meantemp&quot;], label=&quot;Original series&quot;)<br>ax[1].plot(df[&quot;date&quot;], np.log(df[&quot;meantemp&quot;]), label=&quot;After log transform&quot;)<br><br>df[&quot;meantemp_transformed&quot;] = pd.Series(np.log(df[&quot;meantemp&quot;])).diff(periods=12)  # 12 months<br>df.dropna(inplace=True)<br>ax[2].plot(df[&quot;date&quot;], df[&quot;meantemp_transformed&quot;], label=&quot;After differencing&quot;);</pre><p>After performing a log transform we again perform the ADF test and get a p-value for the ADF test of ~1.34(e-5) which allows us to reject the null hypothesis and confirms the stationarity</p><h4>Scaling</h4><p>Once we have stationary time series, we’ll be scaling the data to bring all the values in a range of 0,1 using the MinMaxScaler. Scaling is has an important role as it directly affects the model performance, and is highly recommended</p><pre>scaler = StandardScaler()<br>df_scaled = scaler.fit_transform(df.drop(columns=&#39;date&#39;))<br>df_scaled = pd.DataFrame(df_scaled, columns=df.drop(columns=&#39;date&#39;).columns)</pre><h4>Classic Sliding Window</h4><p>We’ll need to convert the data frame into sliding window tensors which is required as input in the LSTM model. We are using 10 days as the window for past data</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/511/1*KPyLTpC0rZIp7PZCLftuqA.png" /><figcaption>Sliding window</figcaption></figure><pre>def create_window(target, feature, window=1, offset=0):<br>    feature_new, target_new = [], []<br>    feature_np = feature.to_numpy()<br>    target_np = target.to_numpy()<br>    for i in range(window, target.shape[0] - offset):<br>        feature_list = feature_np[i - window:i]<br>        feature_new.append(feature_list.reshape(window, feature_np.shape[1]))<br>        target_new.append(target_np[i+offset].reshape(1))<br>    return np.array(feature_new), np.array(target_new)<br><br>window = 10<br>feature_columns = [&#39;humidity&#39;, &#39;wind_speed&#39;, &#39;meanpressure&#39;, &#39;meantemp&#39;]<br><br>feature, target = create_window(df_scaled[&#39;meantemp&#39;],df_scaled[feature_columns], window=window)<br>df_scaled.head()</pre><h4>Train-Test Split</h4><p>Lastly, in data preprocessing, we’ll split the data into Train-Test based on the time order</p><pre>def train_test(feature, target, perc_train = 0.9):<br>    size_train = int(len(feature) * perc_train)<br><br>    x_train = feature[0:size_train]<br>    y_train = target[0:size_train]<br><br>    x_test = feature[size_train: len(feature)]<br>    y_test = target[size_train: len(feature)]<br><br>    return x_train, x_test, y_train, y_test</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*SS5Yw_qUxxhRNq6irg4QnA.png" /><figcaption>Train-Test Split for Mean Temperature</figcaption></figure><h3>LSTM Modeling Building</h3><p>We have majorly taken care of the data preprocessing required so let&#39;s now delve into the model-building part. We’ll be using a sequential model with a deep network of LSTM and dense layers and mean squared error as our evaluation metric</p><pre>def model_lstm(x_shape):<br><br>    model = keras.Sequential()<br>    model.add(keras.layers.LSTM(50,return_sequences=True, input_shape=(x_shape[1], x_shape[2])))<br>    model.add(keras.layers.LSTM(64, return_sequences=False))<br>    model.add(keras.layers.Dense(32))<br>    model.add(keras.layers.Dense(16))<br>    model.add(keras.layers.Dense(x_shape[2]))<br>    <br>    model.compile(loss=&#39;mean_squared_error&#39;, optimizer=&#39;adam&#39;)<br>    return model</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*mIYOAuJYvIKlyM0U4kA4DQ.png" /><figcaption>Model summary</figcaption></figure><h3>Model Training &amp; Evaluation</h3><p>Once we have completed the model training we’ll move into its performance evaluation. From the below graphs, we can judge that the model performance is pretty good and we’re able to achieve a very low MSE loss of ~0.003.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*-qZpZDiGY0UmAj6eQSIs-A.png" /><figcaption>Loss vs Epochs</figcaption></figure><p>Overall if we see the compilation of prediction versus original values for the test, the overlap is very good indicating that the model is able to understand the pattern and predict accurately</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/575/1*EiOP61Nzss2d8JwpIJIddA.png" /><figcaption>Overlap of original and predicted values</figcaption></figure><h3>Conclusion</h3><p>Hence, we conclude our learnings on LSTM and practical application on a time series data set.<br><em>The complete code in a colab notebook can be found </em><a href="https://colab.research.google.com/drive/1n4z3xPmCZRCM7ThPSkGWzJonuQwTRGFx?usp=sharing"><em>here</em></a><em>.</em></p><h4>Ideas for future work</h4><p>Comparative analysis b/w LSTM and transformers, and with transformers we’ll try to increase the prediction window to multiple days instead of just next-day prediction</p><p><em>I hope you liked it and had some learnings, please show your support with a clap or feedback in the comments. If possible help me fund my medium membership by gifting one </em><a href="https://medium.com/gift-plans#giftMembership"><em>here</em></a>, <em>I would greatly appreciate the help.</em></p><h3>References</h3><p><a href="https://databasecamp.de/en/ml/lstms">Long Short-Term Memory Networks (LSTM)- simply explained! | Data Basecamp</a></p><p><a href="http://colah.github.io/posts/2015-08-Understanding-LSTMs/">http://colah.github.io/posts/2015-08-Understanding-LSTMs/</a></p><p><a href="https://www.kaggle.com/code/avk256/time-series-prediction-lab5-ex">https://www.kaggle.com/code/avk256/time-series-prediction-lab5-ex</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bbe6f425c688" width="1" height="1" alt=""><hr><p><a href="https://medium.com/aiskunks/daily-climate-forecasting-time-series-forecasting-using-lstm-recurrent-neural-nets-bbe6f425c688">Daily Climate Forecasting — Time Series Forecasting using LSTM, Recurrent Neural Nets</a> was originally published in <a href="https://medium.com/aiskunks">AI Skunks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A tour through Visualization zoo — Time series and Geospatial Maps]]></title>
            <link>https://medium.com/aiskunks/a-tour-through-visualization-zoo-time-series-and-geospatial-maps-bc730ace8864?source=rss-6789e44c6d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/bc730ace8864</guid>
            <category><![CDATA[geospatial-data]]></category>
            <category><![CDATA[visualization]]></category>
            <category><![CDATA[charts-and-graphs]]></category>
            <category><![CDATA[time-series-analysis]]></category>
            <category><![CDATA[maps]]></category>
            <dc:creator><![CDATA[Shubham Goyal]]></dc:creator>
            <pubDate>Tue, 14 Mar 2023 02:34:35 GMT</pubDate>
            <atom:updated>2023-03-27T16:38:40.291Z</atom:updated>
            <content:encoded><![CDATA[<h3>A tour through Visualization zoo — Time series and Geospatial Maps</h3><p><em>This article is an attempt to discuss in detail some of the most useful visualization techniques for Time series and Geospatial Maps discussed in the research paper “A Tour through the Visualization Zoo: A survey of powerful visualization techniques, from the obvious to the obscure”</em></p><p><a href="https://queue.acm.org/detail.cfm?id=1805128">A Tour through the Visualization Zoo</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GxICY61i4K04_453ZZVfHg.jpeg" /></figure><p>Topics we would be discussing —</p><ol><li>Introduction to Time Series Visualization</li><li>Types of charts:<br>- Index Charts<br>- Stacked graphs<br>- Small Multiples<br>- Horizon graphs</li><li>Maps<br>- Flow Maps<br>- Choropleth Maps<br>- Graduated Symbol Maps</li></ol><h3>Introduction to Time Series visualization</h3><p>Time series visualization is a technique used to analyze and understand time series data through visual means. By creating visualizations of time series data, we can identify patterns and trends in the data that might not be immediately apparent from looking at the raw numbers.</p><p>Visualizations can take many forms, including line charts, bar charts, area charts, and scatter plots. The choice of visualization type depends on the specific characteristics of the data being analyzed and the analysis goals.</p><p>Examples of time series data include stock prices, weather data, and website traffic statistics.</p><pre>import numpy as np<br>import pandas as pd<br>import matplotlib.pyplot as plt<br><br># Generate random time series data<br>dates = pd.date_range(&#39;2022-01-01&#39;, periods=100, freq=&#39;D&#39;)<br>values = np.random.randint(10, 100, size=(100,))<br><br># Create data frame<br>df = pd.DataFrame({&#39;date&#39;: dates, &#39;value&#39;: values})<br><br># Set date column as index<br>df.set_index(&#39;date&#39;, inplace=True)<br><br>plt.figure(figsize=(12, 6))<br><br># Create line chart of time series data<br>plt.plot(df.index, df[&#39;value&#39;])<br><br># Add title and axis labels<br>plt.title(&#39;Random Time Series Visualization&#39;)<br>plt.xlabel(&#39;Date&#39;)<br>plt.ylabel(&#39;Value&#39;)<br><br># Display chart<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*yonBGZpFyGjptrrhKPyX5A.png" /></figure><h3>Types of Charts</h3><p><strong>a) Index Charts —</strong></p><p>They are used to display changes in a variable over time, with time represented on the x-axis and the variable of interest represented on the y-axis. Index charts are useful for showing trends and patterns in data over time. They are particularly useful for tracking changes in data that occur at regular intervals, such as daily, weekly, or monthly data.</p><p>Index charts can be used in a wide range of fields, including finance, economics, and environmental science, to name just a few. In finance, for example, index charts are often used to track changes in stock prices over time.</p><pre>#Creating a function for indexing<br><br>def create_indexed_columns(date, df, top_level_name=&quot;&quot;):<br>    &quot;&quot;&quot;Returns indexed columns for given dataframe&quot;&quot;&quot;<br><br>    # find index of the date that is closest to our reference date<br>    closest_date_index = df.index.get_loc(date, method=&quot;nearest&quot;)<br><br>    # get the values in the initial columns for the reference date <br>    reference_values = df.iloc[closest_date_index]<br><br>    # divide initial columns by values at ref. date and store in intermediate df<br>    inter_df = df.div(reference_values)*100 - 100<br><br>    # create a multindex for the intermediate df using the date as top-level index<br>    closest_date = df.index[closest_date_index]<br>    inter_df.columns = pd.MultiIndex.from_product(<br>                    [[top_level_name if top_level_name else (closest_date)], inter_df.columns])<br>    <br>    return inter_df, closest_date</pre><pre>import numpy as np<br>import pandas as pd<br>import matplotlib.pyplot as plt<br><br># Generate random time series data<br>dates = pd.date_range(&#39;2022-01-01&#39;, periods=100, freq=&#39;D&#39;)<br>values_1 = np.random.randint(10, 100, size=(100,))<br>values_2 = np.random.randint(20, 200, size=(100,))<br><br># Create data frame<br>df = pd.DataFrame({&#39;date&#39;: dates, &#39;value_1&#39;: values_1, &#39;value_2&#39;: values_2})<br><br># Set date column as index<br>df.set_index(&#39;date&#39;, inplace=True)<br><br>inter_df,df_index= create_indexed_columns(&#39;2022-01-01&#39;,df)<br>plt.figure(figsize=(12, 6))<br>plt.plot(inter_df)<br>plt.title(&#39;Random Time Series Index Chart&#39;)<br>plt.xlabel(&#39;Date&#39;)<br>plt.ylabel(&#39;Value&#39;)<br>plt.legend()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xBQ-VryoWpa3gyoBNTYfAg.png" /></figure><p><strong>b) Stacked Charts —</strong></p><p>Time series stacked charts are a type of chart that allows you to visualize changes in the composition of multiple variables over time. Stacked charts use multiple layers of data to represent the total value of a variable at each point in time, and the relative proportion of each layer shows how the variable is made up of different components.</p><p>Stacked charts are particularly useful for visualizing changes in the composition of time series data where the total value remains constant, such as the market share of different companies or the percentage of sales by product category. By stacking the data, you can see how the different components contribute to the total over time, and how their relative importance changes</p><pre>import numpy as np<br>import pandas as pd<br>import matplotlib.pyplot as plt<br><br># Generate random time series data<br>dates = pd.date_range(&#39;2022-01-01&#39;, periods=100, freq=&#39;D&#39;)<br>values_1 = np.random.randint(10, 100, size=(100,))<br>values_2 = np.random.randint(20, 200, size=(100,))<br><br># Create data frame<br>df = pd.DataFrame({&#39;date&#39;: dates, &#39;value_1&#39;: values_1, &#39;value_2&#39;: values_2})<br><br># Set date column as index<br>df.set_index(&#39;date&#39;, inplace=True)<br><br># Create stacked chart of time series data<br>plt.stackplot(df.index, df[&#39;value_1&#39;], df[&#39;value_2&#39;], labels=[&#39;Value 1&#39;, &#39;Value 2&#39;])<br><br># Add title and axis labels<br>plt.title(&#39;Random Time Series Stacked Chart&#39;)<br>plt.xlabel(&#39;Date&#39;)<br>plt.ylabel(&#39;Value&#39;)<br>plt.legend()<br><br># Display chart<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/389/1*fQM4De0X2_aERwYYYf666g.png" /></figure><p><strong>c) Small multiples -</strong></p><p>Small multiples are a series of small charts or graphs that each show a subset of the data. By breaking the data up into smaller chunks, small multiples allow us to see the patterns and trends in the data more clearly. Small multiples can be used to visualize time series data in a way that is both informative and visually appealing.</p><pre>import numpy as np<br>import pandas as pd<br>import matplotlib.pyplot as plt<br><br># Generate random time series data<br>dates = pd.date_range(&#39;2022-01-01&#39;, periods=100, freq=&#39;D&#39;)<br>values_1 = np.random.randint(10, 100, size=(100,))<br>values_2 = np.random.randint(20, 200, size=(100,))<br><br># Create data frame<br>df = pd.DataFrame({&#39;date&#39;: dates, &#39;value_1&#39;: values_1, &#39;value_2&#39;: values_2})<br><br># Set date column as index<br>df.set_index(&#39;date&#39;, inplace=True)<br><br># Create small multiples of time series data<br>fig, axs = plt.subplots(nrows=2, ncols=1, figsize=(8, 6))<br>axs[0].plot(df[&#39;value_1&#39;])<br>axs[0].set(title=&#39;Value 1 Time Series&#39;, xlabel=&#39;Date&#39;, ylabel=&#39;Value&#39;)<br>axs[1].plot(df[&#39;value_2&#39;])<br>axs[1].set(title=&#39;Value 2 Time Series&#39;, xlabel=&#39;Date&#39;, ylabel=&#39;Value&#39;)<br><br># Add space between subplots<br>fig.tight_layout()<br><br># Display chart<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*1BThQzaJk5mvE8PRCUDKVQ.png" /></figure><p><strong>d) Horizon Graphs -</strong></p><p>A time series horizon graph is a type of visualization that displays a time series over a range of time with multiple horizons, or layers, of the data stacked on top of each other. The purpose of this visualization is to allow viewers to compare changes in the data across time, while also showing changes in the distribution of the data.</p><p>In a horizon graph, the data is divided into several horizontal bands, each of which represents a portion of the data’s range. Each band is then split into two halves, with the top half representing positive values and the bottom half representing negative values. The bands are then layered on top of each other, with the top bands representing the most recent data and the bottom bands representing the oldest data.</p><p>Horizon graphs are useful for visualizing time series data with large numbers of observations over a long period of time, as they can display a lot of information in a compact space. They are particularly effective for showing changes in the distribution of the data, such as shifts in the mean or changes in the variability over time.</p><pre>import numpy as np<br>import pandas as pd<br>import matplotlib.pyplot as plt<br>import seaborn as sns<br><br># Generate random time series data<br>dates = pd.date_range(&#39;2022-01-01&#39;, periods=100, freq=&#39;D&#39;)<br>values = np.random.randn(100).cumsum()<br><br># Create data frame<br>df = pd.DataFrame({&#39;date&#39;: dates, &#39;value&#39;: values})<br><br># Set date column as index<br>df.set_index(&#39;date&#39;, inplace=True)<br><br># Create horizon graph of time series data<br>fig, ax = plt.subplots(figsize=(8, 4))<br><br># Use Seaborn library to create horizon plot<br>sns.lineplot(data=df, palette=&#39;colorblind&#39;, alpha=0.8, linewidth=1.5, ax=ax)<br><br># Set axis labels and title<br>ax.set(xlabel=&#39;Date&#39;, ylabel=&#39;Value&#39;, title=&#39;Horizon Graph of Time Series Data&#39;)<br><br># Display chart<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*mKOZhURtOucf50MZuKGrbg.png" /></figure><h3>Geospatial Maps</h3><p><strong>a) Flow Maps</strong></p><p>Flow maps are a type of visualization that represent movement or flows of entities, such as people, goods, or information, between locations. They are useful for visualizing patterns of movement and identifying hotspots or hubs of activity.</p><p>Flow maps typically use lines or arrows to represent the flow of entities, with the width of the lines or arrows proportional to the volume of entities being moved. The lines or arrows are usually drawn between geographic locations, such as cities, regions, or countries, with the flow direction indicated by the direction of the lines or arrows.</p><pre>import pandas as pd<br>import numpy as np<br>import folium<br><br># Generate random data<br>n_flows = 50<br>origins = np.random.normal(loc=[34.05, -118.24], scale=[0.2, 0.2], size=(n_flows, 2))<br>destinations = np.random.normal(loc=[34.05, -118.24], scale=[0.2, 0.2], size=(n_flows, 2))<br>volumes = np.random.uniform(low=0, high=100, size=n_flows)<br><br># Create DataFrame<br>flows = pd.DataFrame({&#39;origin_lat&#39;: origins[:,0],<br>                      &#39;origin_lon&#39;: origins[:,1],<br>                      &#39;dest_lat&#39;: destinations[:,0],<br>                      &#39;dest_lon&#39;: destinations[:,1],<br>                      &#39;volume&#39;: volumes})<br><br># Create map<br>m = folium.Map(location=[34.05, -118.24], zoom_start=10, tiles=&#39;Stamen Toner&#39;)<br><br># Add flows to map<br>for index, row in flows.iterrows():<br>    origin = (row[&#39;origin_lat&#39;], row[&#39;origin_lon&#39;])<br>    dest = (row[&#39;dest_lat&#39;], row[&#39;dest_lon&#39;])<br>    weight = row[&#39;volume&#39;]<br>    folium.PolyLine(locations=[origin, dest], weight=weight/10, color=&#39;red&#39;, opacity=0.5).add_to(m)<br><br># Display map<br>m</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1eKsRRlRCAgskVX0bjrrpQ.png" /><figcaption>Lines representing geospatial data</figcaption></figure><p><strong>b) Choropleth Maps</strong></p><p>Choropleth maps are a type of map that use color or shading to represent the variation of a particular variable across geographic regions. The name “choropleth” comes from the Greek words “choros” (region) and “plethos” (multitude), indicating that the map shows a multitude of regions.</p><p>Choropleth maps are particularly useful for displaying data that is aggregated at a regional level, such as population density, income, or voting patterns. By using color or shading to represent the variation of the data, choropleth maps can quickly convey patterns and trends that might be difficult to see in a table or a chart</p><pre>import geopandas as gpd<br>import matplotlib.pyplot as plt<br><br># Load the map data<br>world = gpd.read_file(gpd.datasets.get_path(&#39;naturalearth_lowres&#39;))<br><br># Load the data to be displayed<br>data = {&#39;country&#39;: [&#39;France&#39;, &#39;Germany&#39;, &#39;Spain&#39;, &#39;Italy&#39;],<br>        &#39;value&#39;: [10, 20, 30, 40]}<br><br># Convert the data to a Pandas DataFrame<br>df = pd.DataFrame(data)<br><br># Join the map data and the data to be displayed<br>merged = world.merge(df, left_on=&#39;name&#39;, right_on=&#39;country&#39;)<br><br># Create the choropleth map<br>fig, ax = plt.subplots(figsize=(10, 6))<br>merged.plot(column=&#39;value&#39;, cmap=&#39;Blues&#39;, ax=ax, legend=True)<br><br># Add a title<br>ax.set_title(&#39;Example Choropleth Map&#39;)<br><br># Remove the axis<br>ax.axis(&#39;off&#39;)<br><br># Show the plot<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/473/1*T_IhSZrkZOn57S2teOnO3g.png" /></figure><p><strong>c) Graduated Symbol Maps</strong></p><p>Graduated symbol maps are a type of thematic map that display quantitative data for different geographic locations using proportional symbols. The size of each symbol on the map represents the value of the variable being visualized. The symbols are typically scaled to be proportional to the square root or cube root of the data value, to ensure that the differences in size between the symbols are visually meaningful.</p><pre>import folium<br>import numpy as np<br>import pandas as pd<br><br># Generate random data<br>n_points = 50<br>data = pd.DataFrame({<br>    &#39;latitude&#39;: np.random.uniform(low=35, high=45, size=n_points),<br>    &#39;longitude&#39;: np.random.uniform(low=-120, high=-80, size=n_points),<br>    &#39;value&#39;: np.random.randint(low=1, high=1000, size=n_points)<br>})<br><br># Create a map centered on the United States<br>m = folium.Map(location=[39.50, -98.35], zoom_start=4)<br><br># Add circles to the map for each data point<br>for i, row in data.iterrows():<br>    folium.Circle(<br>        location=[row[&#39;latitude&#39;], row[&#39;longitude&#39;]],<br>        radius=row[&#39;value&#39;] ** 0.5 * 1000,<br>        color=&#39;blue&#39;,<br>        fill=True,<br>        fill_color=&#39;blue&#39;,<br>        fill_opacity=0.5,<br>        tooltip=&#39;Location {}: {}&#39;.format(i, row[&#39;value&#39;])<br>    ).add_to(m)<br><br># Display the map<br>m</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wHaALF2JG5f2fHI2kbaL9A.png" /></figure><p>With this we come to an end of this article, if you wanna try on the code please feel free to try the below mentioned colab notebook.</p><p>Link to colab — <br>1) Detailed overview of above theory</p><p><a href="https://colab.research.google.com/drive/1DGruHJOxqyqo5yeaWx-GoBw8zqZxeHwI?usp=sharing">Google Colaboratory</a></p><p>2) Worked example for time series visualizations with financial dataset —</p><p><a href="https://colab.research.google.com/drive/1PcRjcjVacEibExHbY4DzlrqZumM-q64T?usp=sharing">Google Colaboratory</a></p><p><em>If you liked the article please give a clap! Thanks for your time :)</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bc730ace8864" width="1" height="1" alt=""><hr><p><a href="https://medium.com/aiskunks/a-tour-through-visualization-zoo-time-series-and-geospatial-maps-bc730ace8864">A tour through Visualization zoo — Time series and Geospatial Maps</a> was originally published in <a href="https://medium.com/aiskunks">AI Skunks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Runner’s High :  Reflecting on Runs in ‘22]]></title>
            <link>https://medium.com/@goyal.shubh15/runners-high-reflecting-on-runs-in-22-723b991094ea?source=rss-6789e44c6d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/723b991094ea</guid>
            <category><![CDATA[running]]></category>
            <category><![CDATA[data-sciecne]]></category>
            <category><![CDATA[strava]]></category>
            <category><![CDATA[visualization]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Shubham Goyal]]></dc:creator>
            <pubDate>Sat, 07 Jan 2023 22:40:36 GMT</pubDate>
            <atom:updated>2023-01-09T19:26:42.283Z</atom:updated>
            <content:encoded><![CDATA[<h3>Runner’s High: Reflecting on Runs in ‘22</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BYnhatzeDLC58q9O79bcvQ.png" /><figcaption>Maps of all my outdoor runs</figcaption></figure><p>When I was young I was fascinated by races, every year I’d give my best shot to make it to sports day sprint races. Little did I know then, running long distances would eventually become a hobby for me. I remember how failing at those races made me feel self-deprived, though looking back to last year I’m glad that I ran 400 km in total. The year has been overwhelming with a lot of ‘first’ experiences, travel, and lifestyle changes but running served as my escape and form of rehabilitation.</p><p>In this blog, I try to visualize the data of my various runs logged on <a href="https://www.strava.com/">Strava</a>. I can’t thank enough Strava for providing me a platform to connect with a community of local athletes, and tracking runs statistics — which kept me motivated enough.</p><p>At the start of 2022, I had two goals to achieve towards running —</p><ol><li>Complete 500km in the total distance on runs, an ambitious goal of 780km. I had chosen this thinking even if I run 15km/week I can easily achieve it and considering some irregularity I reduced it to 500km.</li><li>Reach a 5:30min/km average pace for a 5km run. I thought it reflects a state of fitness and I could push myself to achieve it.</li></ol><p>I went on around 90 runs in 2022, with a mindset of not running less than 5 km on a single run. When I started off the year it was an activity hard to adhere to but I kept at it. There were days with shin pain, calf pain, and extreme temperatures (reaching 40ºC) but pushing myself at those times helped me remain consistent and come out strong. Today, running 5km has become basic, and building upon that is the next challenge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6Rt4ZttwdGz16unOdMpINw.png" /><figcaption>Y-o-Y Stats for ’21 &amp; ’22 — Apparently I almost never ran on Mondays</figcaption></figure><p>There is an observable difference in the above two charts, both in the spread as well as the intensity—distance (reflected by the color shade). The only change I can think of when I reflect is the habit of making goals for ’22, which was lacking in ‘21.</p><p>March’22 was the most consistent month and I was able to manage a 6-week streak of 15 km/week. Just with that consistency, I was able to clock over 60km in a single month. Achieving small targets of a bigger goal does help it make easy, I could feel a positive energy and a sense of accomplishment at the end of each week.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*1klc3EXlSXU69wQDCnOz9Q.png" /><figcaption>M-o-M distance totals</figcaption></figure><p>From August onwards my days were filled with travel, adjusting to a new city, and cold weather due to which my running took a bad hit. I wouldn’t say fully but I’m satisfied with what I could achieve over the year. Improving my avg pace from over 6min/km to hitting below 5:30min/km and running a 10km long run for the first time was very fulfilling.</p><p>In addition to logging my runs, I loved how I could add a picture as the cover for that run. I would eventually share that cover on Instagram with running stats, which indirectly acted as a hook for me and fed my passion for photography.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*gX1v5hOygvItgMWXJ-xyvw.png" /><figcaption>One of my Fav captures — Central Park, Jaipur IN</figcaption></figure><p>Some practices that worked well for me —</p><ol><li>Logging runs — Strava, Fitbit</li><li>Running on alternate days or taking at least a day’s break</li><li>Setting a larger goal, breaking it into smaller targets</li><li>Good Shoes — I didn’t bargain on this, and wouldn’t recommend either</li><li>Creating a hook — pictures/sharing on Instagram worked for me</li><li>Reviewing runs — I used to find patches where I tend to get slow</li><li>Running with a group — helps you keep a consistent pace</li></ol><p>I don’t run just for being fit, it is always more than that. It gives me a chance to view the city from a different perspective, to venture out more frequently, seek some ‘aha’ moments to capture, meet new people, and feel accomplished. While I’m running, I constantly have an internal dialogue that eventually turns into a form of meditation for me. It&#39;s similar to how Haruki Murakami has beautifully captured his thoughts on running in his novel — ‘What I talk about when I talk about running’. Do give it a read sometime.</p><p>Looking forward to an exciting 2023!</p><p>References :</p><ul><li><a href="https://github.com/marcusvolz/strava_py">GitHub - marcusvolz/strava_py: Create artistic visualisations with your exercise data (Python version)</a></li><li><a href="https://www.tableau.com/blog/how-make-art-out-your-strava-activity-data-tableau-104639">How to make art out of your Strava activity data with Tableau</a></li><li><a href="https://www.strava.com/athletes/66621093">Strava Runner Profile | Shubham Goyal</a></li></ul><p><a href="https://www.instagram.com/shu3ham96/?next=%2F">https://www.instagram.com/shu3ham96/?next=%2F</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=723b991094ea" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Changes]]></title>
            <link>https://medium.com/@goyal.shubh15/i-just-realized-how-much-i-have-hated-changes-for-the-past-years-of-my-life-and-how-it-has-effected-c05e046e26be?source=rss-6789e44c6d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/c05e046e26be</guid>
            <category><![CDATA[philosophy-of-mind]]></category>
            <category><![CDATA[change-your-life]]></category>
            <category><![CDATA[philosophy]]></category>
            <category><![CDATA[change]]></category>
            <category><![CDATA[fear]]></category>
            <dc:creator><![CDATA[Shubham Goyal]]></dc:creator>
            <pubDate>Tue, 13 Feb 2018 11:04:14 GMT</pubDate>
            <atom:updated>2018-04-02T06:05:34.390Z</atom:updated>
            <content:encoded><![CDATA[<p>I just realized how much i have hated changes for the past years of my life and how it has effected me.<br>I have hated changes because of the sole reasons i was scared of them. New people, new place, new job, new field, new things have always given me second thoughts and I always choose the path which seemed familiar instead of taking a risk. This is wrong. You should be brave and take the responsibility to stand and fight it. Sometimes you will fail but when you will succeed you will see the glory which you have been rewarded with. <br>Fight, Rise and Shine!<br>The world is always open for you, if you are scared today you will not be able to explore it. Be smart not a fool, think wisely and thats it nothing else is required.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c05e046e26be" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>