Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| from transformers import AutoTokenizer, AutoModelForSequenceClassification | |
| import torch | |
| # Load the pre-trained model and tokenizer from Hugging Face | |
| model_name = "tajuarAkash/test2" # Replace with your Hugging Face model path | |
| tokenizer = AutoTokenizer.from_pretrained(model_name) | |
| model = AutoModelForSequenceClassification.from_pretrained(model_name) | |
| # Title of the web app | |
| st.title("Fraud Detection in Health Insurance Claims") | |
| # Description of the app | |
| st.write("This app predicts whether a health insurance claim is fraudulent based on the input data.") | |
| # Create a text box for the user to input the generated sentence (feature for prediction) | |
| input_text = st.text_area("Enter the claim description") | |
| # Create a button to make predictions | |
| if st.button('Predict Fraud'): | |
| if input_text: | |
| # Tokenize the input text | |
| inputs = tokenizer(input_text, return_tensors="pt", padding=True, truncation=True, max_length=512) | |
| # Get model predictions | |
| with torch.no_grad(): | |
| logits = model(**inputs).logits | |
| predicted_class = torch.argmax(logits, dim=-1).item() | |
| # Display the result | |
| if predicted_class == 1: | |
| st.write("This claim is predicted to be fraudulent.") | |
| else: | |
| st.write("This claim is predicted to be legitimate.") | |
| else: | |
| st.write("Please enter a claim description.") | |