Skip to content

About

6 ML projects: CNN digit recognition 98.83%, spam detection 96.32%, sales prediction R2 0.91 + NLP + recommender | scikit-learn, TensorFlow

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

88 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Data Science Projects

Eight end-to-end ML projects — led by ride-demand forecasting & churn retention — spanning time series, churn modeling, GenAI/RAG, NLP, deep learning, regression, and recommendation systems

Python scikit-learn TensorFlow Keras NLTK Pandas LangChain ChromaDB


Profile Portfolio Data Analytics


Overview

Cross-Listed Analytics & Predictive Projects

# Project Problem Type Approach Result
1 Ride Demand and Revenue Forecasting Time series · Clustering · Regression SARIMA · K-Means · Random Forest · LLM Forecast Guard R² = 0.972 fare model · MAPE 8.3% forecast · GenAI anomaly briefs
2 Subscription Churn Prediction Binary classification · RAG LogReg + Random Forest · ChromaDB RAG + LLM offers ROC-AUC 0.839 · 80.0% accuracy · GenAI retention gateway
10 E-Commerce Revenue Reconciliation & Leakage AI Engine Binary Classification · Anomaly Detection · Financial AI GradientBoosting · Isolation Forest · GenAI Audit Copilot ROC-AUC 0.921 · Precision 94.8% · ₹83L Leakage Audit

Note: These projects are cross-listed from the Data Analytics repository — the SQL / EDA / finance reporting layers live there; this repository contains the full predictive modeling, machine learning, and AI layers.

Standalone Machine Learning Projects

# Project Problem Type Approach Result
3 Image Classification Multi-class classification CNN (TensorFlow/Keras) 98.83% test accuracy
4 Spam Email Detection Binary text classification TF-IDF + Logistic Regression 96.32% test accuracy
5 Sales Prediction Regression Linear Regression R² = 0.91 · MSE 2.86
6 Car Price Prediction Regression Random Forest Regressor MAE · MSE · R² evaluated
7 Sentiment Analysis NLP / text classification TF-IDF + Logistic Regression 71% accuracy, 0.70 weighted F1
8 Music Recommendation Recommendation Content-based, cosine similarity Top-K similar songs

1 · Ride Demand and Revenue Forecasting

Problem: A ride-hailing operator needs to know when to surge-price, where to position premium vehicles, and which fleet tier to grow — 35,000 trip records, five pickup zones, one simulated year.

Cross-listed from the Data Analytics repo — the SQL / Power BI dashboard layer lives there; this folder contains the full predictive modeling layer.

Ride Demand Dashboard Executive Ride Demand & Dynamic Fare Dashboard — Hourly trip surge, vehicle tier revenue efficiency, and airport route analysis.

Pipeline

35,000 trips (Jan–Dec)
  ↓ SQL cleaning pipeline (ROW_NUMBER() dedup safeguard, type coercion)
  ↓ SARIMA(1,1,1)(1,0,1,7) — daily demand forecast, weekly seasonality
  ↓ K-Means over zone×hour cells — demand segmentation (silhouette-selected k)
  ↓ RandomForestRegressor — route-level fare prediction
  ↓ All validated on a held-out Nov–Dec window (no leakage)

Results (held-out)

Model Performance
SARIMA demand forecast MAE 7.6 · RMSE 9.6 · MAPE 8.3% — ~20% error reduction vs the seasonal-naive baseline (MAE 9.5)
K-Means demand clusters k=2 · silhouette 0.675 — premium long-haul cells (avg ₹507 / 24.9 km) vs high-volume short-trip cells (avg ₹331 / 15.6 km)
RF fare prediction R² = 0.972 · RMSE ₹37.4 — prediction error ~13% of a typical fare

Honest read: SARIMA residuals pass Ljung-Box (p = 0.54 / 0.86) — no leftover autocorrelation. The fare model's high R² reflects that distance and duration genuinely determine fare; the value is the expected vs charged fare gap as an operational lever, not the score itself.

How a stakeholder uses this: ops teams re-time driver incentives to 4:30 PM (before the growth window opens) and position premium fleet for 5–7 PM; the fare model flags routes where charged fares drift below expectation.

� 01_ride-demand-and-revenue-forecasting/


