DEV Community

Cover image for Hackathon Project: How I built an AI Recommender System for SMEs
mohd ibrahim
mohd ibrahim

Posted on

Hackathon Project: How I built an AI Recommender System for SMEs

The Inspiration 💡

We’ve all been there: you add five things to a cart, get distracted by a notification, and never look back. For small e-commerce businesses, that "lost cart" is a major hit to the bottom line. I wanted to build a tool that doesn't just track data, but actually predicts who is about to leave and what might make them stay.

What is SmartCart AI? 🛒

SmartCart AI is a predictive analytics dashboard designed for e-commerce managers. It takes massive transaction datasets and turns them into three actionable insights:

  • Churn Prediction: Who is "at-risk" of never coming back?

  • Customer Health: Visualizing the purchase "pulse" of every user.

  • Smart Recommendations: What should we offer them next?

The Tech Stack 🛠️

Building this required a mix of data engineering and machine learning:

  • Language: Python 3.12

  • Frontend: Streamlit (for that snappy, interactive UI)

  • Data Processing: Pandas & NumPy

  • Machine Learning: Scikit-Learn

  • Random Forest Classifier for churn risk.

  • Collaborative Filtering for the recommendation engine.

  • Visuals: Plotly for the behavioral timelines.

The "Aha!" Moment: Solving the Cold Start ❄️

One of the biggest hurdles was the Cold Start problem—how do you recommend products to a brand-new user with no history? I solved this by implementing a "Popularity Fallback" logic: if the AI doesn't know you yet, it shows you what everyone else is loving until it learns your patterns.

Under the Hood: How it Works 🧠

The system uses RFM Analysis (Recency, Frequency, Monetary) to score customers. We then feed these features into a Random Forest model.


# Quick snippet of the Churn Classification logic
from sklearn.ensemble import RandomForestClassifier

# Training the model on RFM features
model = RandomForestClassifier(n_estimators=100, random_state=42)
model.fit(X_train, y_train)

# Predicting the probability of churn
churn_probability = model.predict_proba(user_data)[:, 1]
Enter fullscreen mode Exit fullscreen mode

Key Challenges 🚧

  • Data Cleaning: Handling 500k+ rows of retail data was a lesson in patience. Cleaning up cancelled invoices and missing IDs was 70% of the work!

  • Memory Management: Learning to optimize similarity matrices so the app doesn't crash on a standard laptop.

What’s Next? 🚀

This is just the MVP. My roadmap for SmartCart AI includes:

  • Integrating directly with Shopify via API.

  • Adding "Sentiment Analysis" on product reviews to refine recommendations.

  • Deploying the model to the cloud for real-time streaming data.


Check it out!


I’d love to hear your thoughts! How are you handling churn in your data projects? Let's discuss in the comments! 👇

Top comments (0)