import joblib import pandas as pd # Load the model and preprocessor model = joblib.load('random_forest_model.pkl') preprocessor = joblib.load('preprocessor.pkl') scaler = joblib.load('scaler.pkl') def fraud_detection(data): # Convert data to DataFrame df = pd.DataFrame([data]) # Preprocess the data X = preprocessor.transform(df) X_scaled = scaler.transform(X) # Predict prediction = model.predict(X_scaled) return {"fraud_prediction": int(prediction[0])}