gaur3009 commited on
Commit
cdbf43b
·
verified ·
1 Parent(s): 3bae845

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -60,7 +60,6 @@ class GANRiskAnalyzer:
60
  generated_data = self.generator(z)
61
  return generated_data.detach().numpy()
62
 
63
- # Risk Analysis
64
  def analyze_financial_data(file):
65
  try:
66
  # Read the uploaded Excel or CSV file
@@ -85,6 +84,13 @@ def analyze_financial_data(file):
85
  if X.empty or y.empty:
86
  return {"error": "The data contains missing values or invalid rows after cleaning."}
87
 
 
 
 
 
 
 
 
88
  scaler = StandardScaler()
89
  X_scaled = scaler.fit_transform(X)
90
 
@@ -114,6 +120,7 @@ def analyze_financial_data(file):
114
 
115
  return insights
116
 
 
117
  # Gradio Interface
118
  with gr.Blocks(theme=gr.themes.Monochrome()) as interface:
119
  gr.Markdown("# **AI Risk Analyst Agent**")
 
60
  generated_data = self.generator(z)
61
  return generated_data.detach().numpy()
62
 
 
63
  def analyze_financial_data(file):
64
  try:
65
  # Read the uploaded Excel or CSV file
 
84
  if X.empty or y.empty:
85
  return {"error": "The data contains missing values or invalid rows after cleaning."}
86
 
87
+ # Handle categorical data by encoding it
88
+ X = pd.get_dummies(X, drop_first=True) # One-hot encoding for categorical columns
89
+
90
+ # Convert target column to numeric if needed
91
+ if y.dtype == 'object':
92
+ y = y.astype('category').cat.codes # Convert to numeric labels
93
+
94
  scaler = StandardScaler()
95
  X_scaled = scaler.fit_transform(X)
96
 
 
120
 
121
  return insights
122
 
123
+
124
  # Gradio Interface
125
  with gr.Blocks(theme=gr.themes.Monochrome()) as interface:
126
  gr.Markdown("# **AI Risk Analyst Agent**")