<?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 Aung Kyaw Win on Medium]]></title>
        <description><![CDATA[Stories by Aung Kyaw Win on Medium]]></description>
        <link>https://medium.com/@akw9785?source=rss-7ae2f5f31eaf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*uECHjxOSTiHvt6O3Ld5ykA.jpeg</url>
            <title>Stories by Aung Kyaw Win on Medium</title>
            <link>https://medium.com/@akw9785?source=rss-7ae2f5f31eaf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 04:49:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@akw9785/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[Building a Financial Tweets Sentiment Classifier With Hugging Face Transformers]]></title>
            <link>https://medium.com/@akw9785/building-a-financial-tweets-sentiment-classifier-with-hugging-face-transformers-e8abdbffce6e?source=rss-7ae2f5f31eaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8abdbffce6e</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[pytorch]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[hugging-face]]></category>
            <dc:creator><![CDATA[Aung Kyaw Win]]></dc:creator>
            <pubDate>Fri, 04 Jul 2025 16:16:57 GMT</pubDate>
            <atom:updated>2025-07-04T16:18:49.264Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EDBbg4Uzcl0RN3IX" /><figcaption>Photo by <a href="https://unsplash.com/@alexbemore?utm_source=medium&amp;utm_medium=referral">Alexander Shatov</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>In the fast-paced world of finance, sentiment analysis of tweets and news can provide a valuable edge. Inspired by this, I set out to build a robust sentiment classifier for financial tweets using state-of-the-art NLP tools. In this article, I’ll walk you through how I built a financial sentiment classifier using Hugging Face Transformers, fine-tuned on a specialized dataset, and deployed it with a Gradio web interface.</p><h3>Why Financial Sentiment Analysis?</h3><p>Financial markets are heavily influenced by public sentiment. Tweets and news headlines can move stocks in minutes. Automating the process of gauging sentiment — bullish, bearish, or neutral — can help traders, analysts, and researchers make better decisions.</p><h3><strong>The Tech Stack</strong></h3><ul><li><strong>Python</strong>: The language of choice for data science and NLP.</li><li><strong>Hugging Face Transformers</strong>: For leveraging powerful pre-trained language models.</li><li><strong>Datasets Library</strong>: To easily load and preprocess data.</li><li><strong>Gradio</strong>: For building a simple, interactive web app.</li><li><strong>PyTorch</strong>: As the deep learning backend.</li></ul><h3>Step 1: Getting the Data</h3><p>I used the <a href="https://huggingface.co/datasets/TimKoornstra/financial-tweets-sentiment">TimKoornstra/financial-tweets-sentiment</a> dataset from Hugging Face, which contains thousands of labeled financial tweets. Loading it was as simple as:</p><pre>from datasets import load_dataset<br>df = load_dataset(&quot;TimKoornstra/financial-tweets-sentiment&quot;)</pre><h3>Step 2: Preprocessing</h3><p>I renamed the sentiment column label and split the data into training, validation, and test sets. Tokenization was handled by AutoTokenizer from Hugging Face, using the cardiffnlp/twitter-roberta-base-sentiment-latest model as a starting point.</p><pre>from transformers import AutoTokenizer<br>tokenizer = AutoTokenizer.from_pretrained(&quot;cardiffnlp/twitter-roberta-base-sentiment-latest&quot;)<br><br>def preprocess_function(examples):<br>    return tokenizer(examples[&quot;tweet&quot;], truncation=True, max_length=512, padding=&quot;max_length&quot;)<br><br>tokenized_dataset = dataset.map(preprocess_function, batched=True)</pre><h3>Step 3: Fine-Tuning the Model</h3><p>I fine-tuned the RoBERTa model for sequence classification, mapping the sentiment labels to integers. Training was managed with Hugging Face’s Trainer API, making it easy to set up evaluation, logging, and checkpointing.</p><pre>from transformers import AutoModelForSequenceClassification, TrainingArguments, Trainer<br><br>model = AutoModelForSequenceClassification.from_pretrained(<br>    &quot;cardiffnlp/twitter-roberta-base-sentiment-latest&quot;,<br>    num_labels=3,<br>    id2label=id2label,<br>    label2id=label2id<br>)<br><br>training_args = TrainingArguments(<br>    output_dir=&quot;finsent_model&quot;,<br>    learning_rate=2e-5,<br>    per_device_train_batch_size=16,<br>    num_train_epochs=1,<br>    evaluation_strategy=&quot;epoch&quot;,<br>    save_strategy=&quot;epoch&quot;,<br>    load_best_model_at_end=True,<br>    push_to_hub=True,<br>)<br><br>trainer = Trainer(<br>    model=model,<br>    args=training_args,<br>    train_dataset=tokenized_dataset[&quot;train&quot;],<br>    eval_dataset=tokenized_dataset[&quot;test&quot;],<br>    tokenizer=tokenizer,<br>    compute_metrics=compute_metrics,<br>)<br><br>trainer.train()</pre><h3>Step 4: Pushing to Hugging Face Hub</h3><p>After training, I pushed the model to the Hugging Face Hub for easy sharing and deployment:</p><pre>trainer.push_to_hub(&quot;aungkyawwin/finsent_model&quot;)</pre><h3>Step 5: Building an Interactive Web App</h3><p>To make the model accessible, I built a Gradio web app. With just a few lines of code, anyone can input a tweet and get an instant sentiment prediction.</p><pre>import gradio as gr<br>from transformers import pipeline<br><br>pipe = pipeline(&#39;text-classification&#39;, model=&#39;aungkyawwin/finsent_model&#39;)<br><br>def classify_text(input_text):<br>    return pipe(input_text)<br><br>interface = gr.Interface(<br>    fn=classify_text,<br>    inputs=&quot;text&quot;,<br>    outputs=&quot;json&quot;,<br>    title=&quot;Know Whether The Latest Financial Tweet Will Burn a Hole In Your Pocket or Get You a Boatload of Money&quot;,<br>    description=&quot;This is a text classification model based on a pretrained version of RoBERTa, fine-tuned on a financial sentiment analysis dataset. It predicts the sentiment of financial tweets as bullish, bearish, or neutral.&quot;,<br>)<br><br>interface.launch()</pre><p>The model can now classify financial tweets as <strong>bullish</strong>, <strong>bearish</strong>, or <strong>neutral</strong> with impressive accuracy. The Gradio interface makes it easy for anyone to try out the model in real time.</p><p>Building a financial sentiment classifier is now easier than ever, thanks to the Hugging Face ecosystem. With just a few lines of code, you can go from raw data to a deployed web app. If you’re interested in the code, check out the <a href="https://huggingface.co/spaces/aungkyawwin/financial_tweets_classification/tree/main">HuggingFace repository</a> or try the <a href="https://huggingface.co/spaces/aungkyawwin/financial_tweets_classification">Gradio demo</a>.</p><p><em>Thanks for reading! If you found this helpful, follow me for more NLP and AI projects.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8abdbffce6e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Built a Candlestick Pattern Image Classifier With Deep Learning]]></title>
            <link>https://medium.com/@akw9785/how-i-built-a-candlestick-pattern-image-classifier-with-deep-learning-5179d1646228?source=rss-7ae2f5f31eaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/5179d1646228</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[stocks]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[hugging-face]]></category>
            <category><![CDATA[finance]]></category>
            <dc:creator><![CDATA[Aung Kyaw Win]]></dc:creator>
            <pubDate>Tue, 01 Jul 2025 13:19:43 GMT</pubDate>
            <atom:updated>2025-07-01T13:23:14.972Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*L5wJSQJkRCqhCU6a" /><figcaption>Photo by <a href="https://unsplash.com/@nampoh?utm_source=medium&amp;utm_medium=referral">Maxim Hopman</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><blockquote><strong>“Can a machine recognize candlestick patterns as well as a seasoned trader?”</strong></blockquote><p>That question sparked my journey into combining deep learning with financial chart analysis. I’ll take you through every step of building a candlestick pattern image classifier — from data wrangling and model design to deploying a live demo on Hugging Face Spaces. Whether you’re a trader, data scientist, or just curious about AI in finance, I hope you’ll find this story both educational and inspiring.</p><h3><strong>Why Candlestick Patterns?</strong></h3><p>Candlestick charts are a staple in technical analysis, used by traders worldwide to interpret price actions and forecast market moves. Each pattern — like the Doji, Hammer, or Engulfing — tells a story about market sentiment.</p><p>But here’s the <strong><em>catch:</em></strong></p><p><strong>Recognizing these patterns is subjective and time-consuming.</strong></p><p>What if we could automate this process with AI, making it faster and more consistent?</p><h3>Project Overview</h3><p><strong>My goal:</strong></p><p>Build a deep learning model that can classify candlestick patterns from chart images, and make it accessible to everyone via a web app.</p><p><strong>Tech Stack:</strong></p><ul><li>PyTorch for model development</li><li>Pandas, Numpy, and scikit-learn for data handling</li><li>mplfinance for chart generation</li><li>Gradio for the web interface</li><li>Hugging Face Spaces for deployment</li></ul><h3>Data Collection &amp; Preparation</h3><ol><li><strong>Gather Historical Data</strong></li></ol><p>I started by downloading historical price data for popular stocks like Apple, Amazon, and Netflix.</p><p><strong>Tools used:</strong> yfinance, pandas</p><p><strong>2. Generating Candlestick Data</strong></p><p>Using mplfinance, I scripted the generation of thousands of candlestick chart images, each labeled with its corresponding pattern.</p><p>This step was crucial — real-world data is messy, and I wanted the model to learn from realistic scenarios.</p><p><strong>3. Organizing the Dataset</strong></p><p>The project directory was structured for clarity and scalability:</p><pre>├── Charts &amp; Labels/       # Raw chart images and their labels<br>├── Dataset/              # Processed dataset for training<br>├── Dataset Generators/   # Scripts for data preparation<br>│   ├── apple_processor.py<br>│   ├── amazon_processor.py<br>│   ├── netflix_processor.py<br>│   ├── rename_and_combine.py<br>│   ├── total_label_counter.py<br>│   └── train_test_split.py<br>├── model/                # Model training and evaluation<br>│   └── Candlestick_Pytorch_version.ipynb<br>├── image_crop.py         # Image preprocessing utility<br>└── requirements.txt      # Project dependencies</pre><p>4. <strong>Preprocessing</strong></p><p>To ensure consistency, I wrote an image_crop.py utility to crop and standardize images. This helped the model focus on the relevant chart area and ignore unnecessary noise.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*TzKedAffyyFn4p8qWFTL_g.png" /><figcaption>Before Running the Crop Script</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*MZCdXXU_8BQhPZQ4nrj0Ew.png" /><figcaption>After Running the Crop Script</figcaption></figure><h3><strong>Model Design and Training</strong></h3><ol><li><strong>Choosing the Right Model</strong></li></ol><p>I experimented with several convolutional neural network (CNN) architectures. After some trial and error, I settled on a custom Vision Transformer that balanced accuracy and speed.</p><p><strong>2. Training the Model</strong></p><p>Since candlestick patterns can have different meanings if they are rotated, flipped, or colors are changed, I didn’t do any data augmentation during the training process.</p><p>To make the model robust, I used:</p><ul><li><strong>Loss Function: </strong>Cross-entropy loss for multi-class classification</li><li><strong>Optimizer:</strong> Adam, with learning rate scheduling</li></ul><p><strong>3. Evaluation</strong></p><p>I split the data into training, validation, and test sets. The model achieved strong accuracy on uncess data, correctly identifying patterns like Doji, Hammer, and Engulfing.</p><pre>Epoch 1/20<br>  Train Loss: 0.4507<br>  Val Loss:   0.4272<br>  Val F1:     0.6842<br>New best model saved<br>Epoch 2/20<br>  Train Loss: 0.4224<br>  Val Loss:   0.4253<br>  Val F1:     0.7186<br>New best model saved<br>Epoch 3/20<br>  Train Loss: 0.3990<br>  Val Loss:   0.4125<br>  Val F1:     0.6844<br>Patience: 1/3<br>Epoch 4/20<br>  Train Loss: 0.3712<br>  Val Loss:   0.4191<br>  Val F1:     0.7173<br>Patience: 2/3<br>Epoch 5/20<br>  Train Loss: 0.3068<br>  Val Loss:   0.4330<br>  Val F1:     0.7301<br>New best model saved<br>Epoch 6/20<br>  Train Loss: 0.2342<br>  Val Loss:   0.4546<br>  Val F1:     0.7248<br>Patience: 1/3<br>Epoch 7/20<br>  Train Loss: 0.1521<br>  Val Loss:   0.4923<br>  Val F1:     0.7247<br>Patience: 2/3<br>Epoch 8/20<br>  Train Loss: 0.0913<br>  Val Loss:   0.5393<br>  Val F1:     0.7135<br>Patience: 3/3<br>Early stopping triggered.</pre><h3><strong>Building the Interface App</strong></h3><ol><li><strong>Why Hugging Face Spaces</strong></li></ol><p>Hugging Face Spaces offers free, easy-to-use hosting for ML demos. With just a few clicks, I deployed my Gradio app and model weights, making the classifier available to anyone with a browser.</p><ul><li><strong>Live Demo:</strong></li></ul><p><a href="https://huggingface.co/spaces/aungkyawwin/Candlestick_Pattern">Candlestick Pattern Classifier on Hugging Face Spaces</a></p><ul><li><strong>Model Weights:</strong></li></ul><p><a href="https://github.com/AungKyawWin20/Candlestick-Pattern-Image-Classification.git">Hugging Face Model Repo</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ffz5iLITsqnbjcNlDUvNpg.png" /><figcaption>Screenshot of the Hugging Face Space Page</figcaption></figure><h3>Challenges &amp; Lessons Learned</h3><ol><li><strong>Data Quality Matters</strong></li></ol><p>Garbage in, garbage out. Clean, well-labeled images made a huge difference in model performance.</p><p><strong>2. Simplicity Wins</strong></p><p>A straightforward custom Vision Transformer performed surprisingly well. Sometimes, less is more.</p><p>3. <strong>Deployment is Easier Than Ever</strong></p><p>With Gradio and Hugging Face Spaces, sharing your ML project with the world is just a few lines of code away.</p><p><strong>4. Real-World Data is Messy</strong></p><p>Financial data is full of quirks — missing values, outliers, and unexpected patterns. Handling these gracefully was key.</p><h3>Try It Yourself!</h3><p><strong>Want to see it in action?</strong></p><p>Upload your own candlestick chart image and get a prediction:</p><p><a href="https://huggingface.co/spaces/aungkyawwin/Candlestick_Pattern">Candlestick Pattern Classifier On Hugging Face Spaces</a></p><h3>Conclusion &amp; Next Steps</h3><p>Building this project was a fantastic learning experience, blending data science, deep learning, and web deployment.</p><p><strong>Next steps:</strong></p><ul><li>Expand to more candlestick patterns</li><li>Improve model robustness with more diverse data and imbalanced data</li><li>Integrate with real-time trading tools</li></ul><p>If you’re interested in the code, check out the GitHub repo!</p><p>Contributions and feedback are always welcome!</p><p><em>Thanks for reading! If you enjoyed this, follow me for more ML and trading projects. Feel free to reach out with questions or suggestions.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5179d1646228" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The AI-Powered Map to Your Customers’ Hearts (and Wallets) ~ Stop Guessing, Start Growing]]></title>
            <link>https://medium.com/@akw9785/the-ai-powered-map-to-your-customers-hearts-and-wallets-stop-guessing-start-growing-05344085c06a?source=rss-7ae2f5f31eaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/05344085c06a</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[customer-segmentation]]></category>
            <category><![CDATA[clustering]]></category>
            <dc:creator><![CDATA[Aung Kyaw Win]]></dc:creator>
            <pubDate>Sun, 22 Jun 2025 08:11:08 GMT</pubDate>
            <atom:updated>2025-06-22T08:28:51.483Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong>From Blind Spots to Breakthroughs: My Journey Building a Customer Segmentation Project Using Python</strong></blockquote><p>Imagine Sarah, a marketing manager at a buzzing e-commerce platform. She’s brilliant, dedicated, and constantly churning out new campaigns. Yet, beneath the surface, a nagging doubt persists: <em>Is anyone truly listening?</em> She sends out dazzling promotions, but the conversion rates are lukewarm. It feels like she’s meticulously crafting love letters and sending them to an entire city, hoping one lands on the right doorstep.</p><p>She yearns to know: Who are her rockstar customers, spending big and buying often? Who are her loyal regulars, deserving of exclusive appreciation? And those elusive “discount coupon junkies” — how can she engage them without cannibalizing profits from her full-price buyers? The cold, hard truth? Without a true understanding of the customer, every marketing dollar risks being a shot in the dark, and every product recommendation, an irrelevant guess.</p><p>This universal business pain point — the frustrating anonymity of a customer base — is exactly what drove me to build this project: a modern machine learning pipeline for <strong>Customer Segmentation</strong>. It’s not just about data; it’s about transforming a chaotic sea of transactions into a crystal-clear map, guiding businesses straight to their customers’ hearts and, yes, their wallets.</p><h3><strong>The Secret Language of Purchases: Unlocking RFMT</strong></h3><p>We all do it unconsciously. You meet someone new, and over time, your brain begins to build a profile. You learn their interests, their habits, what makes them tick. You tailor your conversations, your jokes, even your gift choices. That’s your brain segmenting your social circle!</p><p>Now, imagine doing that for thousands of customers. Impossible, right? Not with <strong>RFMT (Recency, Frequency, Monetary, Interpurchase Time) analysis</strong>. This isn’t just data; it’s the <strong>secret language of your customers’ purchasing behavior</strong>.</p><ul><li><strong>Recency:</strong> How recently did they grace your store with a purchase? This tells you about their current engagement — hot on the trail or cooling off?</li><li><strong>Frequency:</strong> How often do they come back for more? This unveils their loyalty — are they a fleeting fling or a committed relationship?</li><li><strong>Monetary:</strong> How much treasure do they leave behind? This highlights their value — are they window shoppers or your personal goldmine?</li><li><strong>Interpurchase Time: </strong>How long a customer has been with the business? Longer tenure, longer customer relationship!</li></ul><p>Combine these simple yet profound metrics with advanced features like average basket size, and suddenly, every customer ID transforms from a number into a rich, detailed story. You’re not just looking at transactions; you’re deciphering their habits, their desires, their unspoken needs.</p><h3>The Quest for Clarity: Choosing the Right Clustering Lens</h3><p>Once we’ve translated purchasing behavior into RFMT features, the next critical step is to group these customer profiles into meaningful segments. This is where <strong>clustering algorithms</strong> come into play, acting like different lenses through which to view your customer landscape.</p><p>My journey involved exploring several powerful techniques to find the absolute best fit for retail customer data:</p><ul><li><strong>K-Means Clustering:</strong> A classic, known for its efficiency and ability to create clear, spherical clusters.</li><li><strong>HDBSCAN:</strong> A density-based algorithm, great for finding clusters of varying shapes and densities, and identifying outliers.</li><li><strong>Gaussian Mixture Models (GMM):</strong> A probabilistic approach, allowing customers to belong to multiple clusters with varying probabilities, offering a more nuanced view.</li></ul><p>After rigorous analysis and comparison, evaluating factors like cluster interpretability, distinctiveness, and the actionability of the resulting segments, one clear winner emerged for this specific retail dataset: <strong>K-Means Clustering</strong>. You can explore the evaluation metrics of the different clustering algorithms in detail in the GitHub repo linked below.</p><p>It consistently provided the most intuitive, actionable, and business-relevant customer groups. The clarity K-Means offered was paramount, directly translating into marketing strategies that were easy to understand and implement.</p><p>To pinpoint the optimal number of segments (k), I utilized the <strong>Elbow Method</strong>. This technique helped me visually identify the point of diminishing returns, where adding more clusters no longer significantly improved the model fit, ensuring we captured just the right amount of granularity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*ujNexHlkhRpwMmi6CmqmVA.png" /></figure><h3>Meet the Crew: Giving Your Customers a Personality!</h3><p>Armed with RFMT insights and the power of K-Means, generic customer IDs coalesce into distinct, actionable customer personalities. No more generic campaigns! Now, you can greet each customer with a message tailored just for them.</p><p>Here’s how my customer segmentation map helps businesses connect on a deeper level:</p><ul><li><strong>👑 The Royal Regals:</strong> These are your loyal monarchs, purchasing frequently, spending generously, and coming back often. They deserve the red carpet treatment: exclusive previews, personalized concierge service, and loyalty rewards that make them feel like royalty.</li><li><strong>🛒 The Steady Shoppers:</strong> Your reliable backbone. They’re consistent and appreciate thoughtful recommendations that align with their past purchases. Nurture them with relevant content and occasional thank-you offers.</li><li><strong>🚀 The Fresh Faces:</strong> Just discovered your brand! These excited newcomers are ripe for engagement. Welcome them with open arms, provide helpful guides, and make that crucial second purchase as enticing as possible.</li><li><strong>⏳ The Fading Friends:</strong> Once active, now silent. These are your “at-risk” customers. They need a warm, personalized reminder of what they’re missing, perhaps a special offer to rekindle the flame before they fade away entirely.</li><li><strong>💰 The Deal Mavens:</strong> These savvy shoppers live for discounts. Target them with flash sales, bundle deals, and clearance promotions. Don’t waste your premium product budget on them; instead, direct them to offers that excite their inner bargain hunter.</li></ul><p>Imagine the strategic shift! Instead of blasting a “20% off everything” email to <em>everyone</em> (including your full-price loving Royals!), you can send an exclusive pre-sale invite to your <strong>Royal Regals</strong>, a “we miss you!” coupon to your <strong>Fading Friends</strong>, and a tailored product suggestion to your <strong>Steady Shoppers</strong>. This isn’t just smart marketing; it’s <strong>respectful, effective customer engagement.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*EcUgwRTfVOxwJS-OhZW_Yw.png" /></figure><h3>The Ultimate Superpower: Instant Insights with My Streamlit App</h3><p>Understanding these segments is a game-changer. But what if you could have these insights at your fingertips, literally? That was my driving force: to democratize this powerful analysis, making it accessible even to someone like Sarah, who lives and breathes marketing, not code.</p><p>Here’s my “secret sauce” revealed: The journey building this project wasn’t without its hurdles. Real-world sales data, unlike pristine Kaggle datasets, is messy. It reflects true customer behavior, which means an imbalance: naturally, there are many more “Steady Shoppers” than “Royal Regals.” While I experimented with complex techniques like oversampling, the most impactful solution turned out to be robust feature engineering and a streamlined pipeline that focused on practical, reliable segmentation, ensuring the tool works seamlessly in the messy reality of business.</p><p>And that’s precisely what the <strong>Streamlit Web App</strong> delivers.</p><p><strong>No coding. No complex setup. Just raw sales data to actionable customer intelligence in moments.</strong></p><p>Sarah, or any business owner, simply takes their sales data (exported from their POS system, ensuring consistent column names like InvoiceNo, CustomerID, Quantity, etc.) and uploads it to the app.</p><p>Behind the scenes, my robust pipeline, powered by the trained <strong>Random Forest classifier</strong> (for predicting new customer segments) and the <strong>K-Means model</strong>, springs to life:</p><ol><li>It expertly <strong>cleanses</strong> the raw data, handling inconsistencies.</li><li>It ingeniously <strong>engineers</strong> all those critical RFM and advanced features.</li><li>It then <strong>predicts</strong> the precise customer segment for <em>each and every customer</em>.</li></ol><p>And <strong>BOOM!</strong> Sarah can download a pristine CSV with each customer meticulously labeled by segment. Now, armed with this intelligence, she can launch hyper-targeted campaigns, predict churn, personalize product recommendations, and optimize marketing spend with surgical precision. This is the <strong>power of data, made effortless.</strong></p><h3>Beyond the Numbers: Building Unbreakable Customer Bonds</h3><p>This isn’t just a technical project; it’s a blueprint for a revolution in customer relationships. Implementing customer segmentation means:</p><ul><li><strong>Skyrocketing ROI:</strong> Every marketing dollar works harder, reaching the right person with the right message.</li><li><strong>Unrivaled Customer Retention:</strong> Proactively identify and re-engage customers before they leave, turning potential losses into loyal advocates.</li><li><strong>Authentic Personalization:</strong> Make customers feel seen, understood, and valued, fostering deeper brand loyalty.</li><li><strong>Smarter Business Decisions:</strong> From inventory to product development, every choice is informed by a deep understanding of your market.</li></ul><p>Building this project underscored a profound truth for me: the real value of data science lies not just in complex algorithms, but in transforming that complexity into <strong>simple, actionable insights</strong> that drive real-world business growth. It taught me invaluable lessons about handling real-world datasets, which are far messier than the curated ones often found on platforms like Kaggle. It’s about empowering businesses to stop guessing and start growing by truly listening to what their customers are telling them through their purchases.</p><h3>Ready to Claim Your Retail Superpower?</h3><p>If you’re a retail professional eager to unlock the secrets within your sales data or a fellow data enthusiast looking for a practical, impactful machine learning project, I invite you to explore the full code.</p><p>All the components, from data preprocessing and model training to the intuitive Streamlit app, are available on my GitHub:</p><p><a href="https://github.com/AungKyawWin20/Customer-Segmentation-Project"><strong>Aung Kyaw Win’s Customer Segmentation Project on GitHub</strong></a></p><p>Let’s transform retail, one precise segment, one happy customer, and one intelligent decision at a time!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=05344085c06a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Can AI Predict Your Next Purchase? My Flipkart Sentiment Analysis Project]]></title>
            <link>https://medium.com/@akw9785/can-ai-predict-your-next-purchase-my-flipkart-sentiment-analysis-project-de1001051c61?source=rss-7ae2f5f31eaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/de1001051c61</guid>
            <category><![CDATA[web-scraping-tools]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[sentiment-analysis]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[web-scraping]]></category>
            <dc:creator><![CDATA[Aung Kyaw Win]]></dc:creator>
            <pubDate>Thu, 19 Jun 2025 08:13:04 GMT</pubDate>
            <atom:updated>2025-06-19T08:13:04.517Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-GlreyfYtmRYTi2p" /><figcaption>Photo by <a href="https://unsplash.com/@ikukevk?utm_source=medium&amp;utm_medium=referral">Kevin Ku</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><blockquote>Web Scraping Flipkart &amp; Predicting Review Sentiment With Hugging Face</blockquote><p>In today’s data-driven e-commerce landscape, understanding customer sentiment and product performance is crucial for business success. As a data enthusiast, I embarked on a journey to build a comprehensive tool that combines web scraping and sentiment analysis to extract valuable insights from Flipkart’s product data. This project not only enhances my technical skills but also provides fascinating insights into customer behavior and market trends.</p><h3>The Business Value</h3><p>Before diving into the technical details, let’s understand why this project matters:</p><ol><li><strong>Market Intelligence:</strong> By analyzing product reviews and ratings across different categories, businesses can identify market trends and consumer preferences.</li><li><strong>Competitive Analysis:</strong> This tool helps understand how products perform relative to their competitors in terms of customer satisfaction.</li><li><strong>Product Development:</strong> Sentiment analysis of reviews provides actionable insights for product improvement.</li><li><strong>Customer Experience:</strong> Understanding customer pain points and satisfaction drivers helps in enhancing the overall shopping experience.</li></ol><h3>Technical Architecture</h3><ol><li><strong>Web Scraping Engine</strong></li></ol><p>The core of the project is a robust web scraping system built with Python and Selenium. Here’s what makes it special:</p><pre># Key features implemented<br>- Multi-threaded scraping (10 concurrent workers)<br>- Anti-detection mechanisms<br>- CAPTCHA handling<br>- Error recovery systems</pre><p>The scraping engine is designed to be:</p><ul><li><strong>Resilient: </strong>Handles network issues and CAPTCHAs gracefully</li><li><strong>Efficient: </strong>Uses parallel processing for faster data collection</li><li><strong>Ethical:</strong> Implements rate limiting and respects robots.txt</li></ul><p>You can find the complete implementation in my GitHub repository (link given at the end) where I’ve shared the full codebase along with detailed documentation.</p><p>2. <strong>Sentiment Analysis Pipeline</strong></p><p>For sentiment analysis, I used state-of-the-art transformer models:</p><pre># Technical implementation highlights<br>- Transformer-based sequence classification<br>- Batch processing for efficiency<br>- GPU acceleration support<br>- Comprehensive sentiment metrics</pre><h3>Key Learnings</h3><p><strong>Technical Insights</strong></p><ol><li><strong>Concurrency Management</strong></li></ol><ul><li>Learned to balance between speed and server load</li><li>Implemented effective thread pooling</li><li>Mastered browser automation best practices</li></ul><p>2. <strong>Data Processing</strong></p><ul><li>Developed efficient data cleaning pipelines</li><li>Created robust error-handling mechanisms</li><li>Optimized memory usage for large datasets</li></ul><p>3. <strong>Machine Learning</strong></p><ul><li>Gained hands-on experience with transformer models</li><li>Learned to optimize model performance</li><li>Understood the importance of data preprocessing</li></ul><p><strong>Business Insights</strong></p><ol><li><strong>Consumer Behavior</strong></li></ol><ul><li>Identified patterns in customer reviews</li><li>Understood category-specific sentiment trends</li><li>Discovered common pain points across products</li></ul><p>2. <strong>Market Trends</strong></p><ul><li>Observed price sensitivity patterns</li><li>Identified emerging product categories</li><li>Analyzed seasonal trends in customer sentiment</li></ul><h3>Challenges and Solutions</h3><ol><li><strong>Anti-Bot Measures</strong></li></ol><p><strong>Challenge: </strong>Modern e-commerce sites implement sophisticated anti-bot measures.</p><p><strong>Solution: </strong>Implemented a combination of:</p><ul><li>Random delays between requests</li><li>User-agent rotation</li><li>Window size simulation</li><li>Headless browser operation</li></ul><p>2. <strong>Data Quality</strong></p><p><strong>Challenges:</strong> Inconsistent and noisy review data.</p><p><strong>Solution:</strong> Developed:</p><ul><li>Text Cleaning Pipelines</li><li>Sentiment Normalization</li><li>Outlier Detection</li></ul><p>3. <strong>Performance</strong></p><p><strong>Challenge: </strong>Processing large volumes of data efficiently</p><p><strong>Solution: </strong>Implemented:</p><ul><li>Batch Processing</li><li>GPU Acceleration</li><li>Memory Optimization</li></ul><h3><strong>Ethical Considerations</strong></h3><p>It’s crucial to note that this project was developed strictly for educational purposes. When working with web scraping products, it’s <strong>essential</strong> to:</p><ol><li>Respect the website&#39;s terms of service</li><li>Implement proper rate limiting</li><li>Use data responsibly</li><li>Consider privacy implications</li><li>Follow ethical guidelines</li><li>Check robots.txt</li></ol><h3>Future Improvements</h3><ol><li><strong>Enhanced Analytics</strong></li></ol><ul><li>Implement topic modeling</li><li>Add competitor price tracking</li><li>Develop trend prediction models</li></ul><p>2. <strong>Technical Enhancements</strong></p><ul><li>Add real-time monitoring</li><li>Implement automated reporting</li><li>Enhance error recovery</li></ul><p>3. <strong>Business Features</strong></p><ul><li>Add market basket analysis</li><li>Implement price optimization suggestions</li><li>Develop competitor analysis tools</li></ul><p>This project was an incredible learning journey, combining web scraping, data processing, and machine learning. The insights gained have provided valuable lessons in both technical implementation and business analytics. While the tool itself is powerful, it’s important to remember that such tools should be used responsibly and ethically.</p><h3>Disclaimer</h3><p>This project was developed strictly for educational purposes. The web scraping implementation respects Flipkart’s terms of service and robots.txt. Users are responsible for ensuring compliance with applicable laws and terms of service when using similar tools.</p><p>Feel free to check out the GitHub repo with the codebase <a href="https://github.com/AungKyawWin20/Flipkart-Webscraping-Sentiment-Analysis.git">here!</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de1001051c61" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Choking on Air: How Data Can Help Delhi Breathe Again]]></title>
            <link>https://medium.com/@akw9785/choking-on-air-how-data-can-help-delhi-breathe-again-8aa5122d5d4d?source=rss-7ae2f5f31eaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/8aa5122d5d4d</guid>
            <category><![CDATA[storytelling]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-visualization]]></category>
            <dc:creator><![CDATA[Aung Kyaw Win]]></dc:creator>
            <pubDate>Tue, 10 Jun 2025 08:07:46 GMT</pubDate>
            <atom:updated>2025-06-10T09:00:01.025Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8LgVw7eMcaz0IGtr" /><figcaption>Photo by <a href="https://unsplash.com/@yashbhagat?utm_source=medium&amp;utm_medium=referral">Yash Bhagat</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><blockquote>In Delhi, the simple act of breathing has become hazardous</blockquote><p>Delhi’s air isn’t just hard to breathe — it’s become a headline. Each winter, a toxic haze settles over the city, sending AQI numbers into the red and residents into hospitals. It’s a crisis that comes back every year, and yet it feels like nothing changes. But what if data could help shift the narrative?</p><p>In this post, I dive into the intersection of air quality and civic responsibility — using real data, visual stories, and a healthy dose of concern — to ask: <strong><em>What’s really polluting Delhi’s air? Who’s at risk? And what can citizens actually do about it?</em></strong></p><h3>📊The Data That Speaks</h3><p>To understand Delhi’s air, I pulled together data from multiple publicly available data sources:</p><ul><li>AQI &amp; Pollutants: Daily PM2.5, PM10, NO2, SO2, and O3 levels from R.K. Puram monitoring stations</li><li>Satellite-based Stubble Burning Data: Seasonal fire events in Punjab and Haryana, courtesy of NASA FIRMS.</li><li>Vehicle Counts: How many and what types of vehicles are congesting Delhi’s roads, sourced from OpenCity.</li><li>Health Impacts: A powerful study on how children in Delhi are twice as likely to develop lower respiratory issues.</li></ul><p>My goal wasn’t just to find trends — it was <em>to connect the dots between environment, health, and human action.</em></p><h3>❄️Winter is Coming (With Pollution)</h3><p>Let’s start with the most visible villain: winter air.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3yfODcRXy5E0VVHrTaXBWA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VO1JhiT3-sSafP0iDZawSw.png" /></figure><p>In these visualizations, you’ll notice sharp spikes in PM.25 and PM 10 each year between <strong>October and February or March</strong>. Why? Enter: Stubble Burning.</p><h3>🔥Farms Far Away, Air Here Today</h3><p>Farmers in Punjab and Haryana often burn crop residues after harvest — a practice that’s fast, cheap, and devastating for Delhi’s air. Satellite data from NASA reveals a surge in fire events during October and November.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HgljOofkX_1G2gPdPzuQ_w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SQx3cmk5co1gtYX19q1kEw.png" /></figure><p>These fires align <strong>perfectly</strong> with AQI spikes in the capital. While farmers face real economic pressure, the environmental cost is being paid in Delhi’s lungs.</p><p>🚗 The Everyday Enemy: Vehicles</p><p>Not all pollution comes from outside Delhi. Much of it sits in traffic jams.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W7Xrp8wnDMV48OKG2tTeZQ.png" /></figure><p>Delhi has millions of registered vehicles. Two-wheelers dominate the scene, and many lack modern emission controls. While there’s been a dip post-2020, emissions from vehicles remain a <strong>year-round source </strong>of air pollution.</p><h3>🫁<strong>The Cost We Don’t See: Children’s Health</strong></h3><p>Perhaps the most heartbreaking part of this story: <strong><em>Delhi’s children are growing up with weaker lungs.</em></strong></p><p>A study by Siddique et al. (2010) found that <strong>children in Delhi are twice as likely to develop Lower Respiratory Symptoms</strong> compared to those in cleaner environments.</p><p>That’s not just data — it’s a public health emergency. And it’s once we can’t afford to normalize.</p><h3>❔So, What can We Do?</h3><p>Solving Delhi’s air crisis isn’t easy — but it’s not impossible either. Here’s what a civic-minded, data-driven approach might look like:</p><ol><li><strong>Support Farmers With Alternatives</strong></li></ol><p>Subsidize composting, promote bio-decomposers, and enforce burn bans with empathy, not punishment.</p><p>2. <strong>Demand Cleaner Transport</strong></p><p>Stricter vehicle emission laws, improved public transportation, and incentives for electric vehicles can significantly reduce urban pollution.</p><p>3. <strong>Empower Communities</strong></p><p>Urban greening, awareness campaigns, and citizen science initiatives (like AQI monitoring clubs) make clean air a shared mission.</p><p>4. <strong>Educate For Action</strong></p><p>When people understand the <strong><em>why</em></strong>, they care about the <strong><em>how. </em></strong>Let’s get pollution literacy into schools, homes, and policy halls.</p><h3>Why Civic Responsibility Matters</h3><p>No data point matters unless it leads to action. Clean air isn’t just a technical issue — it’s a shared moral and civic responsibility. If we treat every AQI report as background noise, we risk forgetting that it represents <strong>real harm </strong>to real people.</p><p>Data should make us smarter — but also braver. Braver to speak up, act out, and demand the breathable future Delhi deserves.</p><h3>Final Thoughts</h3><p>Delhi’s pollution problem is layered and persistent, but it isn’t unsolvable. What we need is more than outrage — we need engagement. We need citizens who see data not just as numbers but as <strong>stories — </strong>stories that demand a response.</p><blockquote>Check out my GitHub Repo to find out more about this data analysis project and to access the full interactive website containing the plots <a href="https://aungkyawwin20.github.io/Air-Quality-in-Delhi/">here</a>.</blockquote><h3>🔗References &amp; Data Sources</h3><ul><li>PM &amp; AQI Data: <a href="https://aqicn.org/city/delhi/r.k.-puram/">aqicn.org</a></li><li>Fire Maps: <a href="https://firms.modaps.eosdis.nasa.gov/">NASA FIRMS</a></li><li>Vehicle Stats: <a href="https://data.opencity.in/">OpenCity Data Portal</a></li><li>Health Study: Siddique et al.(2010), Air Quality Atmosphere &amp; Health</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8aa5122d5d4d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Hate Speech Detection Model: My Journey with ML and Web Development]]></title>
            <link>https://medium.com/@akw9785/building-a-hate-speech-detection-model-my-journey-with-ml-and-web-development-53dd32a926cc?source=rss-7ae2f5f31eaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/53dd32a926cc</guid>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[website]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[streamlit]]></category>
            <category><![CDATA[text-classification]]></category>
            <dc:creator><![CDATA[Aung Kyaw Win]]></dc:creator>
            <pubDate>Sat, 07 Jun 2025 06:06:22 GMT</pubDate>
            <atom:updated>2025-06-07T06:07:17.695Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IwT8r_E6JRKZkigt" /><figcaption>Photo by <a href="https://unsplash.com/@camstejim?utm_source=medium&amp;utm_medium=referral">camilo jimenez</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In this post, I’ll share my experience building a hate speech detection system using Python, from data processing to deployment, the whole machine learning pipeline. This project taught me valuable lessons about supervised machine learning, web development, and creating user-friendly interfaces.</p><h3>The Challenge</h3><p>Hate speech detection is a crucial problem in today’s digital world. I wanted to create a practical solution that could:</p><ul><li>Accurately identify hate speech</li><li>Be easily accessible through multiple interfaces</li><li>Process text in real-time as quickly as possible</li><li>Be deployable to production</li></ul><h3>Technical Stack</h3><pre>Backend: Python, Flask<br>Frontend: HTML/CSS, Streamlit<br>ML: scikit-learn, TF-IDF, Multinomial Naive Bayes<br>Database: CSV (Kaggle dataset)</pre><h3>The Development Process</h3><p>1. Data Preparation</p><p>I started with a Kaggle dataset containing examples of hate speech and non-hate speech.</p><p>2. Model Building</p><p>I chose TF-IDF with Multinomial Naive Bayes for its:</p><ul><li>Simplicity and interpretability</li><li>Good performance on text classification</li><li>Fast training and prediction times</li></ul><p>The model achieved an impressive 87% accuracy, which was notable for a baseline approach.</p><p>3. Creating Multiple Interfaces</p><p><strong>Web Interface (Flask)</strong></p><p>I learnt about routing, templates, and handling form submissions:</p><pre>@app.route(&#39;/predict&#39;, methods=[&#39;POST&#39;])<br>def predict():<br>    text = request.form[&#39;user_text&#39;]<br>    prediction = pipeline.predict([text])[0]<br>    return render_template(&#39;result.html&#39;, prediction=prediction)</pre><p><strong>Modern UI (Streamlit)</strong></p><p>Streamlit was a game-changer! It allowed me to create a beautiful interface with minimal code:</p><pre>st.title(&quot;🛡️ Hateful Speech Detection&quot;)<br>user_text = st.text_area(&quot;Type your sentence here:&quot;)<br>if st.button(&quot;Analyze&quot;):<br>    prediction = pipeline.predict([user_text])[0]</pre><h3>Key Learnings</h3><ol><li><strong>ML Pipeline Design</strong></li></ol><ul><li>The importance of preprocessing</li><li>Pipeline optimization</li><li>Model evaluation metrics</li></ul><p>2. <strong>Web Development</strong></p><ul><li>Frontend frameworks</li><li>User experience considerations</li></ul><p>3. <strong>Deployment</strong></p><ul><li>Environment management</li><li>Cloud deployment</li><li>Production considerations</li></ul><h3>Challenges Faced</h3><ol><li><strong>Model Accuracy</strong></li></ol><ul><li>Balancing precision and recall</li><li>Handling edge cases</li><li>Dealing with context dependency</li></ul><p><strong>2. Technical Integration</strong></p><ul><li>Connecting different components</li><li>Managing dependencies</li><li>Ensuring consistent behavior across interfaces</li></ul><p><strong>3. Deployment Issues</strong></p><ul><li>Path Management</li><li>Environment variables</li><li>Server configurations</li></ul><h3>Future Improvements</h3><ol><li>Implement BERT for better accuracy</li><li>Add emoji support</li><li>Create a feedback loop</li><li>Implement active learning</li></ol><h3>Looking back at where I started!</h3><p>When I first worked on this hate speech classification project using <strong>TF-IDF and Naive Bayes</strong>, it felt like a solid introduction to NLP and text classification. Since then, I’ve tackled much more complex models and advanced techniques — but I’ve realized that simpler methods still have their place.</p><p>Naïve Bayes might be “basic” compared to deep learning, but it has a way of <strong>surprising us with its effectiveness</strong>, especially in text classification tasks. This project helped me grasp key principles and gave me the foundation to build on. Looking back, it’s a reminder that every step, no matter how simple, adds to the journey!</p><p>Excited to share this as part of my learning process. If you’re new to NLP, don’t underestimate the power of starting small!</p><blockquote>Check out the Streamlit Web App <a href="https://hateful-speech-detection.streamlit.app/">Here</a>! The project is also open-source and available on my <a href="https://github.com/AungKyawWin20/Hateful_Speech_Detection.git">GitHub</a>, and feel free to contribute!</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=53dd32a926cc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Reels Recommendation System]]></title>
            <link>https://medium.com/@akw9785/building-a-reels-recommendation-system-81e4e46f557a?source=rss-7ae2f5f31eaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/81e4e46f557a</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[algorithms]]></category>
            <dc:creator><![CDATA[Aung Kyaw Win]]></dc:creator>
            <pubDate>Thu, 05 Jun 2025 14:20:24 GMT</pubDate>
            <atom:updated>2025-06-05T14:20:24.124Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2BPsTy3iSnYTLMTLcvvkrg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@maria_shalabaieva?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Mariia Shalabaieva</a> on <a href="https://unsplash.com/photos/a-group-of-different-social-media-logos-HBkpnDVc_Ic?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Unsplash</a></figcaption></figure><blockquote>A Deep Dive into Graph &amp; Hashmap-Based Personalization</blockquote><p>In today’s fast-paced world, where people are increasingly busy with their daily lives, finding time for entertainment and relaxation has become a challenge. Long-form content often feels like a commitment, leading to the explosive growth of short-form video platforms like Instagram Reels. These bite-sized videos serve as perfect stress relievers and quick getaways, offering instant entertainment in just a few seconds. This shift in content consumption patterns has made effective recommendation systems crucial for social media platforms to keep users engaged while respecting their time constraints.</p><p>In this post, I’ll walk you through my implementation of a recommendation system for Instagram Reels that combines multiple recommendation strategies to deliver personalized content, ensuring users can quickly find the most relevant and engaging short-form videos that match their interests and available time.</p><h3>Creating a Synthetic Dataset</h3><p>To test and develop the recommendation system, I created a synthetic dataset that mimics real Instagram Reels data. Here’s the details of my synthetic dataset:</p><pre># Key components of the synthetic dataset:<br><br># 1. User Data Generation<br>- 100 simulated users<br>- Each user follows 5-15 other users<br>- Users have 5-20 liked reels<br>- Users have 10-30 viewed reels<br><br># 2. Reels Data Generation<br>- 300 simulated reels<br>- Each reel has 1-3 random tags from categories like:<br>  - travel, food, coding, cooking<br>  - memes, anime, asian cuties<br>  - japanese songs<br>- Realistic engagement metrics:<br>  - Like counts: 0-1000<br>  - View counts: proportional to likes<br>- Timestamps within the last 30 days</pre><p>You can create this type of dataset using the data generation Python script (“simulated_dataset.py”) from my GitHub repo linked down below. The script will create two CSV files:</p><ul><li>“simulated_users.csv”: Contains user connections and interactions</li><li>“simulated_reels.csv”: Contains reel metadata and engagement metrics</li></ul><p>This synthetic dataset allows you to:</p><ul><li>Test the recommendation system without real user data</li><li>Experiment with different parameters</li><li>Understand the system’s behavior with controlled data</li><li>Develop and debug the algorithm safely</li></ul><h3>The Challenge</h3><p>Creating an effective recommendation system for Instagram Reels requires addressing several key challenges:</p><ul><li>Processing vast amounts of user interaction data</li><li>Balancing personalization with content discovery</li><li>Considering both social connections and content preferences</li><li>Providing explainable recommendations</li></ul><h3>The Solution: A Multi-Strategy Approach</h3><p>My implementation system employs four complementary strategies to generate personalized recommendations:</p><ol><li><strong>Graph-Based Social Recommendations</strong></li></ol><p>The system uses Instagram’s social graph to find relevant content through:</p><ul><li>Direct connections (users you follow)</li><li>Second-degree connections (users followed by people you follow)</li><li>Weighted scoring based on connection distance</li></ul><p>2. <strong>Content-Based Filtering</strong></p><p>Content recommendations are generated by analyzing:</p><ul><li>User’s liked reel tags</li><li>Tag frequency and preferences</li><li>Content similarity scoring</li></ul><p>3. <strong>Collaborative Filtering</strong></p><p>The system considers:</p><ul><li>User interaction patterns</li><li>Similar user preferences</li><li>Engagement metrics</li></ul><p>4. <strong>Popularity-Based Boosting</strong></p><p>Content popularity is factored in through:</p><ul><li>Like counts</li><li>View counts</li><li>Normalized popularity scoring</li></ul><h3><strong>Technical Implementation</strong></h3><p><strong>Core Data Structures</strong></p><p>This system uses an efficient data structure for quick lookups:</p><pre>user_liked_reels = {}      # User -&gt; Liked Reels<br>user_viewed_reels = {}     # User -&gt; Viewed Reels<br>user_follows = {}          # User -&gt; Followed Users<br>reel_tags = {}            # Reel -&gt; Tags<br>tag_reels = defaultdict(set)  # Tag -&gt; Reels<br>user_created_reels = defaultdict(set)  # User -&gt; Created Reels</pre><p><strong>Scoring Algorithm</strong></p><pre># Scoring weights:<br># - Direct connections: 3.0<br># - Second-degree connections: 1.5<br># - Tag matches: 2.0 * (tag_frequency/total_likes)<br># - Popularity: 0.0001 * (likes + 0.1 * views)</pre><h3>Key Features</h3><p><strong>1. Explainable Recommendations</strong></p><p>The system provides detailed explanations for each recommendation:</p><ul><li>Social connection reasons</li><li>Content preference matches</li><li>Popularity metrics</li></ul><p><strong>2. Interactive Interfaces</strong></p><p>Two user-friendly interfaces are available:</p><ul><li>Command-line demo for quick testing</li><li>Streamlit web application for visual exploration</li></ul><p><strong>3. Visualization Tools</strong></p><p>The system includes:</p><ul><li>Tag distribution analysis</li><li>Social network visualization</li><li>Recommendation explanation system</li></ul><p><strong>4. Performance Considerations</strong></p><p>The implementation focuses on efficiency through:</p><ul><li>Efficient graph traversal for social connections</li><li>Optimized scoring calculations</li><li>Smart caching of user preferences</li><li>O(1) lookups using hash maps</li></ul><h3>Future Improvements</h3><p>The system can be enhanced with:</p><ul><li>Time decay for engagement metrics</li><li>Negative feedback processing</li><li>Content embedding models</li><li>Real-time recommendation updates</li><li>Diversity mechanisms</li></ul><h3>Getting Started</h3><p>To try the system (GitHub Repo Link Provided Below):</p><pre>git clone https://github.com/AungKyawWin20/Instagram-Reels-Recommendation-Algorithm.git<br>cd Instagram-Reels-Recommendation-Algorithm<br>pip install -r requirements.txt<br>streamlit run app.py</pre><p><strong>Live Demo:</strong></p><p>Try the recommendation system yourself through my Streamlit Web App!</p><p>The demo provides:</p><ul><li>Interactive user selection</li><li>Visual tag distribution analysis</li><li>Detailed recommendation explanations</li><li>Sample video previews for top tags</li></ul><p>Find the Live Web App Demo <a href="https://instagram-reels-recommendation-algorithm.streamlit.app/">Here!</a> (Also pasted down below)</p><p>You can also run the demo locally after cloning my GitHub repository!</p><pre>streamlit run app.py</pre><p><strong>Project Structure</strong></p><pre>   ├── Datasets/<br>   │   ├── simulated_reels.csv<br>   │   └── simulated_users.csv<br>   ├── app.py                 # Streamlit web interface<br>   ├── demo_recommendation.py # Command-line demo<br>   ├── reels_recommendation.py # Core algorithm<br>   └── requirements.txt</pre><p>Before running the code, you will need to install the dependencies:</p><pre>pip install -r requirements.txt</pre><h3>The Final Product</h3><p>This Instagram Reels recommendation system demonstrates how combining multiple recommendation strategies can create a more robust and personalized content discovery experience. By optimizing social connections, content preferences, and engagement metrics, the system provides relevant and explainable recommendations that can help users discover new content while maintaining their interest in the platform.</p><p>The project showcases the importance of:</p><ul><li>Multiple recommendation strategies</li><li>Efficient data structures</li><li>Explainable AI</li><li>User-friendly interfaces</li><li>Performance optimization</li></ul><p>GitHub Repo Link: <a href="https://github.com/AungKyawWin20/Instagram-Reels-Recommendation-Algorithm.git">https://github.com/AungKyawWin20/Instagram-Reels-Recommendation-Algorithm.git</a></p><p>Streamlit Web App Demo Link: <a href="https://instagram-reels-recommendation-algorithm.streamlit.app/">https://instagram-reels-recommendation-algorithm.streamlit.app/</a></p><p>Thanks for reading! This project was a great learning experience, and I’m always looking to improve.</p><p>Feel free to share your thoughts in the comments or connect with me directly. I’d love to hear your feedback!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81e4e46f557a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>