2 · Subscription Churn Prediction & Retention Analytics

Problem: A subscription business (real-world telco data, 7,043 customers) is losing ~26% of customers. Predict who is at risk, why, and what revenue is on the table. The deliverable is a revenue-at-risk ranking that tells the retention team where spend saves the most dollars — month-to-month + fiber-optic customers alone are 72% of the exposure.

Cross-listed from the Data Analytics repo — the SQL / EDA / Excel dashboard layer lives there; this folder contains the full ML pipeline.

Subscription Churn Dashboard Executive Customer Churn & Retention Dashboard — KPI cards, risk segmentation by contract/service, and revenue-at-risk analysis.

Pipeline

Telco Customer Churn (7,043 × 21)
  ↓ Cleaning & feature engineering (tenure bands, service counts, charge ratios)
  ↓ Churn_EDA_Analysis.ipynb — KPI baseline, segment analysis, statistical validation
  ↓ Churn_Prediction_Analysis.ipynb — Logistic Regression + Random Forest
  ↓ Modular src/ pipeline: data_processing → feature_engineering → modeling
    → evaluation → explainability → risk_scoring
  ↓ pytest suite covering the pipeline modules

Results (held-out)

Model Accuracy Precision Recall F1 ROC-AUC
Logistic Regression 0.800 0.640 0.561 0.598 0.839
Random Forest 0.797 0.652 0.511 0.573 0.837

Honest read: recall is the metric that matters here — missing a churner costs the full customer value, while a false alarm costs one retention call. Logistic Regression wins on ROC-AUC (0.839) and recall (0.561) despite Random Forest's slight precision edge. Risk scores feed a revenue-at-risk segmentation (churn_segment_revenue.csv) rather than stopping at a leaderboard number.

How a stakeholder uses this: the retention team gets a ranked call list with revenue exposure per customer — spend prioritised by dollars at risk, not by model score.

� 02_subscription-retention-prediction/


3 · Image Classification — Handwritten Digit Recognition

Problem: Automatically recognize handwritten digits (0–9) from images — the foundational task behind postal code sorting and cheque digitization.

Dataset: MNIST — 60,000 training + 10,000 test grayscale images (28×28 px), loaded directly via keras.datasets.

Model Architecture

Input (28×28×1)
  ↓ Conv2D(32, 3×3, ReLU)  →  MaxPooling2D(2×2)
  ↓ Conv2D(64, 3×3, ReLU)  →  MaxPooling2D(2×2)
  ↓ Conv2D(64, 3×3, ReLU)
  ↓ Flatten  →  Dense(64, ReLU)  →  Dense(10, Softmax)

Optimizer: Adam · Loss: Sparse categorical cross-entropy · Epochs: 5

Results

Epoch Train Accuracy Train Loss
1 88.98% 0.3449
2 98.46% 0.0504
3 99.01% 0.0332
4 99.21% 0.0253
5 99.43% 0.0185

Test accuracy: 98.83% (loss 0.0491) — the small train/test gap indicates the model generalized well without significant overfitting.

Key steps: pixel normalization to [0,1] · channel-dimension reshaping · prediction visualization with Matplotlib · model exported to mnist_model.h5

How a stakeholder uses this: a proof-of-work CNN for OCR intake (form digitisation, cheque processing) — the same architecture transfers to document classification pipelines.

📓 03_image_classification_project/notebooks/image_classification.ipynb


4 · Spam Email Detection

Problem: Classify emails as spam or legitimate — the classic asymmetric-cost problem, where a spam email reaching the inbox is a mild annoyance but a legitimate email wrongly filtered could be a missed job offer.

Pipeline

Raw email text
  ↓ Text preprocessing (NLTK) — cleaning, tokenization
  ↓ TF-IDF vectorization — weight terms by discriminative power
  ↓ Logistic Regression classifier
  ↓ Evaluate on held-out test set

Results

Split Accuracy
Training 96.11%
Test 96.32%

Test accuracy slightly exceeding training accuracy is a healthy sign — the model hasn't memorized the training set and generalizes to unseen emails. A large gap in the other direction would signal overfitting.

Why TF-IDF over raw word counts: it down-weights words appearing across all emails ("the", "and") and up-weights terms that actually distinguish spam from legitimate mail, so the classifier learns from signal rather than noise.

