CoolFace
Apppublic

annikumar/MLmodel

sourceHugging Faceopenrailupdated 3y agoView on Hugging Face
0likes
app.py26 linesDownload Raw Back to root
1import pandas as pd2import numpy as np3import pickle4import gradio as gr5from sklearn.model_selection import train_test_split6from sklearn.tree import DecisionTreeClassifier7with open("frauddetect.pkl", "rb") as f:8  clf = pickle.load(f)9def make_prediction(typ,amount,oldbal,newbal):10    with open("frauddetect.pkl", "rb") as f:11        clf  = pickle.load(f)12        preds = clf.predict([[typ,amount,oldbal,newbal]])13    if preds[0] == 'Fraud':14            return "This is a Fraud Transaction"15    return "This is not a Fraud Transaction"16 17#Create the input component for Gradio since we are expecting 4 inputs18 19type_input = gr.Number(label = "Enter Type of Transaction 1 for CASH_OUT,2 for PAYMENT,3 for CASH_IN,4 for TRANSFER,5 for DEBIT")20amount_input = gr.Number(label= "Enter the amount")21old_input = gr.Number(label = "Enter the Old Balance")22new_input = gr.Number(label = "Enter the New Balance:")23# We create the output24output = gr.Textbox()25app = gr.Interface(fn = make_prediction, inputs=[type_input, amount_input, old_input, new_input], outputs=output)26app.launch()