Spaces:
Sleeping
Sleeping
File size: 1,917 Bytes
e7a17bb a63f856 15e767b 6503db3 689655e e7a17bb a63f856 e7a17bb f31e3bb 1292a32 e7a17bb 52ceadc 6298f5b cfb4d74 6298f5b a5fad7d cfb4d74 6298f5b cfb4d74 6298f5b fc0b527 c7179e8 46cede3 c7179e8 458f562 c7179e8 689655e |
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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# Importing data
import pandas as pd
from sklearn.linear_model import LogisticRegression
import numpy as np
from sklearn.ensemble import RandomForestClassifier
from sklearn.tree import DecisionTreeClassifier
from sklearn.ensemble import VotingClassifier
import joblib,os
import gradio as gr
script_dir=os.path.dirname(os.path.abspath(__file__))
model_path=os.path.join(script_dir,'model','EnsembleModel.joblib')
Ensemble_Model=joblib.load(model_path)
# Function
def Fraud(payments, min_pay, oneoff_p, purch, balance):
df=pd.DataFrame({'payments':[payments],'minimum_payments':[min_pay],
'oneoff_purchases':[oneoff_p],'purchases':[purch],
'balance':[balance]})
# prob={"Probability of Fraud": round(float(Ensemble_Model.predict_proba(df)[0][1]),4)}
prob= "The probability of fraud is: "+str(round(float(Ensemble_Model.predict_proba(df)[0][1]),4))
return prob
with gr.Blocks() as demo:
with gr.Row():
gr.Label('Fraud Detector 💰🏧💳', label='Alpha Bank™')
with gr.Row():
# gr.Image("model/alpha.jpg", scale=2)
gr.Markdown('Share the following monthly information for detecting fraud activity')
with gr.Row():
interface=[
gr.Slider(0,60000,label='Payments per month'),
gr.Slider(0,80000,label='Minimum payments per month'),
gr.Slider(0,50000, label='One-time purchases average amount'),
gr.Slider(0,50000, label='Subscription services regular payments '),
gr.Slider(0,25000, label='Balance amount')
]
with gr.Row():
predict_but=gr.Button('Analyse activity')
output= gr.Textbox(label='Result')
predict_but.click(fn=Fraud, inputs=interface, outputs=output)
if __name__ == "__main__":
# print("here")
# block1.launch()
demo.launch()
|