How a stakeholder uses this: an email filter tuned for the costlier error — a false positive hides a job offer, so thresholds favour keeping legitimate mail in the inbox.

📓 04_spam_email_detection_project/


5 · Sales Prediction

Problem: Predict product sales from outlet and item attributes — MRP, outlet size, item type, and outlet location. Sales forecasting drives inventory planning: under-forecast and you stock out; over-forecast and you tie up capital in unsold goods.

Pipeline

Raw sales data
  ↓ Handle missing values and duplicates
  ↓ Exploratory data analysis (distribution, correlation)
  ↓ Encode categorical variables (outlet type, item category)
  ↓ Train Linear Regression
  ↓ Evaluate — MSE, MAE, RMSE, R²

Results

Metric Value
R² Score 0.91
Mean Squared Error 2.86

R² of 0.91 means the model explains 91% of the variance in sales. For a linear model on retail data that's strong — it suggests the relationship between MRP, outlet characteristics and sales is largely linear, so a more complex tree-based model would buy little here.

How a stakeholder uses this: inventory planners set stock depth per outlet — the model shows which outlet types justify deeper shelf allocation and which are structurally capped.

📓 05_sales_prediction_project/


6 · Car Price Prediction

Problem: Estimate a used car's selling price from year, mileage, fuel type, transmission, and engine specs. Resale pricing is the core of any used-vehicle marketplace — mispricing costs either seller margin or buyer trust.

Pipeline

Vehicle listings data
  ↓ Clean and inspect
  ↓ Feature engineering — derive vehicle age from year
  ↓ Encode categoricals (fuel type, transmission, seller type)
  ↓ Train Random Forest Regressor
  ↓ Evaluate — MAE, MSE, R²

Why Random Forest here: depreciation isn't linear. A car loses value fastest in its first years and the curve flattens later; mileage interacts with age rather than acting independently. A tree ensemble captures those non-linear interactions without needing them specified in advance — which is precisely why it suits this problem where Linear Regression suited sales prediction.

How a stakeholder uses this: a marketplace pricing baseline — sellers get a defensible price band per vehicle instead of gut-feel quotes, reducing time-to-sale.

📓 06_car_price_prediction_project/


7 · Sentiment Analysis — Tweet Classification

Problem: Classify social media posts as positive, negative, or neutral — the core of brand monitoring and customer feedback analysis.

Dataset: 500 labelled tweets with text, sentiment, timestamp, and platform metadata.

Pipeline

Raw text
  ↓ Lowercase  →  strip non-alphabetic characters
  ↓ Stopword removal (NLTK)  →  WordNet lemmatization
  ↓ TF-IDF vectorization (unigrams + bigrams, 5,000 features)
  ↓ Logistic Regression (class_weight='balanced', max_iter=1000)

Stratified 80/20 train-test split preserves class proportions.

Results

Class Precision Recall F1-Score Support
Negative 0.85 0.41 0.55 27
Neutral 0.63 0.90 0.74 40
Positive 0.80 0.73 0.76 33
Accuracy 0.71 100
Weighted avg 0.75 0.71 0.70 100

Honest read: the model is precise on negative tweets (0.85) but recalls only 41% of them — it misses many, usually labelling them neutral. With just 27 negative samples in the test set, more data is the clearest path to improvement. class_weight='balanced' was used specifically to counteract this imbalance.

Includes a predict_sentiment() helper for inference on unseen text.

How a stakeholder uses this: a brand-monitoring triage layer — positive/neutral posts pass through, likely-negative posts are routed to support for human review.

📓 07_sentiment_analysis_project/notebooks/sentiment_analysis.ipynb


8 · Music Recommendation System

Problem: Given a song a listener enjoys, suggest similar tracks — the content-based approach used when you lack the user-interaction history that collaborative filtering requires.

Dataset: 100 songs with title, artist, genre, release year, duration, listen date, and platform.

Approach

Raw listening data
  ↓ Deduplicate to unique songs
  ↓ Feature engineering — aggregate listen counts per song
  ↓ One-hot encode categorical features (genre, artist)
  ↓ StandardScaler normalization
  ↓ Cosine similarity matrix across all song pairs
  ↓ recommend_song(title, top_k) → K nearest neighbours

