mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-21 02:19:59 +08:00
35 lines
1.3 KiB
Python
35 lines
1.3 KiB
Python
import gradio as gr
|
|
import pandas as pd
|
|
import random
|
|
|
|
|
|
def fraud_detector(card_activity, categories, sensitivity):
|
|
activity_range = random.randint(0, 100)
|
|
drop_columns = [column for column in ["retail", "food", "other"] if column not in categories]
|
|
if len(drop_columns):
|
|
card_activity.drop(columns=drop_columns, inplace=True)
|
|
return card_activity, card_activity, {"fraud": activity_range / 100., "not fraud": 1 - activity_range / 100.}
|
|
|
|
|
|
iface = gr.Interface(fraud_detector,
|
|
[
|
|
gr.inputs.Timeseries(
|
|
x="time",
|
|
y=["retail", "food", "other"]
|
|
),
|
|
gr.inputs.CheckboxGroup(["retail", "food", "other"], default=[
|
|
"retail", "food", "other"]),
|
|
gr.inputs.Slider(1, 3)
|
|
],
|
|
[
|
|
"dataframe",
|
|
gr.outputs.Timeseries(
|
|
x="time",
|
|
y=["retail", "food", "other"]
|
|
),
|
|
gr.outputs.Label(label="Fraud Level"),
|
|
]
|
|
)
|
|
if __name__ == "__main__":
|
|
iface.launch()
|