An end-to-end, interactive data mining workbench β clustering and classification algorithms implemented from scratch, powered by Streamlit.
This project is a complete data mining pipeline in a single web app. It walks you from raw CSV to trained model through a guided, phase-by-phase workflow: load β clean β explore β normalize β cluster β classify.
Rather than calling a black-box library, every core algorithm (K-Means, K-Medoids, AGNES, DIANA, DBSCAN, k-NN, Naive Bayes, C4.5, and SVM) is implemented from scratch with NumPy and Pandas. The UI lets you tune parameters, run algorithms side by side, compare them with standard evaluation metrics, and get an automatic "best algorithm" recommendation.
Built as a Data Mining course project with strict academic grounding β every formula follows the course material.
- π§© 9 algorithms from scratch β 5 clustering + 4 classification, no
sklearnestimators. - ποΈ Interactive configuration β tune
k, linkage,eps/MinPts, kernels,C, and more. - βοΈ Compare mode β run all algorithms at once and rank them with a composite score.
- π Rich visualizations β 2D/3D cluster plots, elbow curves, dendrograms, confusion-matrix heatmaps, and more.
- π§ͺ Full preprocessing toolkit β duplicates, missing values, outliers, typing, and minβmax / z-score normalization.
- π³ One-command startup with Docker or Docker Compose.
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
- Docker (recommended), or
- Python 3.9+
git clone https://github.com/RamyRxr/DM-Project.git
cd DM-Project
docker build -t data-mining-app .
docker run -p 8501:8501 data-mining-appOpen http://localhost:8501.
git clone https://github.com/RamyRxr/DM-Project.git
cd DM-Project
docker compose up --buildgit clone https://github.com/RamyRxr/DM-Project.git
cd DM-Project
python -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
streamlit run app.pyThe app opens at http://localhost:8501.
The app is organized into a guided workflow. Data Cleaning (Phases 1β6) must be completed before the machine-learning sections unlock.
| Phase | What it does |
|---|---|
| 1 Β· Data Loading | Upload a CSV, inspect dimensions, columns, and dtypes. |
| 2 Β· Cleaning & Quality | Detect/remove duplicates; handle missing values (auto-clean, custom indicators, drop, fill 0/mean/median, forward/backward fill); drop columns. |
| 3 Β· Outlier Detection | Per-column boxplots, outlier summary, and choose to remove, cap, or keep outliers. |
| 4 Β· Exploration | Descriptive statistics (min, max, mean, median, mode, Q1, Q3) and scatter plots. |
| 5 Β· Data Typing | Detect float columns that represent integers and safely convert them. |
| 6 Β· Normalization | MinβMax scaling, Z-score standardization, or skip. Numeric columns only. |
- Feature selection for 2D/3D visualization with a live preview.
- Single run with algorithm-specific parameters, or Select all to compare every algorithm.
- Visuals: 2D & 3D cluster scatter plots, centroid/medoid markers, elbow curves with optimal-
kdetection, cluster histograms, and dendrograms.
- Choose a target column, inspect class distribution and balance.
- Adjustable train/test split (10β40% test) with per-class sample counts.
- Single run with parameters, or Select all to benchmark all four classifiers.
- Visuals: metrics cards, confusion-matrix tables & heatmaps, k-NN accuracy/precision vs.
kplots, SVM support-vector counts, and a ranked comparison table with a composite score.
| Algorithm | Type | Key ideas |
|---|---|---|
| K-Means | Centroid-based | Iterative centroid updates & convergence; elbow method for k. |
| K-Medoids (PAM) | Medoid-based | Robust to outliers; medoid updates; elbow method. |
| AGNES | Agglomerative | Bottom-up; single / complete / average / ward linkage; dendrogram. |
| DIANA | Divisive | Top-down recursive splitting; dendrogram. |
| DBSCAN | Density-based | eps / MinPts; core, border, and noise point classification. |
| Algorithm | Key ideas |
|---|---|
| k-NN | Euclidean distance, majority vote; the exact 4-step process from the course; evaluated for k = 1β¦20. |
| Naive Bayes | Gaussian likelihood; prior probabilities and posterior argmax under conditional independence. |
| C4.5 | Entropy, Information Gain, Split Information, and Gain Ratio for attribute selection. |
| SVM | Maximum-margin hyperplane; linear / RBF / polynomial kernels; C regularization; support vectors. |
Clustering
- Silhouette Score β higher is better (well-separated clusters).
- DaviesβBouldin Index β lower is better.
- CalinskiβHarabasz Index β higher is better.
- Inertia / WCSS β within-cluster sum of squares (K-Means / K-Medoids).
- Composite Score β normalized weighted blend used for the recommendation.
Classification
- Accuracy = (TP + TN) / Total
- Precision = TP / (TP + FP)
- Recall = TP / (TP + FN)
- F-Measure = 2 Γ (Precision Γ Recall) / (Precision + Recall)
- Composite Score β average of the four metrics above.
DM-Project/
βββ app.py # Main Streamlit app (preprocessing + routing)
βββ requirements.txt # Pinned Python dependencies
βββ Dockerfile # Container image
βββ docker-compose.yml # Compose service definition
βββ .dockerignore / .gitignore # Build & VCS exclusions
βββ LICENSE # MIT
βββ data_mining_project_tasks.md # Full phase-by-phase project roadmap
βββ images/ # Screenshots used in this README
β
βββ algorithms/
βββ unsupervised/ # Clustering
β βββ interface.py # UI + orchestration
β βββ kmeans.py
β βββ kmedoids.py
β βββ agnes.py
β βββ diana.py
β βββ dbscan.py
β
βββ supervised/ # Classification
βββ interface.py # UI + orchestration
βββ knn.py
βββ naive_bayes.py
βββ c45.py
βββ svm.py
| Layer | Tools |
|---|---|
| App / UI | Streamlit |
| Data & math | Pandas, NumPy |
| Visualization | Plotly |
| Utilities | scikit-learn (only for train_test_split, confusion_matrix, and metric helpers) |
| Packaging | Docker, Docker Compose |
- Algorithms are hand-implemented. No
sklearnclustering or classification estimators are used β only distance math, centroid/medoid updates, tree building, and probability calculations written directly. - Formulas follow the course material (e.g., C4.5 uses Gain Ratio, not just Information Gain; Naive Bayes uses Gaussian likelihood; k-NN follows the 4-step procedure taught in class).
- Transparency. The UI includes expandable explanations of each algorithm and metric, and
data_mining_project_tasks.mddocuments every implementation step.
| Problem | Fix |
|---|---|
| App won't start (Docker) | Ensure Docker Desktop is running, then rebuild: docker build -t data-mining-app . |
| App won't start (Python) | Verify python --version is 3.9+ and re-run pip install -r requirements.txt. |
| Port already in use | Run on another port: streamlit run app.py --server.port 8502 or docker run -p 8502:8501 data-mining-app. |
| Out-of-memory on large files | Use a smaller dataset or give the container more memory. |
| Visualizations missing | Confirm Plotly is installed (pip install plotly) and hard-refresh the browser. |
Released under the MIT License.
Ramy Β· @RamyRxr
If you found this useful, a β on the repo is appreciated.