Why content-based: it sidesteps the cold-start problem — a new song can be recommended immediately from its own attributes, with no listening history needed.

How a stakeholder uses this: cold-start-ready recommendations for a growing catalogue — every track is recommendable from day one, before any interaction history exists.

📓 08_music_recommendation_system/notebooks/music_recommendation.ipynb


Repository Structure

Data-Science-Project/
├── 01_ride-demand-and-revenue-forecasting/# Forecasting · SARIMA + K-Means + RF fare model
├── 02_subscription-retention-prediction/# Churn · LogReg + RF, modular pipeline with tests
│   ├── src/                            # data_processing → modeling → explainability
│   └── Churn_Prediction_Analysis.ipynb
├── 03_image_classification_project/       # CNN · MNIST digit recognition
│   └── notebooks/image_classification.ipynb
├── 04_spam_email_detection_project/       # NLP · TF-IDF + Logistic Regression
├── 05_sales_prediction_project/           # Regression · Linear Regression
├── 06_car_price_prediction_project/       # Regression · Random Forest
├── 07_sentiment_analysis_project/         # NLP · tweet sentiment classification
│   ├── dataset/sentiment_analysis.csv
│   └── notebooks/sentiment_analysis.ipynb
└── 08_music_recommendation_system/        # Content-based recommender
    ├── dataset/music_dataset.csv
    └── notebooks/music_recommendation.ipynb

Getting Started

Prerequisites

  • Python 3.10+ (matches the Dockerfile; the churn API is tested on 3.10–3.12)
  • Jupyter Notebook or JupyterLab

Installation

# Clone the repository
git clone https://gitlab.com/ansht_121/Data-Science-Project.git
cd Data-Science-Project

# Install dependencies
pip install numpy pandas matplotlib scikit-learn tensorflow nltk jupyter

# Launch Jupyter
jupyter notebook

Running Each Project

Ride Demand Forecasting · Subscription Churn Prediction — each folder ships its own requirements.txt and README.

pip install -r 01_ride-demand-and-revenue-forecasting/requirements.txt
pip install -r 02_subscription-retention-prediction/requirements.txt

jupyter notebook 01_ride-demand-and-revenue-forecasting/Forecast_Clustering_Analysis.ipynb
jupyter notebook 02_subscription-retention-prediction/Churn_Prediction_Analysis.ipynb
# or run the modular churn pipeline end-to-end:
python 02_subscription-retention-prediction/src/train.py

Image Classification — no setup needed; MNIST downloads automatically on first run.

jupyter notebook 03_image_classification_project/notebooks/image_classification.ipynb

Spam Detection · Sales Prediction · Car Price Prediction — open the notebook in each project folder and run all cells.

jupyter notebook 04_spam_email_detection_project/
jupyter notebook 05_sales_prediction_project/
jupyter notebook 06_car_price_prediction_project/

Datasets not included. These three notebooks expect spam_mail.csv, sales dataset.csv, and car_data.csv respectively, which aren't committed to this repository. Place your own copy alongside the notebook, or update the read_csv() path in the first cell. The notebooks retain their saved outputs, so the results are reproducible reading even without the raw files.

Sentiment Analysis — downloads NLTK corpora on first run.

cd 07_sentiment_analysis_project/notebooks
jupyter notebook sentiment_analysis.ipynb

The notebook loads sentiment_analysis.csv. Either run it from the dataset/ folder or update the path to ../dataset/sentiment_analysis.csv.

Music Recommendation

cd 08_music_recommendation_system/notebooks
jupyter notebook music_recommendation.ipynb

The notebook loads MusicDataset.csv. Update the path to ../dataset/music_dataset.csv to match this repository's layout.


10 · E-Commerce Revenue Reconciliation & Leakage AI Engine

Problem: An e-commerce operator invoiced ₹7.86 Cr across 128,976 order lines. How much cash was actually realized in the bank, what leaked through cancellations and returns, and how can predictive AI intercept leakage before orders ship?

Cross-listed from the Data Analytics repo — the raw SQL / openpyxl financial pipeline lives there; this folder contains the full predictive ML risk model, anomaly detection, cash clearance forecaster, and AI audit agent.

