import streamlit as st import joblib import re import string # Load the trained model and TF-IDF vectorizer knn_model = joblib.load('knn_model.joblib') tfidf_vectorizer = joblib.load('tfidf_vectorizer.joblib') # Preprocess the input text (same preprocessing as in the notebook) def preprocess_text(text): text = text.lower() # Convert to lowercase text = re.sub(r'\d+', '', text) # Remove digits text = text.translate(str.maketrans('', '', string.punctuation)) # Remove punctuation return text # Prediction function def predict_disease(symptom): preprocessed_symptom = preprocess_text(symptom) tfidf_features = tfidf_vectorizer.transform([preprocessed_symptom]).toarray() predicted_disease = knn_model.predict(tfidf_features) return predicted_disease[0] # Streamlit UI Design st.set_page_config(page_title="Disease Prediction App", page_icon="🦠", layout="centered") # Custom Styling st.markdown(""" """, unsafe_allow_html=True) # Title and Description st.markdown("