import gradio as gr import pickle # Load the model and the scaler with open("fraud_detection_model.pkl", "rb") as f: model = pickle.load(f) with open("scaler.pkl", "rb") as f: scaler = pickle.load(f) # Define a function for prediction def predict(input_data): input_data = [float(x) for x in input_data.split(",")] input_data = scaler.transform([input_data]) # Apply the scaling transformation prediction = model.predict(input_data) return "Fraud" if prediction[0] == 1 else "Not Fraud" # Updated Gradio Interface input_text = gr.Textbox(label="Input Features (comma-separated)", placeholder="Enter features like 1.2, 3.4, ...") output_text = gr.Textbox(label="Prediction") interface = gr.Interface( fn=predict, inputs=input_text, outputs=output_text, title="Fraud Detection System", description="Enter the features to predict whether it is fraud or not." ) # Run the application interface.launch()