E-Commerce Reconciliation & AI Cockpit Executive Revenue Reconciliation & AI Leakage Cockpit — Metric Flow aligned layout with Cyber-Violet & Emerald Luxury theme, live ML risk scoring, and cash liquidation forecasting.

Pipeline Architecture

128,976 transactions (Amazon India Marketplace)
  ↓ Deterministic financial reconciliation matrix (Net Realized vs True Leakage vs Transit Lag)
  ↓ Pre-dispatch feature engineering (order economics, category, geographic risk tiering)
  ↓ GradientBoosting Classifier (ROC-AUC 0.921, Precision 94.8%) — order leakage propensity
  ↓ Isolation Forest — multi-dimensional transaction anomaly detection
  ↓ 3-stage liquidation curve forecaster — turns ₹5.16 Cr In-Transit lag into bank cash timeline
  ↓ Autonomous AI Financial Audit Agent — CFO variance briefs & root cause diagnostic

Results (Held-Out Test Set $N = 9,842$)

Metric / Model Performance Operational Impact
GradientBoosting Leakage Model ROC-AUC 0.921 · PR-AUC 0.926 Flags high-risk cancellations & returns prior to dispatch
Model Precision 94.84% Minimizes false flags on safe orders
Model F1-Score 0.8208 (Acc: 86.87%) Optimal balance between retention and fraud/cancellation capture
Audited Clearance Rate 69.18% Separates ₹83.07 Lakh true leakage from ₹5.16 Cr harmless transit lag

📠10_ecommerce-reconciliation-engine/


🤖 How These Models Are Built in the AI Era

Every model in this repository follows the same discipline: AI accelerates, humans validate.

Stage AI Assists With My Validation Gate
Data prep Drafting cleaning & feature-engineering logic Row-count reconciliation, dtype audits, leakage checks (e.g., SARIMA validated on held-out Nov–Dec, never on the training window)
Modeling Baseline code scaffolding Algorithm matched to problem structure — Linear Regression where the relationship is linear (R² 0.91), Random Forest where it is not
Evaluation Metric summaries Metrics recomputed from scratch; train/test gaps interpreted, not hidden (sentiment model's weak minority-class recall is reported, not rounded up)
Explainability Drafting interpretation text Feature importances cross-checked against domain sense before being written into findings

The principle: AI is a co-pilot, not an oracle. It drafts, I verify — a hallucinated evaluation metric or leaky validation split that looks right is more dangerous than an obvious failure. Model limitations are documented, not hidden, exactly because AI output can't be trusted on faith.


Skills Demonstrated

Area Techniques
Deep Learning CNN architecture design, convolution/pooling layers, softmax classification, Adam optimization
NLP Text cleaning, stopword removal, lemmatization, TF-IDF with n-grams
Classical ML Linear & logistic regression, Random Forest ensembles, class imbalance handling, stratified splitting
Regression Analysis R², MSE, MAE, RMSE interpretation; matching model complexity to relationship structure
Recommender Systems Content-based filtering, one-hot encoding, cosine similarity, cold-start reasoning
Time Series Forecasting SARIMA with weekly seasonality, held-out validation, Ljung-Box residual diagnostics, seasonal-naive baselines
Unsupervised Learning K-Means demand segmentation, silhouette-based k selection, cluster profiling
Churn Modeling Logistic Regression vs Random Forest, ROC-AUC / precision / recall trade-offs, explainability, risk scoring
Evaluation Accuracy, precision, recall, F1-score, per-class analysis, train/test gap interpretation
Data Handling Pandas transformations, feature scaling, deduplication, aggregation

Future Improvements

  • Sentiment Analysis — expand beyond 500 samples; try SVM and transformer-based models (BERT) as baselines to beat
  • Image Classification — add data augmentation and dropout; extend to Fashion-MNIST or CIFAR-10
  • Music Recommendation — introduce collaborative filtering as a hybrid layer once interaction data is available
  • Across all — refactor notebooks into reusable modules, add requirements.txt, and pin dependency versions

Author

Ansh Thakur — Data Analyst & Machine Learning Practitioner

GitLab Portfolio LinkedIn Email

About

6 ML projects: CNN digit recognition 98.83%, spam detection 96.32%, sales prediction R2 0.91 + NLP + recommender | scikit-learn, TensorFlow

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages