CoolFace
Apppublic

KeshavaKumar/Personalized_Medicine_Composition_Optimization

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
two.py26 linesDownload Raw Back to root
1import pandas as pd
2import pickle
3
4def load_model():
5    """Load trained disease classifier and symptom encoder."""
6    with open("disease_classifier.pkl", "rb") as f:
7        data = pickle.load(f)
8    return data["model"], data["encoder"]
9
10def recommend_medicine(disease, medicine_df):
11    """Recommend medicines for a given disease based on composition and reviews."""
12    filtered_meds = medicine_df[medicine_df["Uses"].str.contains(disease, case=False, na=False)]
13    if filtered_meds.empty:
14        return "No medicine found for this disease."
15
16    # Sorting based on highest review scores
17    recommended = filtered_meds.sort_values(by=["Excellent Review %"], ascending=False)
18    return recommended[["Medicine Name", "Composition", "Side_effects", "Manufacturer", "Excellent Review %"]]
19
20# Load medicine dataset
21medicine_df = pd.read_csv("Medicine_Details.csv")
22
23# Example usage
24disease_input = "Bacterial infections"
25recommended_meds = recommend_medicine(disease_input, medicine_df)
26print(recommended_meds)