File size: 1,429 Bytes
3849755
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import streamlit as st
import pandas as pd
from transformers import pipeline

# Load the dataset
@st.cache_data
def load_data():
    return pd.read_csv("insurance_data.csv")

data = load_data()

# Load NLP model for intent detection
@st.cache_resource
def load_nlp_model():
    return pipeline("text-classification", model="facebook/bart-large-mnli")

classifier = load_nlp_model()

# Streamlit UI
st.title("Health Insurance Coverage Assistant")
user_input = st.text_input("Enter your query (e.g., coverage for diabetes, best plans, etc.)")

if user_input:
    # Detect intent
    labels = ["coverage explanation", "plan recommendation"]
    result = classifier(user_input, candidate_labels=labels)
    intent = result["labels"][0]  # Get the most likely intent

    if intent == "coverage explanation":
        st.subheader("Coverage Details")
        condition_matches = data[data["Medical Condition"].str.contains(user_input, case=False, na=False)]
        if not condition_matches.empty:
            st.write(condition_matches)
        else:
            st.write("No specific coverage found for this condition.")
    
    elif intent == "plan recommendation":
        st.subheader("Recommended Plans")
        recommended_plans = data.sort_values(by=["Coverage (%)"], ascending=False).head(5)
        st.write(recommended_plans)
    
    else:
        st.write("Sorry, I couldn't understand your request. Please try again!")