|
import streamlit as st |
|
import joblib |
|
import numpy as np |
|
import pandas as pd |
|
from sklearn.preprocessing import StandardScaler |
|
from huggingface_hub import hf_hub_download |
|
|
|
|
|
model_path = hf_hub_download(repo_id="tajuarAkash/Health_Insurance_Fraud_detection_using_Random_forest", filename="random_forest_model.joblib") |
|
|
|
|
|
model = joblib.load(model_path) |
|
|
|
|
|
st.title("Insurance Claim Fraud Detection") |
|
st.write(""" |
|
This app predicts whether an insurance claim is fraudulent or legitimate based on user input. |
|
Please enter the information below. |
|
""") |
|
|
|
|
|
claim_amount = st.number_input("Enter the claim amount", min_value=0) |
|
patient_age = st.number_input("Enter the patient's age", min_value=0) |
|
patient_income = st.number_input("Enter the patient's income", min_value=0) |
|
patient_gender = st.selectbox("Select patient's gender", ["Male", "Female"]) |
|
claim_status = st.selectbox("Claim status", ["Denied", "Pending", "Approved"]) |
|
|
|
|
|
if st.button('Predict Fraud'): |
|
|
|
input_data = { |
|
"ClaimAmount": [claim_amount], |
|
"PatientAge": [patient_age], |
|
"PatientIncome": [patient_income], |
|
"PatientGender": [patient_gender], |
|
"ClaimStatus": [claim_status], |
|
} |
|
|
|
|
|
input_df = pd.DataFrame(input_data) |
|
|
|
|
|
input_df['PatientGender'] = input_df['PatientGender'].apply(lambda x: 1 if x == 'Male' else 0) |
|
|
|
|
|
claim_status_mapping = {"Denied": 0, "Pending": 1, "Approved": 2} |
|
input_df['ClaimStatus'] = input_df['ClaimStatus'].map(claim_status_mapping) |
|
|
|
|
|
scaler = StandardScaler() |
|
input_scaled = scaler.fit_transform(input_df) |
|
|
|
|
|
prediction = model.predict(input_scaled) |
|
|
|
|
|
if prediction == 1: |
|
st.write("This claim is predicted to be **fraudulent**.") |
|
else: |
|
st.write("This claim is predicted to be **legitimate**.") |
|
|