AI-Based Medical Diagnosis System using NLP & Machine Learning

5 min read
Machine Learning

Project Domain / Category
Web Development, NLP, ML


Abstract
This project introduces an AI-Based Medical Diagnosis System that leverages Natural Language Processing (NLP) and Machine Learning (ML) to assist users in identifying potential diseases based on their symptoms. Users can input symptoms
in natural language, which the system processes to extract structured medical information such as symptom type, severity, and duration. These details are then converted into feature vectors and analyzed using ML classification models,
including Decision Trees, Naive Bayes, or Random Forests, to generate probable diagnoses with confidence scores. To improve accuracy and interpretability, the system employs a hybrid approach, combining data-driven ML predictions with rule- based logic derived from medical knowledge. A distinguishing aspect of this system is its explainable outputs, providing users with clear reasoning behind each diagnosis, highlighting influential symptoms and key decision factors. It also offers basic recommendations and maintains a history of past diagnoses for reference. Overall, the project demonstrates the integration of modern AI techniques into healthcare support systems, emphasizing transparency, usability, and structured outputs. Its design makes it particularly suitable for academic purposes, as evaluators can assess its reasoning and predictions efficiently without requiring full system execution.


Functional Requirements
User Roles
• Patient/User
o Enter symptoms in text
o View diagnosis and recommendations
o Access history
Admin
o Manage datasets
o Monitor model performance
o Manage symptom dictionary
Doctor Role
o Validate predictions
o Add expert rules/feedback
User Management
• The system shall allow:
o User registration, login, logout
o Password encryption
• The system shall support:
o Role-based access control
User Interface
• The system shall display the homepage upon opening the website or application.
• The homepage shall contain a header with the logo, navigation menu (Home, About, Submit Symptoms, History, Admin Login), and optional user profile icon if logged in.
• The homepage shall include a main section with a prominent text input box for users to type symptoms.
• The homepage shall provide placeholder text in the input box guiding users: "Type your symptoms here (e.g., fever, headache, body pain)".
• The homepage shall have optional dropdowns or selection fields for:
o Severity (Low, Medium, High)
o Duration (Hours, Days, Weeks)
Symptom Submission
• The homepage shall have a “Diagnose Me” button that submits the user input to the system.
• When the user submits symptoms, the homepage shall validate that the input is not empty.
• If the input is empty, the system shall display a warning message prompting the user to enter symptoms.
• Upon valid submission, the homepage shall redirect the user to the Results Page showing predictions, confidence scores, and explanation.
Natural Language Input Module (NLP Engine)
The system shall accept:
• Free-text input (English)
• The system shall:
• Perform:
o Tokenization
o Stop-word removal
o Lemmatization/stemming
• Extract:
o Symptoms
o Duration
o Severity indicators
• The system shall map extracted text to standard medical terms
• Example:
o Input: "I have high temperature and severe headache"
Output: [fever, headache]
• The system shall:
o Handle spelling mistakes
o Suggest corrections
Symptom Normalization & Dictionary
• The system shall maintain:
o Symptom ontology/dictionary
• The system shall:
o Map synonyms:
▪ “temperature” → fever
▪ “stomach pain” → abdominal pain
• Admin shall:
o Add/edit/remove synonyms
Feature Engineering Module
• The system shall convert symptoms into:
o Numerical feature vectors
• The system shall include:
o Binary encoding (present/absent)
▪ Converts presence/absence of symptoms into 0 or 1.
▪ Example:
fever → 1 (present)
cough → 0 (absent)
▪ Purpose: Lets ML models distinguish which symptoms are reported.
o Severity Weighting
▪ Assigns numeric values to symptom severity.
▪ Low → 1, Medium → 2, High → 3
▪ Purpose: ML models consider not just presence but how severe the symptom is.
o Duration Encoding
▪ Converts symptom duration into numeric values:
▪ Short → 1, Medium → 2, Long → 3
▪ Purpose: Longer-lasting symptoms might have higher significance in diagnosis.
o Vectorization
▪ Combines all features into a single feature vector for the ML
model.
▪ Example:
[fever=1, headache=1, cough=0, severity=3, duration=2]
▪ Provides a structured input that the ML algorithms can process
efficiently
Machine Learning Model Module
• The system shall:
o Train model on symptom-disease dataset
• Supported models:
o Decision Tree
o Naive Bayes
o Random Forest
• The system shall:
o Split dataset (train/test)
o Evaluate accuracy, precision, recall
• The system shall:
o Save trained model
Prediction Engine
• The system shall:
o Accept processed input
o Generate top N disease predictions
• The system shall:
o Output probability scores
Hybrid Logic Layer
• The system shall:
o Apply rule-based adjustments:
▪ Critical symptom override
▪ Severity-based prioritization
Example:
If “chest pain” → raise priority Explainable AI Module (CORE REQUIREMENT ⭐)
• The system shall:
o Display:
▪ Key symptoms influencing prediction
▪ Feature importance
• The system shall generate explanation:
Prediction: Flu (82%)
Reason:
- Fever → high importance
- Headache → medium importance
- Duration → supports viral infection
Output & Visualization Module
• The system shall display:
o Ranked diseases
o Confidence scores
o Extracted symptoms
• The system shall include:
o Graphs/charts for probabilities
Recommendation Module
• The system shall:
o Suggest:
▪ Precautions
▪ Basic remedies
• The system shall include:
o “Consult doctor” warning for critical cases
History & Reporting
• The system shall:
o Store all diagnoses
• The system shall generate:
o Downloadable reports (PDF)
• Report must include:
o Input text
o Extracted symptoms
o Predictions
o Explanation
Admin Dashboard
• The system shall:
o Upload/manage datasets
o View:
▪ Model accuracy
▪ Usage statistics
Error Handling
• The system shall:
o Handle ambiguous input
o Prompt user for clarification
o The system shall:
o Prevent empty submissions

    Tools & Technologies
  • Frontend: React.js / Vue.js, HTML, CSS, JavaScriptj
  • Backend: Python (Flask / Django)
  • AI/ML: scikit-learn, TensorFlow, NLP (spaCy / Transformers)
  • Database: MySQL / MongoDB

Share this project:

Faisal Mehmood

Faisal Mehmood Expert in CS619 Final Year Projects and software development.

View all projects