GenAICoder commited on
Commit
fe61379
·
verified ·
1 Parent(s): d421d9f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +92 -0
app.py ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import gradio as gr
3
+
4
+ from analytics.monitoring_analysis import generate_monitoring_table
5
+ from metrics.mix_metrics import (
6
+ calculate_count_mix,
7
+ calculate_limit_mix
8
+ )
9
+
10
+ # ------------------------
11
+ # Load Data
12
+ # ------------------------
13
+ acq = pd.read_csv("data/acquisition.csv")
14
+ perf = pd.read_csv("data/performance.csv")
15
+
16
+
17
+ # ------------------------
18
+ # Core Engine
19
+ # ------------------------
20
+ def run_analysis(dataset, analysis_type, group_col):
21
+
22
+ if dataset == "Acquisition":
23
+
24
+ df = acq
25
+
26
+ if analysis_type == "Count Mix":
27
+ return calculate_count_mix(df, group_col)
28
+
29
+ elif analysis_type == "Limit Mix":
30
+ return calculate_limit_mix(df, group_col)
31
+
32
+ else:
33
+ return "Invalid analysis type for Acquisition dataset"
34
+
35
+ elif dataset == "Performance":
36
+
37
+ df = perf
38
+
39
+ if analysis_type == "Vintage Monitoring Table":
40
+ return generate_monitoring_table(df)
41
+
42
+ else:
43
+ return "Invalid analysis type for Performance dataset"
44
+
45
+ else:
46
+ return "Invalid dataset selection"
47
+
48
+
49
+ # ------------------------
50
+ # Gradio UI
51
+ # ------------------------
52
+ with gr.Blocks() as app:
53
+
54
+ gr.Markdown("# 📊 Risk Analytics Manager Agent (V1)")
55
+
56
+ with gr.Row():
57
+
58
+ dataset = gr.Dropdown(
59
+ choices=["Acquisition", "Performance"],
60
+ label="Select Dataset"
61
+ )
62
+
63
+ analysis_type = gr.Dropdown(
64
+ choices=[
65
+ "Count Mix",
66
+ "Limit Mix",
67
+ "Vintage Monitoring Table"
68
+ ],
69
+ label="Select Analysis"
70
+ )
71
+
72
+ group_col = gr.Dropdown(
73
+ choices=[
74
+ "sourcing_channel",
75
+ "fico_band",
76
+ "city_tier",
77
+ "occupation_type"
78
+ ],
79
+ label="Group Column (for Mix)"
80
+ )
81
+
82
+ run_btn = gr.Button("Run Analysis")
83
+
84
+ output = gr.Dataframe()
85
+
86
+ run_btn.click(
87
+ fn=run_analysis,
88
+ inputs=[dataset, analysis_type, group_col],
89
+ outputs=output
90
+ )
91
+
92
+ app.launch()