<?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 Ogunjirin Oluwasotun Goodness  on Medium]]></title>
        <description><![CDATA[Stories by Ogunjirin Oluwasotun Goodness  on Medium]]></description>
        <link>https://medium.com/@oluwasotunogunjirin?source=rss-3409c505df74------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*qHxZ9kWt7jRxzbnc</url>
            <title>Stories by Ogunjirin Oluwasotun Goodness  on Medium</title>
            <link>https://medium.com/@oluwasotunogunjirin?source=rss-3409c505df74------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 18:11:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@oluwasotunogunjirin/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[Uncovering Wine Quality Segments Through Principal Component Analysis]]></title>
            <link>https://medium.com/@oluwasotunogunjirin/uncovering-wine-quality-segments-through-principal-component-analysis-72a7d6182696?source=rss-3409c505df74------2</link>
            <guid isPermaLink="false">https://medium.com/p/72a7d6182696</guid>
            <category><![CDATA[matplotlib]]></category>
            <category><![CDATA[numpy]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[pandas]]></category>
            <category><![CDATA[pca-analysis]]></category>
            <dc:creator><![CDATA[Ogunjirin Oluwasotun Goodness ]]></dc:creator>
            <pubDate>Tue, 23 Dec 2025 22:14:40 GMT</pubDate>
            <atom:updated>2025-12-23T22:14:40.740Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Oxudnd89_7WCaPbB" /><figcaption>Photo by <a href="https://unsplash.com/@nazirbuildingdesigner?utm_source=medium&amp;utm_medium=referral">Nazir Ahmad</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>What separates a bold Cabernet from a delicate Pinot Noir? Beyond taste and terroir, the answer lies in chemistry. Thirteen distinct chemical measurements that together define a wine’s identity. But here’s the problem: how do you make sense of thirteen variables all at once? This is where Principal Component Analysis comes in, a technique that transforms overwhelming complexity into something you can actually see and understand.</p><p>Working with the classic Wine dataset of 178 samples across three customer segments, I faced exactly this challenge. Each wine came with thirteen chemical measurements, everything from Alcohol and Flavanoids to the more mysterious OD280, which relates to protein content. The segments weren’t evenly distributed either. Segment 2 had 71 wines, Segment 1 had 59, and Segment 3 brought up the rear with 48. The big question was whether I could take these thirteen dimensions, delineate, and compress them into something simple enough to visualize, while still keeping what makes each segment special.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zzQ7kbFxqhmbPU1ymck20A.png" /><figcaption>Libraries used for the analysis</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*BMWNJ2dIpsHtURwuxAFxWA.png" /><figcaption>Dataset and Column Information</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/1*mEwpe8CRvIlsYeesH-NDWA.png" /><figcaption>Customer Segments of the Wines</figcaption></figure><p>Before running the Principal Component Analysis (PCA), I had to deal with a crucial problem. Principal Component Analysis (PCA) is extremely sensitive to the scale of your features. If one measurement ranges into the hundreds while another stays below one, the bigger numbers will dominate everything purely because they’re larger. This would be like letting the loudest person in the room make all the decisions, regardless of what they’re actually saying. Using the StandardScaler library fixed this. By putting all features on equal footing the data was ready for the transformation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vVgETrtE4Dkh2dlWCBUpDA.png" /><figcaption>Code snapshot for scaling the data</figcaption></figure><p>By fitting the Principal Component Analysis (PCA) with just two components on our scaled data, I was asking the algorithm to do something remarkable, which was to capture as much variation as possible using only two dimensions instead of thirteen. What came out was a two-dimensional map that tells a surprisingly complete story about wine chemistry.</p><p>The scatter plot is beautiful in its simplicity. When you project all 178 wines onto a plane defined by these two principal components, the three customer segments don’t just separate, they form clear clusters. The first component runs along the x-axis, the second along the y-axis, and together they create natural boundaries between wine types that originally needed thirteen measurements to define. But seeing the separation is only half the story. Understanding why these components work the way they do is where things get really interesting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*0JPXvtjD4KwiB9b0dBUBCw.png" /><figcaption>The Scatter Plot of the Principal Components</figcaption></figure><p>The first principal component captures most of the variation in the data and it reads like a wine quality report card. On the positive side, Flavanoids score highest at 0.92, and these compounds are crucial for astringency and how well a wine ages. Total Phenols come in at 0.86, representing overall structure. OD280 hits 0.82, tied to protein content and maturity. On the negative side, Nonflavanoid Phenols score minus 0.65, meaning lower levels actually push wines higher on this component. Same with Malic Acid at minus 0.53 and Ash Alcanity at minus 0.52. What this means is simple: the first component essentially separates complex, phenol-rich wines from simpler, more acidic ones. It’s capturing a fundamental quality gradient.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/1*vQWkWDB4Vm6euPPyhzXbCg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e-MiBtZEk0BC5d58FC84FQ.png" /><figcaption><em>Code snapshot for getting the component vectors and eigen values for the components</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1002/1*617JBTXN1xMLtAnNVJoc6w.png" /><figcaption>Results for the Explained Variances (EigenValues for each component)</figcaption></figure><p>The second component tells a completely different story, one focused on intensity rather than quality. Color Intensity dominates at 0.84, basically defining how visually bold a wine appears. Alcohol comes in strong at 0.77, contributing to body and the feeling in your mouth. Proline, an amino acid that indicates concentration, scores 0.58. Hue sits at minus 0.44, where lower values mean deeper, more saturated colors. Put it all together and this component separates powerful, intense wines from lighter, more delicate ones. It’s about concentration and presence rather than complexity.</p><p>This is where the real value becomes clear. We haven’t just reduced dimensions, we’ve found meaningful dimensions. Those thirteen abstract chemical measurements have been distilled into two interpretable ideas. Moving horizontally along the first component tracks quality and complexity. Moving vertically along the second tracks intensity and boldness. Together they create a sensible map of wine space where the customer segments naturally fall into place. A winemaker looking at this could identify exactly which chemical properties to adjust to move a product from one segment to another.</p><p>What makes this analysis work is that the components aren’t just mathematical artifacts. They align with concepts that wine experts already understand intuitively. The first component captures what makes a wine good. The second captures what makes it strong. When your data reduction reveals patterns that match domain knowledge, you know you’re onto something real.</p><p>In conclusion, this is what good data science looks like. Taking complexity and turning it into an insight. In this case, taking thirteen tangled variables and finding the two threads that matter most. In the world of wine chemistry, those threads turned out to be quality and intensity, and together they explain why different wines appeal to different customers.</p><p>The GitHub link is available <a href="https://github.com/Sotun-1010/Uncovering-Wine-Quality-Segments-Through-Principal-Component-Analysis">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72a7d6182696" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Predicting Stock Prices]]></title>
            <link>https://medium.com/@oluwasotunogunjirin/predicting-stock-prices-4e548411dc44?source=rss-3409c505df74------2</link>
            <guid isPermaLink="false">https://medium.com/p/4e548411dc44</guid>
            <category><![CDATA[var-model]]></category>
            <category><![CDATA[arimax]]></category>
            <category><![CDATA[arima]]></category>
            <category><![CDATA[time-series-forecasting]]></category>
            <category><![CDATA[granger-causality]]></category>
            <dc:creator><![CDATA[Ogunjirin Oluwasotun Goodness ]]></dc:creator>
            <pubDate>Sat, 13 Sep 2025 23:32:00 GMT</pubDate>
            <atom:updated>2025-09-13T23:32:00.285Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HEGllWsY4f4ogEaD" /><figcaption>Photo by <a href="https://unsplash.com/@hakannural?utm_source=medium&amp;utm_medium=referral">Hakan Nural</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The question that keeps traders, investors, and data scientists awake at night is deceptively simple: can we predict stock prices with mathematical precision? While the efficient market hypothesis suggests that all available information is already reflected in current prices, the persistent allure of discovering patterns in financial chaos continues to fuel innovation in predictive modelling. This comprehensive analysis explores three powerful time series forecasting approaches, building and comparing ARIMA, ARIMAX, and VAR models using real historical stock data to uncover which method truly captures the essence of market movements. The link to the GitHub Repo can be found <a href="https://github.com/Sotun-1010/WPM-Stock-price-prediction"><strong><em>here.</em></strong></a></p><p>For this investigation, I utilized 503 days of historical stock data from Weaton Precious Metals company, spanning from July 2023 to July 2025. The dataset provided a rich foundation for analysis, containing daily closing prices, standard OHLC (Open, High, Low, Close) data, trading volume with K/M notation indicating whether they were in thousands or millions, and daily percentage changes. The price range extended from $52.92 to $130.19, with trading volumes fluctuating between 64,980 and 5.1 million shares, creating an ideal playground for time series experimentation across various market conditions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WjmMGPyMkAu4U1PS.png" /><figcaption>Code Snapshot while converting the columns with K &amp; M notation to numbers</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/0*TCQuoUvpH8ofj_BP.png" /><figcaption>Checking the data</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/0*Ct2vKrtbrWy2q3Bf.png" /><figcaption>Output of the check</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/0*GSa8a5ycaNNWy6ji.png" /><figcaption>Line plot of the time series data</figcaption></figure><p>First and foremost, I looked at the ARIMA model. ARIMA, or AutoRegressive Integrated Moving Average, represents the Swiss Army knife of univariate time series forecasting. This powerful model combines three essential components: the AutoRegressive component where past values influence future predictions, the Integrated component that handles differencing to achieve stationarity, and the Moving Average component where past forecast errors shape future predictions. The beauty of ARIMA lies in its ability to capture complex temporal patterns while maintaining mathematical elegance.</p><p>The first critical challenge emerged immediately: determining whether our price series exhibited stationarity. Using the Augmented Dickey-Fuller test, the results were clear but unsurprising. With an ADF statistic of 0.4306 and a p-value of 0.9826, the test definitively rejected stationarity. Stock prices naturally exhibit trends and lack constant statistical properties over time, making this outcome expected. The solution required first-order differencing, transforming the data to achieve the stationarity necessary for reliable ARIMA modelling.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/0*bo4bIn7sd3cFf37l.png" /><figcaption>Checking for stationarity</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/988/0*r-Ce-YJD6jDbzVGJ.png" /><figcaption>Code Snapshot of the ACF and PACF plots</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fXhILUJPgFmoPUYk.png" /><figcaption>The ACF and PACF plots</figcaption></figure><p>After carefully analysing the Autocorrelation Function (ACF) and Partial Autocorrelation Function (PACF) plots, the optimal configuration emerged as ARIMA(0,1,0), essentially a random walk model. While this might appear overly simplistic, random walk models often demonstrate surprising effectiveness with financial data, reflecting the inherent unpredictability that makes markets challenging to forecast. The model was trained on 401 samples and tested on 101 samples, yielding a Mean Absolute Error of 2.34, Root Mean Square Error of 3.03, and a Mean Absolute Percentage Error of 300.57%. The unusually high MAPE resulted from the differenced series containing values near zero, a common characteristic when working with transformed financial time series.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1021/0*mP_babe-yTuU-UFm.png" /><figcaption>Results from the ARIMA Model</figcaption></figure><p>Building upon the ARIMA foundation, ARIMAX introduces exogenous variables to capture additional market information beyond pure time series patterns. This enhanced approach recognizes that stock prices don’t exist in isolation but respond to various market factors and conditions. For this analysis, I incorporated all available features as predictors: opening prices, high and low prices, trading volume, and daily percentage changes. Interestingly, the ARIMAX model encountered convergence issues during optimization, suggesting potential multicollinearity among the predictor variables. This warning signal made perfect sense given the inherent correlations between Open, High, Low, and closing prices. These variables naturally move together and contain overlapping information about market sentiment and trading activity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1005/0*g409Ph3GKTgSHZGy.png" /><figcaption>Results from the ARIMAX model</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/0*nnqULGaOeRZSEbeA.png" /><figcaption>Residual Plots of the Model</figcaption></figure><p>Despite the convergence challenges, the ARIMAX model produced intriguing results. The Mean Absolute Error increased to 4.72, and the Root Mean Square Error rose to 5.19. However, the Mean Absolute Percentage Error dramatically improved to 3.94%, a substantial enhancement over the pure ARIMA approach. This improvement occurred because the model now predicted actual price levels rather than differenced values, providing more interpretable and practically useful forecasts.</p><p>Before constructing the final model, I conducted comprehensive Granger Causality tests to determine which variables genuinely contain predictive power for future prices. Granger Causality addresses a fundamental question in time series analysis: does knowing the historical behaviour of variable X improve our ability to predict variable Y beyond using Y’s own history? The Granger Causality results proved both intuitive and illuminating. After ensuring all series achieved stationarity, several clear patterns emerged. Opening prices demonstrated significant predictive power with a p-value of 0.0018, indicating that yesterday’s opening price contains valuable information about today’s closing price. High prices showed similar significance with a p-value of 0.0385, while low prices exhibited the strongest predictive relationship with a p-value essentially at zero.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7Pakc1NcNTfLP7EK.png" /><figcaption>Code Snapshot for the Granger Causality test</figcaption></figure><p>Conversely, trading volume proved non-significant with a p-value of 0.1517, and daily percentage changes showed marginal significance at 0.0794. These results aligned perfectly with market intuition: previous day’s OHLC prices naturally contain information about subsequent price movements, while volume and percentage changes provide less reliable predictive signals. This analysis provided crucial guidance for constructing the final multivariate model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DMlZaiz0Jp_pQSE3.png" /><figcaption>Output of the Granger Causality test</figcaption></figure><p>The Vector Autoregression model represented the most sophisticated approach in this comparison, treating all variables as endogenous and allowing each variable to be predicted using the complete history of all variables in the system. This methodology acknowledges the complex interdependencies that characterize financial markets, where price movements, volume changes, and market sentiment interact in intricate ways.</p><p>Using the Bayesian Information Criterion (BIC) for model selection, the optimal lag order emerged as two days, meaning the VAR model incorporated the previous two days of all variables when generating predictions. This configuration balanced model complexity with predictive accuracy, avoiding both underfitting and overfitting risks.</p><p>The VAR model delivered remarkable results that justified its increased complexity. The Mean Square Error measured 7.03, with a Root Mean Square Error of 2.65 and a Mean Absolute Percentage Error of just 1.05%. This MAPE represented a dramatic improvement over both ARIMA variants, suggesting that the multivariate approach successfully captured market dynamics that univariate models missed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/0*6Esm0h1sEkRZF5_I.png" /><figcaption>Checking for stationarity for the VAR Model</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/0*wD0kTVsI8tE4Cs9n.png" /><figcaption>Building the Var Model</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/0*GK6i4MebvqvMPr9I.png" /><figcaption>Result of the VAR Model</figcaption></figure><p>The comparative analysis revealed several crucial insights about stock price prediction and time series modelling. The VAR model’s superior performance highlighted that stock prices fundamentally don’t exist in isolation but form part of an interconnected system where OHLC relationships contain valuable predictive information. This finding challenges approaches that focus solely on closing prices while ignoring other available market data. Stationarity emerged as a critical requirement across all successful models. Each approach required data transformation to achieve the statistical properties necessary for reliable time series analysis. This requirement reflects the trending nature of financial data and the importance of proper preprocessing in time series applications. The effectiveness of the simple ARIMA(0,1,0) random walk model provided compelling evidence supporting aspects of the efficient market hypothesis. Despite its simplicity, this baseline model achieved reasonable performance, suggesting that much of stock price movement follows random patterns that resist prediction. Perhaps most importantly, the analysis demonstrated that incorporating relevant multivariate relationships proved more effective than building increasingly complex univariate models. Rather than seeking sophisticated single-variable approaches, the key lay in understanding and modeling the interdependencies between related market variables.</p><p>While the VAR model achieved an impressive 1.05% MAPE, several important caveats apply to these results. Past performance provides no guarantee of future results, particularly in financial markets where regime changes can invalidate historical relationships. Transaction costs, bid-ask spreads, and market impact costs weren’t incorporated into the analysis but would significantly affect real-world trading performance. The limited test dataset size raises concerns about overfitting, and the analysis period may not capture the full range of market conditions that affect predictive model performance. Market volatility, economic cycles, and external shocks can dramatically alter the relationships between variables, potentially rendering historical patterns obsolete. These findings carry significant implications for various market participants. Traders might benefit from VAR-style models that incorporate OHLC relationships rather than relying exclusively on closing price patterns. Risk managers can leverage Granger causality analysis to identify key risk factors and understand how different market variables influence each other over time.</p><p>For data scientists, this analysis demonstrates the power of combining rigorous statistical testing with model selection procedures. The Granger causality analysis provided essential guidance for feature selection and model construction, illustrating how theoretical understanding can inform practical modelling decisions. Future research directions could explore regime-switching models to handle changing market volatility, incorporate external economic indicators as additional predictors, investigate deep learning approaches like LSTM networks, or develop ensemble methods that combine multiple modelling approaches. Each avenue offers potential for enhanced predictive accuracy while addressing different aspects of market complexity.</p><p>While perfect stock price prediction remains elusive, this comprehensive analysis demonstrates that thoughtful application of time series techniques can extract meaningful signals from market noise. The key lies not in discovering the perfect model but in understanding the relationships within financial data and selecting appropriate analytical tools. The VAR model’s success reinforces a fundamental truth in finance: prices don’t move in isolation but participate in a complex, interconnected system where multiple variables influence each other through time. Sometimes, the most effective approach involves embracing this complexity rather than attempting to oversimplify market dynamics.</p><p>This investigation reveals that successful financial forecasting requires balancing statistical rigor with market intuition, combining sophisticated modeling techniques with deep understanding of financial market behavior. While we may never achieve perfect prediction, we can certainly improve our understanding of how markets move and develop more informed approaches to financial decision-making. The journey through ARIMA, ARIMAX, and VAR models illustrates the evolution from simple to sophisticated, from univariate to multivariate, and from isolated to interconnected thinking about financial time series. Each approach contributed valuable insights, but the clear winner emerged from acknowledging and modeling the complex relationships that truly drive market behavior. Thank you for reading and stay lit.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4e548411dc44" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlocking Customer Insights with Unsupervised Learning]]></title>
            <link>https://medium.com/@oluwasotunogunjirin/unlocking-customer-insights-with-unsupervised-learning-154729bfccbc?source=rss-3409c505df74------2</link>
            <guid isPermaLink="false">https://medium.com/p/154729bfccbc</guid>
            <category><![CDATA[unsupervised-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[customer-segmentation]]></category>
            <category><![CDATA[kmeans-clustering]]></category>
            <category><![CDATA[plotly]]></category>
            <dc:creator><![CDATA[Ogunjirin Oluwasotun Goodness ]]></dc:creator>
            <pubDate>Fri, 12 Sep 2025 23:07:42 GMT</pubDate>
            <atom:updated>2025-09-12T23:07:42.349Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>How I Built a Data-Driven Segmentation Model</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zu9peVbNR6XfK35P" /><figcaption>Photo by <a href="https://unsplash.com/@uxindo?utm_source=medium&amp;utm_medium=referral">UX Indonesia</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Hello everyone, it’s me again. Have you ever wondered what your customers actually look like beyond basic demographics? As businesses collect more data than ever, the challenge isn’t gathering information, it’s making sense of it all. In one of my latest projects, I share how I used machine learning to discover hidden patterns in customer data, revealing four distinct personas that could transform any marketing strategy and I also built a Plotly dash app to show how various features interacted within the clusters (The link is at the end of this article). The link to the GitHub Repo for the analysis can be found <a href="https://github.com/Sotun-1010/Customer-segmentation-analysis-using-K-Means-clustering"><strong><em>here.</em></strong></a></p><p>Picture this: you have 2,000 customers in your database, each with detailed information about their age, income, education, occupation, and lifestyle. That’s a goldmine of information, but how do you turn it into actionable insights? The traditional approach might involve manual analysis or predetermined assumptions about customer groups. But what if we could let the data speak for itself?</p><p>This is where <strong>unsupervised learning</strong> comes in, specifically, a technique called K-means clustering. Unlike supervised learning where we know what we’re looking for, unsupervised learning discovers hidden patterns without any predetermined labels. Think of it as letting an AI detective examine your customer base and naturally group similar customers together.</p><p>I started with a clean dataset of 2,000 customers, each described by eight key attributes:</p><ul><li><strong>Demographics</strong>: Age, sex, marital status</li><li><strong>Socioeconomics</strong>: Income, education, occupation</li><li><strong>Geography</strong>: Settlement size (small city, mid-sized city, big city)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/0*LFQ5QEVcD4T9Jwar.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/0*x8JjrOmQUKhdWBfI.png" /><figcaption><em>Snapshots of the code and the result of the columns information</em></figcaption></figure><p>The beauty of this dataset? Zero missing values and perfectly clean data, a data scientist’s dream! But before diving into clustering, some detective work was needed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/0*iBPmsp08NVjw_t6m.png" /><figcaption><em>Output of the total null values in the dataset</em></figcaption></figure><p>Real-world data is messy, and outliers can throw off our entire analysis. Imagine trying to group customers when one person earns $30,000 and another earns $3,000,000. That extreme outlier would skew everything. Using the <strong>Interquartile Range (IQR) method</strong>, I identified and removed 132 outliers (about 6.6% of the data). This technique looks at the middle 50% of your data and flags anything that falls too far outside this range. After this cleanup, and after the clean up, I had 1,868 rows of customer data left from the initial 2,000 rows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/987/0*XPTUF599jB3cQ_E9.png" /><figcaption>Checking for outliers in the data</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wd_NkQA1VaESaXPA.png" /><figcaption>Removing the outliers</figcaption></figure><p>Here’s a crucial insight many people miss. K-means clustering uses distance calculations to group similar customers. But what happens when you’re comparing age (ranging 18–76) with income (ranging $35K-$300K)? The income differences would completely dominate the age differences! The solution? <strong>Standardization</strong>. I transformed all features to have a mean of 0 and standard deviation of 1, ensuring each attribute gets equal weight in the clustering process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/988/0*qeRTROHbS9zPKHdx.png" /><figcaption>Scaling the data</figcaption></figure><p>Now to the t<strong>he “Million-Dollar Question”: How Many Customer Groups Exist?</strong></p><p>This is where the art meets the science. How do you determine the optimal number of customer segments? I used two proven techniques:</p><p><strong>1. The Elbow Method</strong></p><p>Imagine you’re looking for the sweet spot in a graph that resembles a bent arm. As you increase the number of clusters, the “tightness” of groups improves rapidly at first, then levels off. The “elbow” point suggests the optimal number and in this case, it pointed to <strong>4 clusters</strong>.</p><p><strong>2. Silhouette Analysis</strong></p><p>This technique measures how well each customer fits into their assigned group versus other groups. Think of it as a confidence score for your clustering. The analysis confirmed that 4 clusters provided the best balance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ag8c_96IKhL_4VHn.png" /><figcaption>Determining the optimal number of clusters with the elbow method and silhouette scores</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cbkmpt6B0pHbRgUf.png" /><figcaption>Plots for the Elbow Method and Silhouette Scores</figcaption></figure><p>After training the K-means model, four fascinating customer personas emerged:</p><p><strong>Cluster 0: The Young Professionals</strong></p><p><em>“Building their foundation”</em></p><ul><li><strong>Profile</strong>: 28-year-old married women</li><li><strong>Income</strong>: $119,462 (moderate)</li><li><strong>Education</strong>: High school</li><li><strong>Occupation</strong>: Skilled employees</li><li><strong>Location</strong>: Small cities</li><li><strong>Size</strong>: The foundation builders establishing their careers</li></ul><p><strong>Cluster 1: The Urban Achievers</strong></p><p><em>“Making it in the big city”</em></p><ul><li><strong>Profile</strong>: 37-year-old single men</li><li><strong>Income</strong>: $132,207 (high)</li><li><strong>Education</strong>: High school</li><li><strong>Occupation</strong>: Skilled employees</li><li><strong>Location</strong>: Big cities</li><li><strong>Size</strong>: Career-focused individuals thriving in metropolitan areas</li></ul><p><strong>Cluster 2: The Established Elite</strong></p><p><em>“Peak earning power”</em></p><ul><li><strong>Profile</strong>: 52-year-old married women</li><li><strong>Income</strong>: $132,412 (highest)</li><li><strong>Education</strong>: University degree</li><li><strong>Occupation</strong>: Skilled employees</li><li><strong>Location</strong>: Small cities</li><li><strong>Size</strong>: Experienced professionals at their earning peak</li></ul><p><strong>Cluster 3: The Emerging Segment</strong></p><p><em>“Starting their journey”</em></p><ul><li><strong>Profile</strong>: 32-year-old single women</li><li><strong>Income</strong>: $87,572 (lowest)</li><li><strong>Education</strong>: High school</li><li><strong>Occupation</strong>: Unemployed/unskilled</li><li><strong>Location</strong>: Small cities</li><li><strong>Size</strong>: Individuals in transition, seeking opportunities</li></ul><p>From this analysis, I could depict a few things:</p><ol><li><strong>Income patterns</strong>: Three clusters show similar income levels ($119K-$132K), while one shows significantly lower earnings ($87K)</li><li><strong>Geographic insights</strong>: Interestingly, most high earners prefer small cities over big cities (except for our Urban Achievers)</li><li><strong>Education vs. Income correlation</strong>: University education appears in our highest-earning, most established segment</li><li><strong>Gender patterns</strong>: Women dominate three of four segments, with men concentrated in urban, high-earning roles</li></ol><p>After this I used two metrics to assess the model’s performance:</p><ul><li><strong>Silhouette Score</strong>: 0.26 (indicating reasonably separated clusters with some overlap)</li><li><strong>Davies-Bouldin Index</strong>: 1.31 (suggesting good separation and compactness)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*s6DtmJ6prZV51_k7.png" /><figcaption>Code Snapshot for the Average Silhouette and Davies-Bouldin Index</figcaption></figure><p>While these scores indicate room for improvement, they confirm that our four segments are statistically meaningful and distinct.</p><p>Now, these personas aren’t just academic exercises, they’re strategic goldmines and can be applied in various instances for example:</p><p><strong>For Marketing Teams, they can:</strong></p><ul><li>Target Young Professionals with family-oriented products and services</li><li>Reach Urban Achievers through big-city digital channels and premium offerings</li><li>Appeal to Established Elite with luxury and convenience-focused messaging</li><li>Support the Emerging Segment with affordable, skill-building opportunities</li></ul><p><strong>For Product Development teams, they can:</strong></p><ul><li>Design different service tiers matching each segment’s income level</li><li>Create location-specific offerings (urban vs. small city preferences)</li><li>Develop educational products for the Emerging Segment</li></ul><p><strong>For Customer Experience teams, they can:</strong></p><ul><li>Customize communication styles for different education levels</li><li>Tailor service offerings to marital status and lifestyle preferences</li></ul><p>In today’s data-driven world, generic “one-size-fits-all” approaches are becoming obsolete. This customer segmentation project demonstrates how unsupervised learning can reveal hidden insights that transform how we understand and serve our customers.</p><p>The four personas discovered weren’t predetermined categories, they emerged naturally from the data itself. This is the power of machine learning: it can uncover patterns that human analysis might miss.</p><p>I also built a python dash app for easy visualization of how several features interact within the clusters. Feel free to check it out <a href="https://dash-app-for-customer-segmentation.onrender.com/"><strong><em>the live app</em></strong></a> and the <a href="https://github.com/Sotun-1010/dash-app-for-customer-segmentation"><strong><em>GitHub Repo</em></strong></a> here too.</p><p>This analysis also opens doors to deeper investigations like:</p><ul><li><strong>Predictive modelling</strong>: Can we predict which cluster a new customer belongs to?</li><li><strong>Temporal analysis</strong>: How do these segments evolve over time?</li><li><strong>A/B testing</strong>: Do different marketing approaches work better for different clusters?</li><li><strong>Revenue optimization</strong>: Which segments offer the highest lifetime value?</li></ul><p>Customer segmentation through machine learning isn’t just a technical exercise, it’s a bridge between data and business strategy. By letting patterns emerge naturally from the data, we create more nuanced, accurate, and actionable customer insights. What patterns might be hiding in your customer data? The only way to find out is to let the algorithms take a look. Want to dive deeper into the technical implementation? Feel free to connect with me for more detailed discussions about the methodology, code, and advanced techniques used in this analysis. Thank you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=154729bfccbc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cancer EDA with Python, Excel and Flourish Studio]]></title>
            <link>https://medium.com/@oluwasotunogunjirin/cancer-eda-with-python-excel-and-flourish-studio-9098db686f9b?source=rss-3409c505df74------2</link>
            <guid isPermaLink="false">https://medium.com/p/9098db686f9b</guid>
            <category><![CDATA[eda]]></category>
            <category><![CDATA[flourish-studio]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[python-visualization]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Ogunjirin Oluwasotun Goodness ]]></dc:creator>
            <pubDate>Wed, 30 Jul 2025 15:51:38 GMT</pubDate>
            <atom:updated>2025-07-30T15:51:38.605Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XZcwaeksITsvmIsC" /><figcaption>Photo by <a href="https://unsplash.com/@ang10ze?utm_source=medium&amp;utm_medium=referral">Angiola Harry</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Diving into the world of data analysis once more, I’m thrilled to share a story from a recent project where I delved into the fascinating world of global cancer patient data from 2015 to 2024. My goal was to uncover key insights and trends related to cancer diagnosis, treatment, and survival, using a comprehensive dataset. I leveraged Python for data cleaning and extraction, and then brought my findings to life with interactive visualizations in Flourish Studio.</p><p>My project began with checking through the dataset, which contained 50,000 entries and 15 columns. Each row represented a patient, and the columns provided a wealth of information:</p><ul><li><strong>Patient_ID:</strong> A unique identifier for each individual.</li><li><strong>Age:</strong> The patient’s age.</li><li><strong>Gender:</strong> The patient’s reported gender.</li><li><strong>Country_Region:</strong> The country where the patient’s data originated.</li><li><strong>Year:</strong> The year of data reporting.</li><li><strong>Genetic_Risk, Air_Pollution, Alcohol_Use, Smoking, Obesity_Level:</strong> These are all numerical scores representing various risk factors.</li><li><strong>Cancer_Type:</strong> The specific type of cancer diagnosed (e.g., Lung, Leukemia, Breast, Colon, Skin, Cervical, Liver, Prostate).</li><li><strong>Cancer_Stage:</strong> The stage of cancer at diagnosis (Stage 0 to Stage IV).</li><li><strong>Treatment_Cost_USD:</strong> The cost of treatment in US dollars.</li><li><strong>Survival_Years:</strong> The number of years the patient survived.</li><li><strong>Target_Severity_Score:</strong> A score indicating the severity of the cancer.</li></ul><p>Before I could visualize anything, I needed to ensure my data was clean and structured correctly. My good ol’ buddy, Python, was my primary tool for this.</p><p>My initial steps in Python were crucial for preparing the data for analysis and visualization:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c0ihi8ml5djyU0rDMa9QqA.png" /><figcaption>Loading and Viewing the dataset</figcaption></figure><ol><li><strong>Loading the Data:</strong> I started by importing pandas and loading the CSV file into a DataFrame.</li><li><strong>Initial Inspection:</strong> I used the pandas head(), shape, info(), isna() and sum() to get a quick overview of the data, check for missing values, and understand column data types. Thankfully, there were no missing values, which made my job a bit easier.</li><li><strong>Creating Age Groups:</strong> To analyze age-related trends more effectively, I created a new categorical column called Age_Group. I categorized patients into ‘Under 30’, ’30–50&#39;, ’51–70&#39;, and ‘Above 70’ based on their age. This allowed for more generalized insights into age demographics.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K5wEz5VIQjcbXZY5cx9QeA.png" /><figcaption>Creating the age group category</figcaption></figure><p>4.<strong> Extracting Key Sub-Datasets:</strong> This was where I prepared the data for Flourish Studio. I grouped and aggregated data to create summary tables for various analyses. For instance, a few subsets I calculated included:</p><ul><li>Total cancer cases per country.</li><li>Cancer cases by gender and country.</li><li>Cancer cases by age group and country.</li><li>Cancer types by country.</li><li>Number of cases per year by country.</li><li>Average risk factors by country.</li><li>Cancer stage by country.</li><li>Treatment cost per year by country.</li><li>Average severity score per year by country.</li><li>Proportion of different cancer types and stages.</li><li>Cancer type and stage distribution by gender and age group.</li><li>Average risk factors by gender and age group.</li><li>Total and average treatment cost by cancer type and stage.</li></ul><p>During this process I utilized python’s groupby() method for aggregation and unstack() for pivoting the data for deeper insights. I also used a few other methods alongside editing in excel to ensure the data was in the anticipated format ready to be visualized. These extracted datasets became the backbone of my visualizations in Flourish Studio.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/1*iNx2iho4MuiFn67O-8QmZw.png" /><figcaption>Sample code utilizing the groupby and unstack methods</figcaption></figure><p>Now, let’s dive into the exciting part, the visualization in Flourish Studio.</p><p>1. Number of Cancer Cases per Country</p><p>My first visualization showed the total number of cancer cases across different countries. I found that Australia had the highest number of cases (5092), while Canada had the lowest (4864). This immediately gave me a geographical perspective on cancer prevalence in the dataset.</p><iframe src="https://flo.uri.sh/visualisation/24268315/embed" width="700" height="575" frameborder="0" scrolling="no"><a href="https://medium.com/media/37f654408d8d845a4e41beba9527894f/href">https://medium.com/media/37f654408d8d845a4e41beba9527894f/href</a></iframe><p>2. Country Cases by Gender and Age Groups</p><p>This visualization provided a dual perspective. For Country Cases by Gender, I observed that Australia had the most male and female cases, while the ‘Other’ gender category had a tie between Australia and India. This indicated a relatively balanced distribution across genders within each country, with slight variations.</p><iframe src="https://flo.uri.sh/visualisation/24268685/embed" width="700" height="575" frameborder="0" scrolling="no"><a href="https://medium.com/media/66b1dc2793624a89cc6b4d1b865f95ad/href">https://medium.com/media/66b1dc2793624a89cc6b4d1b865f95ad/href</a></iframe><p>The Country Cases by Age Groups chart revealed that the 30–50 age group had the most cases in the USA. For the 51–70 age group, India showed the highest numbers. Cases above 70 were most prevalent in Germany, and Australia had the most cases in the ‘Under 30’ age group. This breakdown highlighted how cancer prevalence can vary significantly across different age demographics and countries.</p><iframe src="https://flo.uri.sh/visualisation/24269544/embed" width="700" height="575" frameborder="0" scrolling="no"><a href="https://medium.com/media/34b7e886d4e1900594fd0c0ab395b3e4/href">https://medium.com/media/34b7e886d4e1900594fd0c0ab395b3e4/href</a></iframe><p>3. Cancer Types by Countries</p><p>Here, I visualized the prevalence of each cancer type within each country. The interactive nature of the Flourish chart allowed me to filter by cancer type, but even without filtering, I could see the distribution. India and Germany appeared to have interesting distributions across various cancer types, suggesting unique epidemiological patterns in those regions.</p><iframe src="https://flo.uri.sh/visualisation/24269658/embed" width="700" height="575" frameborder="0" scrolling="no"><a href="https://medium.com/media/1c2c3974488015946873ac82092117c7/href">https://medium.com/media/1c2c3974488015946873ac82092117c7/href</a></iframe><p>4. Average Risk Factors across Countries</p><p>This chart illustrated the average scores for genetic risk, air pollution, alcohol use, smoking, and obesity level across the different countries. It helped me understand the general risk profiles of patients in each region. The scores seemed relatively consistent across countries, hovering around 5 for most factors, which might indicate a normalized or scaled representation of these risks.</p><iframe src="https://flo.uri.sh/visualisation/24298490/embed" width="700" height="575" frameborder="0" scrolling="no"><a href="https://medium.com/media/57bc393284f45fe8694884874f51ee2d/href">https://medium.com/media/57bc393284f45fe8694884874f51ee2d/href</a></iframe><p>5. Cancer Stage Cases across Countries</p><p>Similar to cancer types, this visualization showed the distribution of cancer stages (Stage 0 to Stage IV) across countries. It allowed me to see if certain countries had a higher proportion of early or late-stage diagnoses.</p><iframe src="https://flo.uri.sh/visualisation/24298814/embed" width="700" height="575" frameborder="0" scrolling="no"><a href="https://medium.com/media/d3dcc23cc4adc2eeccb5917e0dc1f2f0/href">https://medium.com/media/d3dcc23cc4adc2eeccb5917e0dc1f2f0/href</a></iframe><p>6. Country Cases across Years (2015–2024)</p><p>This dynamic chart, which I designed to be interactive in Flourish, showed how the number of cases evolved year by year for each country. One aspect worthy of note was how the number of cases in Australia spiraled up from the year 2020. This type of analysis is crucial for understanding disease progression and the impact of health interventions over time.</p><iframe src="https://flo.uri.sh/visualisation/24269981/embed" width="700" height="575" frameborder="0" scrolling="no"><a href="https://medium.com/media/187a97d9012f087180002bd775247939/href">https://medium.com/media/187a97d9012f087180002bd775247939/href</a></iframe><p>7. Country Cost across Years (2015–2024)</p><p>This chart mirrored the previous one but focused on treatment costs. In 2017 for instance, China had the highest total treatment cost (approximately $97.48 million), while Pakistan had the lowest (approximately $85.34 million). I also noted that while Australia had more cases and higher spending, Canada, with fewer cases, spent more than Pakistan. This raised an important question: “Does it mean that some cancer types or stages are more expensive to treat?” This led me to my next set of analyses.</p><iframe src="https://flo.uri.sh/visualisation/24299046/embed" width="700" height="575" frameborder="0" scrolling="no"><a href="https://medium.com/media/be66ea96e3829ff44c994bf081ebbdb4/href">https://medium.com/media/be66ea96e3829ff44c994bf081ebbdb4/href</a></iframe><p>8. No. of Patients and Average Treatment Cost by Cancer Stage</p><p>To answer my own question, I created this chart. It clearly showed that Stage III cancer had the highest average treatment cost, even though it had the third-highest total number of patients. This was a significant finding, indicating that advanced stages of cancer are indeed more expensive to manage.</p><iframe src="https://flo.uri.sh/visualisation/24454682/embed" width="700" height="575" frameborder="0" scrolling="no"><a href="https://medium.com/media/cf00eb5f717febfca043c58eddcf7a33/href">https://medium.com/media/cf00eb5f717febfca043c58eddcf7a33/href</a></iframe><p>9. No. of Patients and Average Treatment Cost by Cancer Type</p><p>Following up on the cost question, this chart revealed that Lung cancer had the highest average treatment cost, despite having the least number of patients. This suggests that the type of cancer plays a crucial role in the financial burden of treatment. I did a bit of data check with python to confirm also confirm and I found out there were more lung cancer cases in Canada but fewer stage III cancer cases compared to Pakistan which confirmed my hypothesis was on point. I did not bother visualizing it further because I already included the subset of the data in the entire visualization. Refer to point 3 and 5 to access the charts.</p><iframe src="https://flo.uri.sh/visualisation/24455046/embed" width="700" height="575" frameborder="0" scrolling="no"><a href="https://medium.com/media/b8bb6703226bc9ae0df2b11181caaa3b/href">https://medium.com/media/b8bb6703226bc9ae0df2b11181caaa3b/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ml-V6U8PECqmukfMINzqTQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UoJCjk3Ba2rh0qlyN5V-OA.png" /></figure><p>10. Average Severity Scores across Years (2015–2024)</p><p>This interactive chart showed how the average severity scores changed over the years for each country. USA had the highest average severity score, suggesting that a larger proportion of their cases were more severe than in other countries while Brazil had the least average severity score.</p><iframe src="https://flo.uri.sh/visualisation/24299182/embed" width="700" height="575" frameborder="0" scrolling="no"><a href="https://medium.com/media/166dfdd759dc35d1e9c057e1f2abad91/href">https://medium.com/media/166dfdd759dc35d1e9c057e1f2abad91/href</a></iframe><p>11. Proportion of Cancer Types and Stages</p><p>These two donut charts provided a clear overview of the overall distribution. I found that Colon cancer was the most common cancer type (12.75%), and Stage II cancer cases were the most frequent (20.25%). This gave me a high-level understanding of the most prevalent cancer types and stages in the dataset.</p><iframe src="https://flo.uri.sh/visualisation/24300664/embed" width="700" height="575" frameborder="0" scrolling="no"><a href="https://medium.com/media/c89e917a3870fb2cdcec84a50305559f/href">https://medium.com/media/c89e917a3870fb2cdcec84a50305559f/href</a></iframe><iframe src="https://flo.uri.sh/visualisation/24300849/embed" width="700" height="575" frameborder="0" scrolling="no"><a href="https://medium.com/media/d36069c3e9313a2f0ad244cc1d4cbaae/href">https://medium.com/media/d36069c3e9313a2f0ad244cc1d4cbaae/href</a></iframe><p>12. Cancer Types by Gender</p><p>This stacked bar chart broke down cancer types by gender. A surprising insight here was that males had more breast cancer cases than females in this simulated dataset. This is an important detail to note, as it deviates from real-world epidemiology where breast cancer is far more prevalent in females. This highlights the simulated nature of the dataset.</p><iframe src="https://flo.uri.sh/visualisation/24301107/embed" width="700" height="575" frameborder="0" scrolling="no"><a href="https://medium.com/media/b4f243b11e335f89527fc9f0bbb6f909/href">https://medium.com/media/b4f243b11e335f89527fc9f0bbb6f909/href</a></iframe><p>13. Cancer Stages by Gender</p><p>This chart showed the distribution of cancer stages across the three gender categories, providing a clearer picture of how different genders are affected at various stages of the disease.</p><iframe src="https://flo.uri.sh/visualisation/24301226/embed" width="700" height="575" frameborder="0" scrolling="no"><a href="https://medium.com/media/6cad7bc6a501c0afb5e71d727ec18352/href">https://medium.com/media/6cad7bc6a501c0afb5e71d727ec18352/href</a></iframe><p>14. Average Risk Factors by Gender</p><p>Here, I visualized the average risk factors (genetic risk, air pollution, alcohol use, smoking, obesity level) across the three gender categories. This helped me understand if certain genders had higher exposure or susceptibility to particular risk factors.</p><iframe src="https://flo.uri.sh/visualisation/24301332/embed" width="700" height="575" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c94b31c6628a2e4821f11988283fd76/href">https://medium.com/media/3c94b31c6628a2e4821f11988283fd76/href</a></iframe><p>15. Cancer Stages by Age Group</p><p>This chart illustrated the distribution of cancer stages across the different age groups, showing which age groups were more prone to certain stages of cancer.</p><iframe src="https://flo.uri.sh/visualisation/24301474/embed" width="700" height="575" frameborder="0" scrolling="no"><a href="https://medium.com/media/1a41e9cd3a6da315d8743a6d41a7cb64/href">https://medium.com/media/1a41e9cd3a6da315d8743a6d41a7cb64/href</a></iframe><p>16. Cancer Types by Age Group</p><p>Similar to the previous chart, this one showed the distribution of cancer types across the various age groups, helping to identify age-specific cancer prevalence.</p><iframe src="https://flo.uri.sh/visualisation/24301559/embed" width="700" height="575" frameborder="0" scrolling="no"><a href="https://medium.com/media/f99349b2f4b4e8c18c2dfa170c7383f4/href">https://medium.com/media/f99349b2f4b4e8c18c2dfa170c7383f4/href</a></iframe><p>17. Average Risk Factors by Age Group</p><p>Finally, this chart presented the average risk factors distributed across the different age groups, allowing me to see how risk factor exposure might vary with age.</p><iframe src="https://flo.uri.sh/visualisation/24301640/embed" width="700" height="575" frameborder="0" scrolling="no"><a href="https://medium.com/media/6108ce77b938e0e15cd90df32a432ce0/href">https://medium.com/media/6108ce77b938e0e15cd90df32a432ce0/href</a></iframe><p>In conclusion, this exploratory data analysis project was incredibly insightful. By meticulously cleaning and preparing the data in Python and then creating dynamic visualizations in Flourish Studio, I was able to tell a comprehensive story about global cancer patients from 2015 to 2024.</p><p>I uncovered several key findings:</p><ul><li>Australia had the highest number of cancer cases, while Canada had the lowest.</li><li>Age and gender play a role in the distribution of cancer cases and types.</li><li>Colon cancer was the most common type, and Stage II was the most frequent stage.</li><li>Stage III cancer had the highest average treatment cost, and Lung cancer was the most expensive to treat on average.</li><li>The USA showed the highest average severity scores.</li></ul><p>While this dataset was simulated, the process of extracting, analyzing, and visualizing these trends provides a valuable framework for understanding real-world health data. It&#39;s truly rewarding to transform raw data into actionable insights that can inform public health strategies and potentially improve patient outcomes. To get access to the python notebook I used in extracting the data, you can check from the <a href="https://github.com/Sotun-1010/Cancer-EDA-with-Python-Excel-and-Flourish-Studio">GitHub repo</a>. You can also view the Presentation on<a href="https://www.canva.com/design/DAGt5wb9kcI/EAIVImgEfA5suIZbMZX1SA/edit?utm_content=DAGt5wb9kcI&amp;utm_campaign=designshare&amp;utm_medium=link2&amp;utm_source=sharebutton"> Canva</a> or on <a href="https://public.flourish.studio/story/3241063/">Flourish Studio</a> which will give you access to the full interactivity.</p><p>Lastly, I think a good analyst should be able to use any tool since they share the same underlying concepts and using flourish studio for visualization proved to be one of the best if not the best I have used so far. It’s definitely one to look out for if you want to include more interactivity in your charts. Thank you and stay lit.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9098db686f9b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Effective Linear Regression Models — Part 2]]></title>
            <link>https://medium.com/@oluwasotunogunjirin/building-effective-linear-regression-models-part-2-90244de3de9f?source=rss-3409c505df74------2</link>
            <guid isPermaLink="false">https://medium.com/p/90244de3de9f</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[linear-regression-python]]></category>
            <category><![CDATA[f-regression]]></category>
            <dc:creator><![CDATA[Ogunjirin Oluwasotun Goodness ]]></dc:creator>
            <pubDate>Mon, 26 May 2025 13:43:01 GMT</pubDate>
            <atom:updated>2025-05-26T14:17:04.628Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building Effective Linear Regression Models — Part 2</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Wvr9xVTAO0_lYy8A" /><figcaption>Photo by <a href="https://unsplash.com/@edge2edgemedia?utm_source=medium&amp;utm_medium=referral">Edge2Edge Media</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In my previous write-up on how to <a href="https://medium.com/@oluwasotunogunjirin/building-effective-linear-regression-models-part-1-e9f3e7a8e56d">build effective linear models — Part 1</a>, I broke down the essentials of simple linear regression, showing how we can leverage a single independent variable and multiple dependent variables to predict outcomes through a basic linear relationship. Now, I’m excited to take you deeper into the world of statistical modeling with Part 2, where I’ll unpack F-regression — a powerful technique that has transformed my approach to feature selection. While my earlier work laid the groundwork for understanding how variables relate, this time I’ll reveal how F-regression helps me determine which variables actually matter in my models. I’ve found this method particularly fascinating because it uses the F-test to separate the signal from the noise, allowing me to build more efficient and meaningful predictive models. Trust me, once you grasp F-regression, you’ll never look at feature selection the same way again.</p><p>Before we move on, let’s take a look at the data once again. The dataset contained data from customers who bought clothes online using an app and a website and contained 500 rows and 8 columns of data. The columns included in the dataset were the email, address, avatar, average session length, time on the app, time on the website, length of membership, and the yearly amount spent. I only created multiple linear model to predict the annual amount various customers spend since the simple linear model wasn’t going to perform well. Feel free to access the code on GitHub too.</p><p>When I set out to build the linear regression model for predicting customer spending, I began by importing essential Python libraries. These included pandas and numpy for data manipulation, seaborn and matplotlib for visualization, Pylab, Scipy stats and several modules from scikit-learn for machine learning tasks. My goal was to create a workflow that would allow me to both explore the data and build predictive models, while also identifying which features were most influential.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PjKxICxDNrKdiBFHl-WDcA.png" /><figcaption>Snapshot of the libraries</figcaption></figure><p>After gathering my tools, I loaded the e-commerce dataset into a data frame. This dataset contained various customer attributes, such as average session length, time spent on the app and website, and length of membership, along with the yearly amount each customer spent. I had carefully examined the data to ensure it was clean and ready for analysis before, so I did not need to do it again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UlcKxtecHOrYyuxcGzuEnA.png" /><figcaption>Loading the data</figcaption></figure><p>Before jumping straight into the multiple linear model, a key part of my process was using f_regression, a statistical method for feature selection. By applying f_regression, I was able to quantify the strength and significance of the relationship between each feature and the target variable. This helped me identify which factors had the most predictive power, ensuring that my final model was both accurate and interpretable. Now, how did I do this?</p><p>I selected the necessary columns, which turned out to be all numeric columns, using the Pandas <em>select_dtypes</em> method before splitting the data into target and feature variables y and X, respectively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*Pr_ffcikmPw2cAM0hBklxA.png" /><figcaption>Selecting the numeric columns and splitting into target and feature variables</figcaption></figure><p>After that, I used the f_regression method from the sci-kit learn library to determine the p-values of each feature concerning the target variable. The Avg Session Length, Time on App, and Length of membership columns had p-values less than 0.05, while the Time on website column had a value of 0.95, which turned out to be greater than 0.05, indicating it was not significant. This made me drop the column from the feature variable as I proceeded with the three other columns in my multiple linear model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*mNameIciKj9dUhXoc74fJg.png" /><figcaption>Snapshot of the f-regression analysis</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/329/1*HKdfSw9S6O3C71iQSkl-Xw.png" /><figcaption>Results from the f-regression analysis</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*CgUfHKEVSG7PspW5S7CQ-A.png" /><figcaption>Dropping the Time on the website column</figcaption></figure><p>Now to the multiple linear regression model. I had already defined the target and feature variables and up next was to split them into training and testing compartments using the <em>train_test_split</em> method from the <em>sci-kit learn</em> library. I also calculated the mean baseline to serve as a benchmark. Next, I plugged my training data into the model, double-checking with scikit-learn’s <em>check_is_fitted</em> method to ensure that the model was fitted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K4Sq6SOjZ46A589kzzu6OQ.png" /><figcaption>Splitting the data into train and test data</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lZWnfrreyP2e3S4qJN42lw.png" /><figcaption>Calculating the mean baseline for the data</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/1*mODfvxjnMZLSq06bESepfw.png" /><figcaption>Instantiating the linear regression model</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*ItM8dHUxV8iURjjHyD1M0w.png" /><figcaption>Checking the data is fitted</figcaption></figure><p>After fitting the multiple regression model, I predicted the target using the training data and got a mean absolute error score of 7.72. Not the much-expected improvement I was hoping for. The previous model also had a training mean absolute error of 7.72. After getting the mean absolute error for the training data, I drew out the intercept and coefficients passed into a data frame and placed them in an equation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uT8UGOYNZ3E6sarTjpluIA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*fdtvf4OvetgPdsJszhsEPA.png" /><figcaption>Mean absolute error for the training data</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eVNH-zt2GXXjsN1hT7zzrQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*OX2zYJh0yLv-x4hRN0nccQ.png" /><figcaption>Determining the coefficients for the linear regression equation</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_5V3p6iLcEXMJKy72ZOqdw.png" /><figcaption>The equation for the linear regression model</figcaption></figure><p>When I ran the model on my test data, the result was almost similar, having a mean absolute error of 8.58, which is just slightly higher than that of the test data in the first part, which was 8.56. Here comes the fun part, when I checked the R-Squared value, it had a score of 0.984, better than 0.977 of the model without the f regression. Amazing right? That means the model was explaining the variation in the target variable better than the previous model in <a href="https://medium.com/@oluwasotunogunjirin/building-effective-linear-regression-models-part-1-e9f3e7a8e56d">part 1 of this write-up,</a> or in simpler terms, 98.4% of the changes in the target variable are well accounted for by the feature variables. I also calculated the adjusted R-squared and got a similar value, indicating that the independent variables are very relevant predictors and the model is not being penalized for adding an “irrelevant column”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*SykSgcJEPHRZqC1OnHEdFA.png" /><figcaption>The R-Squared calculation</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*abRo1nLrrQbKbEKkwxlkqw.png" /><figcaption>The adjusted R-Squared calculation</figcaption></figure><p>Moving on, I visualized how well this model was performing with a residual plot and a probability plot using <em>Pylab</em> from the stats library. The residual plot showed the errors were nicely scattered around zero without obvious patterns, and the probability plot confirmed our residuals were following a normal distribution pretty closely, right along that diagonal line. These visualizations tell us that the multiple regression model was fitting the data extremely well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cTqAo06-ENgj_g7sqTeE0g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*HDNRoUG7QwVt_adc07JqRw.png" /><figcaption>Code snapshot for the probability plot</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*j_yy2pnxJnQOZaEd7uYGmg.png" /><figcaption>The probability plot</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*6S5yu0-IC6pZbiGaDG1KIQ.png" /><figcaption>The residual plot</figcaption></figure><p>I also built an interactive dashboard so anyone could play with the model and make predictions on the fly. The first step was creating a prediction function to handle the math behind the scenes. Then I tapped into the <em>iPywidgets</em> library, using the interact function and FloatSlider objects to create those adjustable sliders. The result was pretty sweet — a hands-on tool where you could drag sliders for each feature and instantly see how it would affect the yearly spending prediction. Much more engaging than just looking at static results! It let me (and would let others) experiment with different combinations of values and see the model’s response in real time. Great way to put the model to practical use and get a feel for how each factor influences the final prediction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KsQ4ewE5-lVFKqD6eqIJPQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0adgQ_47c6ULxSwPnKlycg.png" /><figcaption>Code snapshot for the interactive interfaces</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Thzge7sU_t6b-_OYMyMtdA.gif" /><figcaption>The interactive plot</figcaption></figure><p>Throughout this process, I aimed to build models that not only predicted customer spending accurately but also provided clear explanations for the underlying drivers. By combining data exploration, statistical feature selection, and regression modeling, I was able to deliver both predictive power and valuable business insights. If you found this interesting and helpful, please hit that clap button below and share it with anyone else who might benefit. You can also follow me on <a href="https://www.linkedin.com/in/oluwasotun-ogunjirin-603388181/">LinkedIn</a> and <a href="https://github.com/Sotun-1010">GitHub</a>. You can check out my other <a href="https://medium.com/@oluwasotunogunjirin">articles</a> and <a href="https://oglytics.webflow.io/projects">website</a> for more content like this too. Thank you, and stay lit.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90244de3de9f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Effective Linear Regression Models— Part 1]]></title>
            <link>https://medium.com/@oluwasotunogunjirin/building-effective-linear-regression-models-part-1-e9f3e7a8e56d?source=rss-3409c505df74------2</link>
            <guid isPermaLink="false">https://medium.com/p/e9f3e7a8e56d</guid>
            <dc:creator><![CDATA[Ogunjirin Oluwasotun Goodness ]]></dc:creator>
            <pubDate>Mon, 28 Apr 2025 11:02:42 GMT</pubDate>
            <atom:updated>2025-05-09T15:49:51.281Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*W6-uxxWsxywOKVei" /><figcaption>Photo by <a href="https://unsplash.com/@markuswinkler?utm_source=medium&amp;utm_medium=referral">Markus Winkler</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>So, linear regression models, huh? Maybe the name sounds a bit… well, linear. But don’t let that fool you. These seemingly straightforward tools are the unsung heroes behind countless analyses and predictions that shape our understanding of the world. Not quite sure what they’re all about or what they’re for? That’s perfectly alright. I am here to illuminate the power and practicality of linear regression, showing you how to move beyond the basic concept and build models that truly deliver meaningful insights.</p><p>Simple linear models are quite common nowadays, and we can assume almost anyone can build them. However, I often ask questions like, &quot;Is the model ideal? Is it accurate? Is it proper?&quot;. In my latest project, I have built a simple and multiple linear regression model using an <a href="https://www.kaggle.com/datasets/kolawale/focusing-on-mobile-app-or-website">E-Commerce dataset</a> from Kaggle. Using this model, I will explain important steps to ensure your linear regression model is accurate, proper, and ideal. In my next write-up, I’d be adding an extra step, which has to do with feature selection, but for now, let’s dive right in and explore the essential steps needed for building a linear regression model.</p><p>Before we move on, let’s see what the dataset is about, shall we? The dataset contained data from customers who bought clothes online using an app and a website. The dataset contained 500 rows and 8 columns of data. The columns included in the dataset were the email, address, avatar, average session length, time on the app, time on the website, length of membership, and the yearly amount spent. I created a simple and multiple linear model to predict the annual amount various customers spend. The code is also available on my <a href="https://github.com/Sotun-1010/linear_regression_model_without_f_regression">GitHub</a>; feel free to check it out. Now, let’s dive into how I created the linear regression models using effective methods.</p><p>I kicked things off by grabbing all the libraries I needed. That’s always step one with Python projects, right? I didn’t stress about getting every single import upfront — nobody does that anyway. I just started with the basics and added more as I went along. So I pulled in Pandas and NumPy for the data work, Matplotlib and Seaborn for making those nice visualizations, threw in some Pylab and SciPy for the math &amp; statistics, added ipywidgets for some interactive elements, and rounded it out with a bunch of scikit-learn libraries for the machine learning part. You know how it goes — just add what you need when you need it.</p><figure><img alt="importing python libraries" src="https://cdn-images-1.medium.com/max/1024/1*8O1Ly_-DiH_g3ihNcIaDrg.png" /><figcaption>Importing the libraries</figcaption></figure><p>Once I had all my libraries set up, I grabbed the dataset using Pandas’ <em>read_csv</em> function and loaded it into a data frame. You know, the usual first step with any data project. Then I did a quick check to see what I was working with — I looked at the shape and info of the data to get the lay of the land. Turned out I had 500 rows to work with and 8 different columns. Looking closer, five of those columns were numerical data (float or decimal types), and the other three were objects — categorical stuff or text. Just getting a feel for the data before diving deeper, as you do.</p><figure><img alt=".shape and .info python methods" src="https://cdn-images-1.medium.com/max/542/1*wMo0R4MmSRzfJvkNo7kTBA.png" /><figcaption>Code snap for the shape and column information</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/1*dhVllLUsT2-zsu_PDp2l6A.png" /><figcaption>The output for the column information</figcaption></figure><p>I checked for missing values next and — no surprise for a Kaggle dataset — there weren’t any. Clean data right out of the gate! Then I had to figure out which columns to use for my regression model. I took a good look at those three object columns and decided to cut them completely. Why? Well, they were packed with unique values, and I knew that trying to convert them to numbers would lead me straight into the “curse of dimensionality” trap. You know how it works with machine learning — each feature is basically another dimension in your model. Those object columns would’ve exploded into tons of features after encoding, and suddenly my model would be trying to make sense of this massive, high-dimensional space with the same amount of data points. The model would struggle to find patterns because everything becomes too spread out. It’s like trying to find your friends in a massive stadium versus a small room — way harder when there’s too much space! So I cut those columns loose to keep things manageable. A great <a href="https://www.youtube.com/watch?v=QZ0DtNFdDko">video</a> explains this whole dimensionality problem if you’re interested in the deeper details.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MP9HA3ULPV9HEG9_NmopeQ.png" /><figcaption>Code snap for checking null and unique values</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/396/1*Ni_uCSJdHYPp-24IhH07Sg.png" /><figcaption>Output for the value counts method</figcaption></figure><p>Next up, I dove into those numeric columns to figure out which ones would help my regression model. I ran a quick pandas <em>describe </em>method to get the basic stats and see what I was working with. After eyeballing the numbers, I decided not to bother with scaling or normalizing the data. Why? The ranges across features weren’t that different from each other — no column was way out of whack compared to the others. I was also keeping an eye out for outliers, and the stats summary wasn’t throwing up any red flags. But you know me — I don’t just trust the numbers without seeing them visually. So I threw together some Kernel Density Plots using <em>Seaborn</em> on a subplot to see the distributions. Sometimes your eyes catch things the stats miss, right? This just confirmed what I suspected — the data was pretty “well-behaved” without any crazy values throwing things off.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pszAiRIyhFABku-Mmw352Q.png" /><figcaption>Code snap for kernel density plots using subplots</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4ylMejWH3CTy4lpgUVL11A.png" /></figure><p>To wrap up my exploration, I wanted to see how everything connected, so I whipped up a few visualization heavy-hitters — you know, the classics: a pair plot, correlation matrix, and a linear model plot. Used Seaborn’s <em>pairplot</em> to see all those relationships in one go, then made a heatmap for the correlation matrix to get those nice color-coded numbers. Both plots told me the same story — the “length of membership” column was seriously tight with our target variable, the “Yearly Amount Spent.” That correlation was jumping off the chart! But hey, I reminded myself that just because two things move together doesn’t mean one causes the other. Still, it was worth exploring further, right? So as a final check, I threw together a linear model plot with Seaborn’s <em>lmplot</em> to see that line of best fit running through the data. Pretty convincing visual that made me feel good about using membership length as my main feature for the simple linear regression. Sometimes the best features just jump right out at you when you let the visuals do the talking!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qETDAaxXjYapOIa5bY3ZHA.png" /><figcaption>The pair plot for the columns</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*3C-VxaWjxb6Fc65JzrZuFA.png" /><figcaption>The heat map graph for the correlation matrix</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BTo0IeP9cMSG_HI5qwy3-w.png" /><figcaption>Code snap for the linear model plot for the simple linear regression model</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/489/1*XY3g1qqCUQNw51BJUOge3Q.png" /><figcaption>The linear model plot for the simple linear regression model</figcaption></figure><p>I cleaned up the dataset after all that exploration, dropping those columns I knew wouldn’t help the model. Just used the pandas’ <em>drop</em> method, setting the <em>inplace </em>attribute to “True” to get rid of them without creating a whole new dataframe. No point keeping extra baggage around, right? Simple and straight to the point — just axed the unnecessary stuff and kept moving with the same dataframe I was already working with.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aiWWs1TyTdUy9w0XyI014w.png" /><figcaption>Code snap for dropping columns</figcaption></figure><p>After cleaning up my dataset, I built two different regression models — kept things interesting that way. First came the simple linear regression using just that one standout feature I found, then a multiple regression with several predictors. For the simple model, I separated things nice and clean — put my single feature into dataframe X and the target variable into y. Classic split. Then I used scikit-learn’s train_test_split to carve out training and testing portions from both datasets. You know the drill — need some data to build the model and separate data to test if it works. Nothing fancy, just the standard preparation before teaching the model what’s what.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TqBr451dFdMaeNEpbPKqoA.png" /><figcaption>Code snap for feature selection for the simple linear regression model</figcaption></figure><p>After splitting my data, I set up a benchmark to measure my model against. You’ve gotta have something to compare to, right? So I calculated a mean baseline — the average of all target values. I took the mean of the target variable, duplicated it into a list the same length as my training data, and used that as my “dumb” prediction. Then I measured how far off this baseline was by calculating the mean absolute error between these constant predictions and the actual training values. The baseline score came in around 63.546. Since we’re talking about error here, smaller is better — a perfect score would be zero. This gave me a reference point — my actual model needed to beat this number to prove it was learning something useful from the data. Otherwise, why bother with all this machine learning complexity if just guessing the average would be about as good?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-S6s8DQ5ifCb64hsJ916ag.png" /><figcaption>Code snap for calculating the mean baseline</figcaption></figure><p>I created my baseline, then got to the fun part — building the actual model. I instantiated a basic linear regression model and fed it the training data. Just to be safe, I used scikit-learn’s <em>check_is_fitted</em> method to confirm the model learned something from the data. The first test was using the model on the same training data it had learned from. Got a mean absolute error of 37.326 and an R-squared of 0.670. Definitely better than the baseline’s 63.546 error, but still not amazing. Then came the real test — how would it perform on the unseen test data? The numbers told the story: mean absolute error of 37.836 and R-squared of 0.563. Both metrics got a bit worse compared to the training data. The error went up slightly and the R-squared dropped more noticeably. So what does this tell us? The model was doing better than just guessing the average, but that error was still pretty large. And the fact that performance dropped on test data suggested it wasn’t generalizing super well. Not terrible, but not what I’d call efficient. The single-feature approach wasn’t cutting it — time to try something more sophisticated.</p><p>If you’re not familiar with these evaluation metrics, here’s a quick rundown: Mean Absolute Error (MAE) is exactly what it sounds like — it measures how far off your predictions are from the actual values, on average. Think of it as the typical prediction error in the same units as your target variable. Lower is better, with zero being perfect predictions. R-squared (R²) tells a different story — it shows how much of the variation in your target variable your model explains. It ranges from 0 to 1, where 1 means your model perfectly explains all the variation, and 0 means it’s no better than just guessing the average. In real-world terms, our model with an R² of 0.563 on test data means it’s explaining about 56.3% of the variation in yearly spending. These two metrics together give you a pretty good picture of how well your model is performing. The MAE tells you about the size of your errors, while R² tells you how much of the pattern in the data your model has captured. For serious model evaluation, you’d want to look at both rather than just one or the other. This <a href="https://www.youtube.com/watch?v=w1RySTwe6Dk">video</a> explains more about what Mean Absolute Error and R Squared entail.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_oKyCcXkH5jz1dDKtVvHMw.png" /><figcaption>Code snap for calculating the mean absolute error for the training data</figcaption></figure><p>Moving on, I went to build the multiple linear regression model, that is, I tried to predict the target variable, the yearly amount spent, but this time, using multiple features rather than just one. The target column was the last, so separating it from the features wasn’t too hard. I used my knowledge of indexing to extract the features and target into 2 separate variables. After separating them, I checked the shape to ensure they were in the correct dimensions before proceeding to split them into the training and testing compartments using the <em>train_test_split</em> method from the <em>sklearn</em> library.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EINl1BRE2TkFx5LD4Fhs9A.png" /><figcaption>Code snap for selecting features for the multiple regression model</figcaption></figure><p>After my first model fell short, I went through the same setup process for the multiple regression. Started by calculating that mean baseline again, which was still 63.546 — makes sense since I’m using the same target variable. Next, I plugged my training data into a fresh linear model, but this time with all my selected features instead of just one. I made sure to double-check with scikit-learn’s <em>check_is_fitted</em> method that the model took in the data properly. You know how it is — always better to verify than assume something worked when it didn’t. Just that extra bit of code to make sure we’re on solid ground before moving forward with predictions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mKkJ4wwsheTTqj1uOGM0TA.png" /><figcaption>Code snap for calculating the baseline error for the multiple linear regression model</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*38lynLCzjtMe2F8nPRjJeg.png" /><figcaption>Code snap for instantiating and fitting the linear regression model</figcaption></figure><p>After I had my multiple regression model trained, I tested its performance on the training data. The results were eye-opening — a mean absolute error of just 7.72! That’s dramatically better than the simple model’s 37.326 and miles ahead of our baseline of 63.546. I wanted to see this improvement for myself, so I ran some predictions using the X_train data and compared them to the actual y_train values. The predictions were strikingly close to the real numbers — always a good sign. Then I dug into what the model learned by looking at the equation it built. The intercept came in at -1044.26, and each feature got its own coefficient: 25.60, 38.79, 0.31, and 61.90. These numbers tell us exactly how each feature contributes to the prediction , some having much stronger effects than others. With these values, I could write out the complete regression equation and make predictions by hand if I wanted to. The huge improvement in error showed just how much better multiple features were at capturing the patterns in this particular dataset compared to using just one feature.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pJHTZI2f2TiGD_e2Y7R-bg.png" /><figcaption>Code snap for calculating the mean absolute error for the multiple linear regression model using the training data</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*17yzH8Usj2mYEweWIwSQEQ.png" /><figcaption>Code snap for getting the intercept</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FgMf9a2oR_UOoAAta6wadA.png" /><figcaption>Code snap for getting the coefficients</figcaption></figure><p>When I ran the model on my test data, the strong performance continued. The mean absolute error was only 8.56, which is just slightly higher than on the training data. And check this out — the R-squared hit 0.977! That means the model was explaining almost 98% of the variation in the target variable with our test data. To visualize how well this model was performing, I created residual plots and probability plots using <em>Pylab</em> from the stats library. The residual plot showed the errors were nicely scattered around zero without obvious patterns — exactly what you want to see. And that probability plot confirmed our residuals were following a normal distribution pretty closely, right along that diagonal line. These visualizations backed up what the metrics were telling us — the multiple regression model was fitting the data extremely well, much better than our simple single-feature approach. Adding those extra features captured important relationships that a single variable just couldn’t handle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GR3m96y3Rxf6G1zQx1OsaQ.png" /><figcaption>Code snap for the multiple linear regression equation</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*eS4etaBv4g187_t3J-4KkQ.png" /><figcaption>Code snap for the residual plot</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*efibWQjNR_xCrq8AnrjdFw.png" /><figcaption>The residual plot</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dtnm4z-mFqZBCt57kb1-2g.png" /><figcaption>Code snap for the probability plot</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*7q2KJKbqG6zCzbIgFsSO7Q.png" /><figcaption>The probability plot</figcaption></figure><p>For the finishing touch, I built an interactive dashboard so anyone could play with the model and make predictions on the fly. The first step was creating a prediction function to handle the math behind the scenes. Then I tapped into the <em>iPywidgets</em> library, using the interact function and FloatSlider objects to create those adjustable sliders. The result was pretty sweet — a hands-on tool where you could drag sliders for each feature and instantly see how it would affect the yearly spending prediction. Much more engaging than just looking at static results! It let me (and would let others) experiment with different combinations of values and see the model’s response in real time. Great way to put the model to practical use and get a feel for how each factor influences the final prediction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aEL6hz4sJvUCeHspQMH7Xw.png" /><figcaption>Code snap for the prediction function for the multiple regression model</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3GR_LeF6mlJ2PzYhOdDapQ.png" /><figcaption>Code snap for the interactive dashboard</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C5_n2vRsEYRSsBqDoazSEg.gif" /><figcaption>The interactive dashboard</figcaption></figure><p>To wrap up, here’s what I’ve learned about building solid linear regression models: Start with all your essential libraries, then get your hands dirty with the data cleaning and preprocessing. Be ruthless about cutting unnecessary features while hanging onto the ones that matter. And watch out for those high-dimensional features — they’ll trip you up faster than you think! Don’t skimp on evaluation either. Those metrics tell you whether your model is any good, and you need to know how to read them properly. My experience showed just how much difference multiple features made compared to a single predictor — the numbers don’t lie! I’m sure there are other techniques I haven’t covered here. If you’ve got some tricks up your sleeve or approaches that have worked well for you, drop them in the comments! I’m always looking to learn new methods.</p><p>Building a successful linear regression comes down to understanding the fundamentals, being meticulous with your data preparation, building your model carefully, and thoroughly evaluating how it performs. Master these elements and you’ll be extracting meaningful insights and making data-backed decisions in no time. If this helped you out, hit that clap button below and share it with anyone else who might benefit. You can also follow me on <a href="https://www.linkedin.com/in/oluwasotun-ogunjirin-603388181/">LinkedIn</a> and <a href="https://github.com/Sotun-1010">GitHub</a>. You can also check out my other <a href="https://medium.com/@oluwasotunogunjirin">articles</a> and <a href="https://oglytics.webflow.io/projects">website</a> for more articles and projects like this. Thank you, and stay lit.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e9f3e7a8e56d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[1990’s Classic Hits Analysis with Python]]></title>
            <link>https://medium.com/@oluwasotunogunjirin/1990s-classic-hits-analysis-with-python-a793137475bc?source=rss-3409c505df74------2</link>
            <guid isPermaLink="false">https://medium.com/p/a793137475bc</guid>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[spotify]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-analysis]]></category>
            <dc:creator><![CDATA[Ogunjirin Oluwasotun Goodness ]]></dc:creator>
            <pubDate>Sat, 01 Mar 2025 18:05:46 GMT</pubDate>
            <atom:updated>2025-03-01T18:31:14.377Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wEce4d8ptqeaJtRe" /><figcaption>Photo by <a href="https://unsplash.com/@introspectivedsgn?utm_source=medium&amp;utm_medium=referral">Erik Mclean</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Hello everyone!!! I analysed a 1990’s Classic Hits dataset from kaggle with Python. This <a href="https://www.kaggle.com/datasets/thebumpkin/1990s-classic-hits-with-spotify-data">dataset</a> has 980 iconic 1990s singles performed by 536 different artists. Each track in the collection includes full Spotify audio feature data, allowing for in-depth analysis of musical properties like danceability, energy, key, loudness, mode, speechiness, acousticness, instrumentality, liveness, valence, tempo, and length. I decided to hop on it and I’ve come to share my insights with you. Just in case you missed the first instance of the link, here is the <a href="https://www.kaggle.com/datasets/thebumpkin/1990s-classic-hits-with-spotify-data">dataset</a> and also a link to the code uploaded on <a href="https://github.com/Sotun-1010/1990s_classic_hits_analysis">GitHub</a>.</p><p>After downloading the data from Kaggle, I created a Python notebook file on JupyterLab and imported the modules I’d be using in the analysis. I used the Pandas, Matplotlib, Seaborn, and Plotly libraries for data wrangling and visualization. After that, I loaded the data using the pandas <em>read_csv</em> function, examined the first five rows, and looked over the data to brainstorm potential questions to investigate. This technique helped me absorb and digest the facts much more effectively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*t8gPAT0ERev11k2ivAdOjA.png" /><figcaption>Importing the libraries</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/1*qiO47MvBzTpgh4ORxtsyug.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*AQOXaJG-ZjMr7EyOcICqFw.png" /><figcaption>Loading the data and the questions to analyse</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5XDQgWv2vkvsK9nX3Yx6BQ.png" /><figcaption>Preview of the data</figcaption></figure><p>Moving on, I dug further into the data to check for null values, shape, column information, and numeric column descriptions using the pandas library’s <em>is_null</em>, <em>shape</em>, <em>info</em>, and <em>describe</em> methods, respectively. It turned out that the data had no null values and was suitable for analysis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/1*CO8eZekAuilvDTUH2uVQGg.png" /><figcaption>Code snap for checking for the shape, null values, column information and description of the data</figcaption></figure><p>Now onto the first question I investigated. The investigation concerned the musicians’ popularity. This was an intriguing one since I couldn’t decide whether to use the average or sum aggregation method when combining the data. I chose the sum aggregation because it appeared to fit into the picture much better, namely that a single artist who releases a successful song once cannot be claimed to be more popular than an artist who has released numerous hit songs. The first thing I did was group the data by the artist column using pandas’ <em>groupby()</em> function and aggregated it by the total of their popularity score.</p><p>I made sure to sort the values in descending order using pandas <em>sort_values() </em>function before proceeding to visualise in a seaborn bar plot. I also made a few tweaks to the plot by placing the the data labels at the edge of each bar, slanting the x-axis labels by -60 degrees and inserting the title all for the purpose of making the plot look cleaner. Some of the most popular artists in the 1990’s were Mariah Carey, Madonna, and Janet Jackson just to mention a few.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wpjPPlU7n1RikfdAtIkWxQ.png" /><figcaption>Code Snap for the top 10 most popular artists</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1017/1*MtD2s4ftt2GLGPtZeC6y_g.png" /><figcaption>Top 10 most popular artists</figcaption></figure><p>Furthermore, I went ahead to assess the most popular tracks from the dataset. I achieved this by indexing the artist, track and popularity columns, sorted them by the popularity column and picked the first 10 rows. After this, I used a <em>plotly</em> interactive bar plot, to visualise the data, including the corresponding artist’s name in the hover data and also making sure to tweak the other plot elements where necessary. Turns out the most popular track was a song titled “cruel summer” by Ace of Base.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dGsw70FznJXgR0huMFfeJQ.png" /><figcaption>Code Snap for the top 10 most popular tracks</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_Ea5ffaerEehoJjWJqSHtA.png" /><figcaption>Top 10 most popular tracks</figcaption></figure><p>Next up, I checked for the loudest musicians and tracks similar to what I did for the popularity column. For the loudest tracks, I sorted the data by the Loudness column in descending order after which I plotted an interactive horizontal bar plot with the <em>plotly</em> library. I also included the artist’s name in the hover data and adjusted the chart to show the loudness in decibels as data labels. The loudest track was “Hazard” by Richard Marx.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PPbMMP_WzGqyCePEjQoL2Q.png" /><figcaption>Code snap for top 10 loudest tracks</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*HQyyMPoMWbjtorqFhNpobw.png" /><figcaption>Top 10 loudest tracks</figcaption></figure><p>For the question of the loudest musicians or artists, I grouped the data by the artist column, aggregated the data by the mean of the loudness column, sorted it in descending order and selected the first ten rows. I then used python’s <em>Seaborn </em>library to visualize the data in an horizontal bar plot too. I made sure to set the figure size and also adjusted the data labels in decibels to appear at the edge of each bar. I also changed the orientation of the x-axis with <em>Seaborn’s</em> <em>invert_xaxis()</em> function to make the plot much easier to read. The loudest artist turned out to be Mase featuring Total with an average loudness score of -2.053 decibels.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f6tkP-t2ttG7wDcmg-5XlQ.png" /><figcaption>Code snap for top 10 loudest artists</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G7ZEvssCwguZDMPGW7njMg.png" /><figcaption>Top 10 Loudest artists</figcaption></figure><p>As I spent more time on the dataset, I started to wonder if there were any relationships between any of the columns, so, for a quick preview I did a pairplot. What I could observe from the pairplot was that the energy and loudness columns seemed to have some form of positive relationship and as well as the acousticness and energy columns having some form of negative relationship. After the generating the pairplot, I digged in deeper by generating a correlation matrix and visualizing it in a heatmap plot with the seaborn library and annotated it, enabling me to see the various correlation scores between every column and classify them accordingly. The correlation groups ranged from moderate negative correlation groups to Moderate positive correlation groups. There wasn’t any evidence of any strong correlation in the dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*ZemjHaF8i05Vjvchn9B7uA.png" /><figcaption>Code snap for the pair plot</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gv4v3A0s4jAdpWfADrk4qQ.png" /><figcaption>Pair plot of the dataset</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eG8ggFeKzKl_LKtJfzIfoQ.png" /><figcaption>Code Snap for the correlation matrix and heatmap plot</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/1*K037nPetLGodi2H_5bzEAg.png" /><figcaption>Heatmap plot for the correlation matrix</figcaption></figure><p>After visualising the correlation matrix, I went on to dig deeper into some of the moderate correlations. The first one was checking the relationship between the acousticness and energy which had a high moderate negative correlation score, which was almost a strong negative correlation. I created a subplot with the <em>subplot</em> function and had two visualisations in it, one for the scatter plot and another for the regression plot. I did this to see the possibility of creating a simple linear model for the two columns. Ialso related the correlation score to realistic instances as we sometimes see that acoustic songs tend to have a low energy which explains the moderate negative correlation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S3IW45v3Wv5vHUuUswH1Nw.png" /><figcaption>Code Snap for the scatter plot and regression plot: Acousticness vs Energy</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V-ZgE3mN8dh3N8l8IaCrlQ.png" /><figcaption>Scatter plot and regression plot: Acousticness vs Energy</figcaption></figure><p>The next one was the relationship between the loudness and energy column which had a high moderate positive correlation score, this time around, almost a strong positive correlation. I created a subplot and had two visualisations as well, one for the scatter plot and another for the regression plot. Once again, I did this to see the possibility of creating a simple linear model for the two columns and I also related the correlation score to realistic instances as we sometimes see that loud songs tend to have a high energy which explains the moderate positive correlation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0rG3Eb1PW-U4JKOVRKI3Yw.png" /><figcaption>Code Snap for the scatter plot and regression plot: Loudness vs Energy</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XKrfSNuIYH-sUaakDSW3yQ.png" /><figcaption>Scatter plot and regression plot: Acousticness vs Energy</figcaption></figure><p>I also checked the relationship of the other columns with moderate correlations starting with the negative ones. I used a scatter plot to visualise the relationship between the acousticness and loudness column and also the instrumentalness and loudness column. From the scatter plots, there was no clear or definite relationship between the columns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iS123Tc1H6g7OozEzElzaA.png" /><figcaption>Code Snap for the scatter plot of Acousticness vs Loudness and Instrumentalness vs Loudness</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*euEG-UX0HlFZ1EP2ZWyI7Q.png" /><figcaption>Subplots of the scatter plot of Acousticness vs Loudness and Instrumentalness vs Loudness</figcaption></figure><p>Moving on, I checked the relationship of the columns with moderate positive correlations; The valence and danceability columns and the valence and energy columns. Again, from the scatter plot there was no clear or definite relationship between the columns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6FeyqAFa-9YByaFqUCZ7aA.png" /><figcaption>Code Snap for the scatter plot of Valence vs Danceability and Valence vs Energy</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mWDTt_NnmM-W8FV5SdDUAw.png" /><figcaption>Subplots of the scatter plot of Valence vs Danceability and Valence vs Energy</figcaption></figure><p>Moving ahead, I thought of other insights that might be derived from the dataset and I came up with the idea of checking for the frequency of the keys used alongside some other ideas. For the frequency of the keys used on the tracks, I converted the numeric key column to the actual notes in music by mapping the values from a dictionary. I created the dictionary which I was going to map from first, and chained some methods together to achieve the data frame I was going to visualize. I grouped the data by the different keys and aggregated them with the count of the tracks first, reset the indexes and renamed the column that had the counts from track to number of tracks. Furthermore, I went on to replace the numeric key values by mapping their corresponding values from the dictionary I had already created. I also came up with two alternative methods on how to achieve the same result described above and I have included the code snap below. Feel free to check them out. To wrap this section up, I visualised the data using a bar plot from pandas plot function which runs with the matplotlib library. I didn’t forget to place the data labels on the edge of the bars and also included and adjusted other necessary attributes for the plot. From the plot, some of the most used keys during the 90’s was C#, G, A, F and C and the least used was E flat.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CWEj0lZZiH3XNfHORg5HcQ.png" /><figcaption>code snap for the most used keys</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LGmh5zzoUIv-w10y_twbxA.png" /><figcaption>Alternative approach of getting the dataframe for the most used keys 1</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JkhgTzExKVi3izMSbDbHeg.png" /><figcaption>Alternative approach of getting the dataframe for the most used keys 2</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1009/1*Q7fVBOmmmY1Kl9X6JH_0CA.png" /><figcaption>Bar plot for the most used keys</figcaption></figure><p>Still on the analysis, I also came up with the Idea of checking for the top 10 longest and shortest songs in the dataset, but there was one issue, the duration column was not in a numeric format which meant I had to convert the datatype to a numeric one. I did this by creating a function which was going take in the dataframe, split the duration column by a delimiter (in this case a colon) and then convert the time values to seconds. After creating the function, I then called the function on the copied dataframe and I was able to achieve my result. I then went on ahead to sort the values by the total seconds column in descending order which I had just created and picking out the first ten rows which indicated the longest songs. I then visualised the result in a plotly bar plot using the total seconds as the data labels. The longest song was “Feels so good” by Mase which lasted 582 seconds.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O6uUtAO27UfcKTBNHu4m0w.png" /><figcaption>Code snap for the top 10 longest songs</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/304/1*UPIVZFlt-YAToQofWaenRg.png" /><figcaption>result of the split duration function</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/917/1*PK2nJHG47bYcfHGNMty4Pg.png" /><figcaption>Top 10 longest tracks</figcaption></figure><p>I also followed the same approach for the top 10 shortest songs. I sorted the values by the total seconds column but this time in ascending order and went on to select the first ten rows which represented the shortest songs. I also visualised the result in a plotly bar plot using the total seconds as the data labels and including the corresponding artist as the hover data. The shortest song was “Theme from Mission: Impossible” by Adam Clayton and Larry Mullen which lasted 51 seconds. I made a GIF of the interactive plot below too for us to see it in real time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cPSo_8pfzMuOBxpYKu8Osw.png" /><figcaption>Code snap for for the top 10 shortest songs</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yMvM8mrHg6vudI94gw5jJw.gif" /><figcaption>Shortest Tracks</figcaption></figure><p>I also checked for the most used time signature and found that to be the 4/4 time signature. I achieved this by using the value_counts method on the time signature which returned a count for each time signature, I then normalized the values and rounded them up to 3 decimal places, before passing it into a dataframe, renaming the proportion column and resetting the index of the dataframe. I used a seaborn bar plot to visualize the result also adjusting necessary attributes of the plot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UZBt30EmLzOFEWh98pjO1Q.png" /><figcaption>Code snap for the relative frequency of the time signatures</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qQnxed2tPSBNLLoIy37nBw.png" /><figcaption>Bar plot for the relative frequency of the time signatures</figcaption></figure><p>Lastly, I checked for the fastest and slowest songs. I did this by sorting the data by the tempo in a descending manner for the fastest songs and in an ascending manner for the slowest songs, then, went on to visualise the results in a plotly bar plot including the artists in the hover data and showing the tempo as data labels at the edge of their corresponding bars. The fastest song was “I’ll be there for you/You’re all I need to get” by Method man ft Mary J. Bilge with a tempo of approximately 220 and the slowest song was “Tennessee” by Arrested Development with a tempo of 48.7.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k-k9pzw3jKOnwtgK3kXpQg.png" /><figcaption>Code snap for the top 10 fastest songs</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vp4Qw2Dliq0H2KTKcVu9vw.png" /><figcaption>The top 10 fastest songs</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0szq3i4zIoTx__DIdtVAKQ.png" /><figcaption>Code snap for the top 10 slowest songs</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cXPhX5bOeneCIm9PVDtQBA.png" /><figcaption>The top 10 slowest songs</figcaption></figure><p>If you enjoyed reading this, kindly clap for this post a gazillion times, leave a comment, and share to your friends. Moreover, I’m open to feedback and suggestions on the work I have done, therefore if you have suggestions or you want to learn how to do something like this, feel free to reach out to me concerning these either in the comments on any of my socials, I’d love to hear them. Until next time, stay lit.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a793137475bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Upskilling Journey]]></title>
            <link>https://medium.com/@oluwasotunogunjirin/my-upskilling-journey-d6b12afee000?source=rss-3409c505df74------2</link>
            <guid isPermaLink="false">https://medium.com/p/d6b12afee000</guid>
            <category><![CDATA[careers]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[health]]></category>
            <category><![CDATA[upskilling]]></category>
            <dc:creator><![CDATA[Ogunjirin Oluwasotun Goodness ]]></dc:creator>
            <pubDate>Tue, 11 Feb 2025 10:57:22 GMT</pubDate>
            <atom:updated>2025-02-11T11:11:36.223Z</atom:updated>
            <content:encoded><![CDATA[<h3>My Upskilling Journey for the past six months</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*L_IKpki3fV-TKaOj" /><figcaption>Photo by <a href="https://unsplash.com/@uns__nstudio?utm_source=medium&amp;utm_medium=referral">Unseen Studio</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Upskilling oneself has to be one of the most challenging yet exciting things to do. For the past six months I took some time off working on personal projects to upskill myself in certain areas for my career and excitingly, it has been quite the ride.</p><p>Around July last year, after switching my tech path to fully focus on Data Science and rounding up my introduction to data science course with kibo school, I worked on a few personal projects but I also felt the need to upskill myself too, so this led me to take some courses and I’m glad I did.</p><p>I also enrolled in the Applied Data Science Lab by WorldQuant University first and I must say it was quite educative and insightful. I passed the admissions test and was able to finish the course in about 5 months. It exposed me to a lot of data analytics concepts from simple linear models, to classification models, and the Garch model amongst others. I also added to my knowledge of data wrangling and how to access data from various sources and in different formats like SQL, JSON, MongoDB and also from APIs. The program had 8 modules and those modules had their projects from building several models to performing A/B testing. These 8 projects helped me practice what I had learnt but I know I’d still have to practice more to fully master it. Overall, it as a 10/10 learning experience and I am already practicing what I have learnt, and would probably share it in a few days after this post.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*WR3gImE8Ww-d6Jeqgsacnw.png" /></figure><p>Another course I took was the ALX AI Career Essentials (AiCE) course and I was running it side by side with the Applied Data Science course. The AI Career Essentials (AiCE) program was a 6-week training program designed to equip young professionals with essential AI literacy and 21st-century skills. The program focused on enhancing our understanding and application of AI tools in professional settings. I gained a lot of experience using sophisticated AI tools like ChatGPT, some other generative AI tools, Midjourney, Udio, etc. mirroring contemporary workplace challenges. The program also enabled me to blend theoretical knowledge with practical applications through real-world simulations and hands-on projects and I can say my productivity went up after this course. I’d recommend this course to anybody that’s interested in upskilling and boosting their productivity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4hdHzz5ltdY_yDtXSZ1USA.gif" /></figure><p>Lastly, in January, I took the “Tata Data Visualization: Empowering Business with Effective Insights Job Simulation” course on Forage which is a 3–4 hour self-paced online program that provides participants with insights into how data visualization can be used to make informed business decisions. I learnt how to think from the perspective of business leaders to analyze data more effectively, choose the right visuals for a given scenario, create effective visuals, and communicate insights and analysis. The program design enabled me to simulate a real-world work experience at Tata Insights and Quants, one of Tata Group’s companies. I also completed tasks guided by pre-recorded videos and example answers from the Tata team. The program made me to become a much more efficient and productive data analyst.</p><p>Before I forget too, I also took part in the Mckinsey Forward program. The program has helped me develop essential workplace skills like adaptability, communication, problem-solving, and digital proficiency. This is also a great program to take part of if you’re looking to upskill yourself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*e4_jMZYtQiEiKJnV4p7DAg.png" /></figure><p>Now that I have taken these courses, I’d be applying the knowledge I’ve gained in building personal projects and also working on my future goal of integrating AI in the health sector especially, and other sectors by the way. I have also added these credentials to my LinkedIn profile and I’m happy I took time to upskill. Moving forward, I’d be looking out for Job and Internship opportunities alongside Master’s degree opportunities in Public Health (Biostatistics/Health Informatics preferrably), BioInformatics, or Data Science, in order to actualize my future goals, which I hope to achieve in the next few years. Thank you and please stay tuned for my next post.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d6b12afee000" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Weather Data Analysis Project]]></title>
            <link>https://medium.com/@oluwasotunogunjirin/my-weather-data-analysis-project-94046a69336c?source=rss-3409c505df74------2</link>
            <guid isPermaLink="false">https://medium.com/p/94046a69336c</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[growth-mindset]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Ogunjirin Oluwasotun Goodness ]]></dc:creator>
            <pubDate>Thu, 18 Jul 2024 11:58:28 GMT</pubDate>
            <atom:updated>2024-07-18T11:58:28.418Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>My Weather Data Analysis Project</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lUfnwRymkbGxpGgk" /><figcaption>Photo by <a href="https://unsplash.com/@lukaszlada?utm_source=medium&amp;utm_medium=referral">Łukasz Łada</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Hello everyone, I am here again to share one of the projects I’ve worked on in the past few weeks. I am slowly moving up in my AI/ML journey, which is quite a good thing I guess? While I’m still in my learning phase, I’ve decided to do some analytic projects using various tools. In my<a href="https://medium.com/@oluwasotunogunjirin/my-trykibo-final-project-15c1f10fcb48"> last post</a>, I used a sheet tool (Google sheets) and Google looker studio for the analysis, but for this, I used Python in analysing the data. I also think I’d be spending much more time analysing data with python in the future because it’s quite fascinating for me and I enjoy it a lot. Come along with me now as I share my latest project with you.</p><p>In this project, I analysed one of the trending datasets on <a href="https://www.kaggle.com/">Kaggle</a> about weather type classification. The dataset is synthetically generated to mimic weather data for classification tasks. The dataset contained 13,200 rows and 11 columns. The columns involved data on humidity, temperature, atmospheric pressure, cloud cover and some other weather data metrics containing values having string, float and integer data types. The link to the dataset can be found <a href="https://www.kaggle.com/datasets/nikhil7280/weather-type-classification/data">here</a>. Also, I uploaded the code to my Github which can be found <a href="https://github.com/Sotun-1010/Weather_Data_Analysis">here</a>.</p><p>I used Jupyterlab as my IDE because I find it easy to navigate through files back and forth using the file menu and the left side pane. I started by importing the required python libraries like pandas, <em>numpy</em>, <em>matplotlib</em> and <em>seaborn</em>. After importing the libraries, I used the pandas <em>read_csv()</em> function to load the CSV data into a data frame and also checked through some rows of the data just to get a quick overview of the data using the <em>head()</em>, <em>tail()</em> and <em>sample()</em> functions available in the Pandas library.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*asBABdi_5Tr_dFRajUdIkQ.png" /><figcaption>Importing the required libraries</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pSmUULTdQV3rCZfXLKl5AQ.png" /><figcaption>Loading and checking through the data</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0AwNGdCvkZmLLI1Fm5Eu1w.png" /><figcaption>A sample view of the data</figcaption></figure><p>After checking through, I proceeded to check the shape and also check the entire data for null values in which I found none. I did this by using <em>is_null()</em> function to check for null values before aggregating the sum of null values twice with the <em>sum()</em> function to give a single output of the null values. Then, I used the <em>describe()</em> function to generate the descriptive statistics of the data. It generated the count, mean, standard deviation, minimum, <em>etc.</em> of all the numeric columns present in the data. I then proceeded to print out only the average, minimum and maximum values for each of the columns as I concluded they’d be the most important things to note from the descriptive statistics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ECQLNzL9TtrrGXdoaVTnpQ.png" /><figcaption>Checking the shape of the data and checking for null values</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BJlpZtvkYVT1Tp3Wpem5sw.png" /><figcaption>Generating the descriptive statistics for the data</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/1*COKg9M2BJHF-KA0Q3tol7w.png" /><figcaption>The result of the described data</figcaption></figure><p>Moving on, I decided to group the numeric weather metric columns based on the string data type columns. That is I grouped various weather metrics like temperature, humidity, atmospheric pressure, <em>etc</em>. by the weather type, cloud cover, season and location. For the metrics grouped by weather type, I grouped the metrics by either rainy, cloudy, snowy or sunny weather. For the metrics grouped by cloud cover, I grouped the metrics by either clear, cloudy, overcast or partly cloudy cloud covers. For the metrics grouped by season, I grouped the metrics by either autumn, spring, summer or winter seasons and finally for the metrics grouped by location, I grouped the metrics by either coastal, inland or mountain locations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XLjINd34tK1lV5_ExPFRnw.png" /><figcaption>Grouping temperature and humidity values by weather type</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yErTNoW-NJYGJRVJ2ACh_g.png" /><figcaption>Grouping temperature and humidity values by season</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qEgceEiaRDButERgT0ePVQ.png" /><figcaption>Grouping temperature and humidity values by location</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k0kLxZ3p2wwUj7yo52YA-w.png" /><figcaption>Grouping temperature and humidity values by cloud cover</figcaption></figure><p>After the grouping, I proceeded to visualize the data using the <em>matplotlib</em> and <em>seaborn</em> libraries. I initiated the visualization by using a <em>seaborn kdeplot() </em>function to show the distribution of the numeric weather metrics. I could have opted for a histogram plot using the <em>seaborn</em> <em>histplot()</em> function but I felt visualizing its relative frequency or density rather than just the counts made more sense to interpret.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oZTijoYZHbZa49sF905_Dw.png" /><figcaption>Generating the kde plots for the various weather metrics</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*jiQCUTJtVxQ0apme7AouPQ.png" /><figcaption>Result of the precipitation distribution</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*R6VVy7pXbEY4B7_1qjlYag.png" /><figcaption>Result of the temperature distribution</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*8dIhUMsCJgq5xwG5EFeVqQ.png" /><figcaption>Result of the atmospheric pressure distribution</figcaption></figure><p>After plotting for the various the distributions, I proceeded to visualize each average, minimum and maximum numeric weather metrics by weather type, location, temperature and season in the same plot. I was able to achieve this layout using the <em>subplot()</em> function in the <em>matplotlib </em>library. I also noticed that based on the groups, some metrics had more elevations and depressions which might indicate which metric to look out for based on the groups. For example, the temperature data had more change in terms of elevations and depressions in the weather type groups and Cloud cover groups other than the season and location group. This might indicate one should place more emphasis on temperature changes based on the cloud cover and weather type, other than location or season.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FXWUUlEG-SWfybjxACDudg.png" /><figcaption>Generating the plot for temperature based on various groups on different subplots</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xThF5WpDqYhT2BFT1gxiFQ.png" /><figcaption>Results of the temperature data groups on the subplots</figcaption></figure><p>Also, I thought of the possibility that one might be able to predict some labels based on some features in the data so I plotted a heatmap graph after deriving the correlation matrix of the numeric weather metric columns using the <em>corr()</em> function available in the <em>pandas</em> library. I also tried to plot some regression plots to see the best line of fit for some of the plots. Some of the metrics with strong correlations turned out to be a mess so I opted for some lower ones. I used a <em>jointplot()</em> function to generate a linear regression plot and to also show the spread of the data. It turned out that a linear regression model might not be the best method to use in this case, I also experimented with a logistic regression plot and there wasn’t much difference. Perhaps, some other machine learning models might be best for this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dOTL72w55ASJVbIIq7XcSg.png" /><figcaption>Generating the correlation matrix</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*3K2oMdwphX6GXGQqg0D-NA.png" /><figcaption>The heatmap display of the correlation matrix</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BrrKnJPHwNdnJjdVMqGBvw.png" /><figcaption>Generating the regression plot between temperature and visibility</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*EmMSjAo-FBwD8FID_2IcrQ.png" /><figcaption>Result of the linear regression plot between temperature and visibility</figcaption></figure><p>Another thing I did, was to take a random sample size of the data before plotting. I opted for a sample size of 1000 which I thought was reasonable to an extent, although, the graph was much clearer, my conclusion still remained that other models would give a much better result than the regression model and as the data description, it would be more suitable to use classification methods.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6aj1HKwQ-xGkqzstdDVmWw.png" /><figcaption>Generating the joint plot for the sample size data</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*8efyTywJk1xCIgJEdSgAsg.png" /><figcaption>Result of the sample size data regression plot between temperature and visibility</figcaption></figure><p>This concludes my analysis and I hope it was an interesting read. I am open to any feedback or suggestions on what I could have analysed, other approaches I could have applied, or insights I might have overlooked. I’d continue to learn and discover more about AI/ML but this project was an interesting one and I will continue to do more of this(with python especially) while I continue my journey. Stay tuned!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94046a69336c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My tryKibo Final Project]]></title>
            <link>https://medium.com/@oluwasotunogunjirin/my-trykibo-final-project-15c1f10fcb48?source=rss-3409c505df74------2</link>
            <guid isPermaLink="false">https://medium.com/p/15c1f10fcb48</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[google-sheets]]></category>
            <category><![CDATA[google-looker-studio]]></category>
            <dc:creator><![CDATA[Ogunjirin Oluwasotun Goodness ]]></dc:creator>
            <pubDate>Thu, 27 Jun 2024 09:49:12 GMT</pubDate>
            <atom:updated>2024-06-27T09:49:12.672Z</atom:updated>
            <content:encoded><![CDATA[<h3>My tryKibo Final Project: The beginning of my analytics journey</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZPvhQXjvTq5-fIGb" /></figure><p>I am happy to have completed my data analysis course with tryKibo having embarked on my AI/ML journey. I had the opportunity to join a 5 week boot camp to learn about data analysis, hosted by Kibo School. The whole learning phase was fun for me, from the live sessions to the assignments, weekly projects, and even down to the final project which I’d also be talking about in the next section of this post. We were exposed to various resources from working with sheets, to working with SQL and databases, and also visualizing data with google looker studio. I also learnt about the basics of Machine Learning and Artificial Intelligence before the final project. For the final project, I analyzed a <a href="https://www.kaggle.com/">kaggle</a> dataset on electric power consumption in Tetouan, Morocco for the year 2017 (<a href="https://www.kaggle.com/datasets/fedesoriano/electric-power-consumption">Find the dataset here</a>). The aim of this project was to majorly study the trend of power consumption in different zones in Tetouan while also considering the weather conditions.</p><p>The tools I used in this analysis include Google sheets, and Google Looker Studio. The data consisted of 9 columns and 52,417 rows of data spanning from 01-Jan-2017 to 30-Dec-2017 with date and float data types. The analysis also showed that for the 3 zones in Tetouan, in the year 2017, the average temperature in Tetouan was 18.8 degrees Celsius, the average humidity 68.3% and the average wind speed, 2.0 meters per second.</p><p>The steps I used in this analysis include:</p><p>Cleaning: There was little cleaning to do for this dataset as most of the data was in the correct format. The only thing left to do was to check for blanks and other rows that might not have the correct format, and also have a quick overview of some of the columns in the dataset. With the filter feature available in Google sheets, I was able to check through the 9 columns and found no blank values or data with wrong formats. After checking through, I decided to alter the order of the date column. I simply changed the format from MM/DD/YYYY to DD/MM/YYYY for easier readability from my perspective.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l4bIYd8SjpOJTbBjafU-sw.png" /><figcaption>A quick check through the data</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WptA40wukLGLFCJYwnVZrw.png" /><figcaption>Filtering the data and checking for blanks</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8cM-9-9najJ2KaFDObzZgQ.png" /><figcaption>Checking for the summary of a column</figcaption></figure><p>Visualisation: I visualized the data using google looker studio. After linking the dataset from google sheets, I cross checked the data to ensure they still maintained the same data type, before proceeding to generate various charts. Some of the charts I utilized were the scorecard, the column chart and the time series chart. I also added a date control so as to visualize the data for a specific time frame. Also the dashboard is 100% interactive and dynamic. Here is the link to the <a href="https://lookerstudio.google.com/u/2/reporting/a50ce1a7-77c8-42d8-af3e-7257971a1da1/page/QyO2D">visualization</a> if you wish to check it out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L_C1yLows0fbP966gnewKQ.png" /><figcaption>The Dashboard</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n7vBGnqcpbJU8PLHsDVxfw.png" /><figcaption>Date range control on the dashboard</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uPcPQAZzwNKhdd7cnjc2_A.png" /><figcaption>A glimpse of the dashboard’s interactivity and dynamism</figcaption></figure><p>After the analysis, I was able to discover that Zone 1 consumed the highest amount of power for the year while Zone 3 consumed the lowest. Also power consumption was high sometime around august across all the zones and low sometimes around January and December. This also prompted me to further analysis by checking the power consumption by quarters and the results showed that the total power consumption was highest in the third quarter and lowest in the fourth quarter. Also, the general diffuse flow trend, a key indicator for power leakage, showed that power leakage must have been quite high around June. So 3 key takeaways from this is that:</p><blockquote>Power consumption appears to be highest in Q3 (August — October) and lowest in Q1 (January — March) and there is a general upward trend throughout the year.</blockquote><blockquote>Power consumption in other zones seems to follow a similar pattern, especially to zone 1, with a peak in Q3 and a low point in Q1. However, the fluctuations seem to be less pronounced than in zone 1.</blockquote><blockquote>Power consumption in zone 3 appears to be more consistent throughout the year, with a slight increase in Q3.</blockquote><p>With these findings it is possible make informed decisions on whether to increase power production in any of the Zones deemed fit and also trace causes to low and high power consumptions and also high potential power leakages during some specific periods. Also it might be possible the weather conditions might have also affected the power consumption, but this wasn’t visualized because there was a huge disparity between the electric power consumption and the weather metrics which doesn’t allow the graph to depict all the selected metrics on the same graph. If I would have to visualize this I would need to convert the power consumption values into compact forms rather than their full forms, hence, the reason for not visualizing it but it might be a useful insight for those hoping to also work on the data. Also more suggestions and perspectives are welcome and I’d be posting more of some analysis in the coming days, stay tuned.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=15c1f10fcb48" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>