An AI-powered web application for cancer diagnosis using multiple machine learning algorithms, built from scratch in C++ with a modern web interface.
- Overview
- Features
- Tech Stack
- Architecture
- Getting Started
- Usage
- Project Structure
- API Documentation
- Machine Learning Models
- Screenshots
- Contributing
- License
- Author
The Cancer Diagnosis System is a comprehensive, full-stack application that leverages multiple machine learning algorithms to assist in cancer diagnosis based on genetic mutation data. This project demonstrates the implementation of core ML algorithms from scratch in C++, combined with a modern web-based user interface for real-time diagnosis and analysis.
- π§ Four ML Models: Decision Tree, K-Nearest Neighbors, Logistic Regression, and Naive Bayes
- β‘ High Performance: C++ backend ensures fast processing and low latency
- π Modern Web UI: Intuitive interface with real-time data visualization
- π Model Comparison: Evaluate and compare multiple ML models side-by-side
- π Batch Processing: Queue system for processing multiple patients efficiently
- π Comprehensive Metrics: Accuracy, Precision, Recall, and F1-Score evaluation
- Multi-Model Diagnosis: Run predictions using four different ML algorithms
- Real-time Analysis: Instant diagnosis results with confidence scores
- Data Management: Load and manage patient and genetic data via CSV files
- Batch Queue System: Process multiple patients in a queue for efficient workflow
- Model Evaluation: Comprehensive performance metrics for all models
- Data Visualization: Interactive charts and graphs using Chart.js
- Responsive Design: Modern, user-friendly interface with dark mode support
- Hash-based Data Mapping: Efficient genetic data lookup using custom hash tables
- Data Preprocessing: Automated data cleaning and normalization
- RESTful API: Clean API design for easy integration
- CORS Support: Cross-origin resource sharing enabled for web access
- Error Handling: Robust error handling and user feedback
- Settings Management: Configurable API endpoints and preferences
- Language: C++17
- HTTP Server: cpp-httplib v0.28.0
- Build System: CMake 3.10+
- Architecture: RESTful API
- HTML5: Semantic markup
- CSS3: Modern styling with animations
- JavaScript: Vanilla JS (no frameworks)
- Chart.js: Data visualization library
- Algorithms: Implemented from scratch
- Decision Tree Classifier
- K-Nearest Neighbors (KNN)
- Logistic Regression
- Naive Bayes Classifier
- Hash Tables: Custom implementation for genetic data mapping
- Vectors & Arrays: Efficient data storage and manipulation
- Queues: Patient processing queue system
βββββββββββββββββββ
β Web Browser β
β (Frontend) β
ββββββββββ¬βββββββββ
β HTTP/REST API
β (JSON)
ββββββββββΌβββββββββ
β C++ HTTP Server β
β (Port 8080) β
ββββββββββ¬βββββββββ
β
ββββββ΄βββββ
β β
βββββΌββββ ββββΌβββββββββ
β ML β β Data β
β Modelsβ β Structuresβ
βββββββββ βββββββββββββ
- Data Loading: CSV files are loaded and preprocessed
- Model Training: ML models are trained on genetic mutation data
- Diagnosis: Patient genetic data is analyzed by selected model(s)
- Results: Predictions are returned with confidence scores
- Visualization: Results are displayed in the web interface
- CMake (3.10 or higher)
- C++ Compiler:
- Windows: Visual Studio 2019+
- Linux: GCC
- macOS: Xcode Command Line Tools
- Python 3 (optional, for serving UI)
-
Clone the repository
git clone https://github.com/Muhammad-Hashir-Code/Cancer-Diagnosis-System.git cd Cancer-Diagnosis-System/CancerDiagnosisSystem -
Build the project
# Create build directory mkdir build && cd build # Configure (Windows) cmake .. -G "Visual Studio 16 2019" # Configure (Linux/macOS) cmake .. -DCMAKE_BUILD_TYPE=Release # Build cmake --build . --config Release
-
Run the server
# From project root directory ./build/Release/cds_server.exe # Windows ./build/cds_server # Linux/macOS
-
Open the web interface
cd ui python -m http.server 8000 # Open http://localhost:8000/index.html in your browser
For detailed setup instructions, see SETUP_GUIDE.md.
- Navigate to the "Load Data" section
- Click "Load Data on Server"
- Wait for confirmation message
- Verify data in the Dashboard
- Go to "Run Diagnosis" section
- Add patient genetic records (Gene ID and Mutation Score)
- Select one or more ML models
- Click "Run Diagnosis"
- View results with confidence scores
- Navigate to "Evaluate Models" section
- Click "Evaluate All Models"
- Compare performance metrics:
- Accuracy
- Precision
- Recall
- F1-Score
- Add patients to the queue
- Process queue to run batch diagnosis
- View results for all queued patients
CancerDiagnosisSystem/
βββ data/ # CSV data files
β βββ genes.csv # Genetic mutation data
β βββ patients.csv # Patient information
β βββ test_*.csv # Test datasets
βββ headers/ # C++ header files
β βββ CancerDiagnosisSystem.h
β βββ DecisionTreeClassifier.h
β βββ KNNClassifier.h
β βββ LogisticRegressionModel.h
β βββ NaiveBayesClassifier.h
β βββ ...
βββ src/ # C++ source files
β βββ Server.cpp # HTTP server implementation
β βββ CancerDiagnosisSystem.cpp
β βββ [ML Model implementations]
βββ ui/ # Web interface
β βββ index.html # Main HTML file
β βββ script.js # Frontend logic
β βββ styles.css # Styling
βββ third_party/ # External libraries
β βββ httplib.h # HTTP server library
βββ CMakeLists.txt # Build configuration
βββ SETUP_GUIDE.md # Detailed setup guide
βββ README.md # This file
Get system status and data counts.
Response:
{
"modelsTrained": true,
"geneticCount": 150,
"patientCount": 50
}Load data from CSV files.
Request:
{
"genesFile": "data/genes.csv",
"patientsFile": "data/patients.csv"
}Response:
{
"success": true,
"message": "Data loaded successfully",
"geneticCount": 150,
"patientCount": 50
}Train all ML models.
Response:
{
"success": true,
"message": "Models trained successfully"
}Run diagnosis on patient data.
Request:
{
"model": "decision_tree",
"geneticRecords": [
{"geneId": "GENE_001", "mutationScore": 0.85},
{"geneId": "GENE_002", "mutationScore": 0.72}
]
}Response:
{
"success": true,
"model": "decision_tree",
"prediction": 1,
"confidence": 0.87,
"message": "High risk detected"
}Evaluate all models and return metrics.
Response:
{
"decision_tree": {
"accuracy": 0.92,
"precision": 0.89,
"recall": 0.91,
"f1Score": 0.90
},
"knn": { ... },
"logistic_regression": { ... },
"naive_bayes": { ... }
}- Type: Supervised Learning
- Use Case: Classification based on feature thresholds
- Advantages: Interpretable, handles non-linear relationships
- Implementation: Custom C++ implementation with recursive splitting
- Type: Instance-based Learning
- Use Case: Classification based on similarity
- Advantages: Simple, effective for non-linear data
- Implementation: Distance-based classification with configurable k
- Type: Statistical Learning
- Use Case: Binary classification with probability estimates
- Advantages: Fast, interpretable coefficients
- Implementation: Gradient descent optimization
- Type: Probabilistic Classifier
- Use Case: Classification based on Bayes' theorem
- Advantages: Fast, works well with small datasets
- Implementation: Gaussian Naive Bayes for continuous features
Gene_ID,Mutation_Score,Label
GENE_001,0.85,1
GENE_002,0.72,1
GENE_003,0.45,0Patient_ID,Name,Age
P001,John Doe,45
P002,Jane Smith,52Note: Add screenshots of your application here
- Dashboard showing system statistics
- Diagnosis interface with model selection
- Results visualization with charts
- Model evaluation comparison
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Muhammad Hashir
- GitHub: @Muhammad-Hashir-Code
- Email: siddiquimuhammadhashir1@gmail.com
- cpp-httplib - HTTP server library
- Chart.js - Data visualization library
- CMake community for excellent build system documentation
- Setup Guide - Detailed installation instructions
- Data Loading Troubleshooting - Common issues and solutions
- CMake Documentation
If you find this project helpful, please consider giving it a β on GitHub!
Built with β€οΈ using C++ and modern web technologies