area444 commited on
Commit
fd37136
·
verified ·
1 Parent(s): e808628

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -10
app.py CHANGED
@@ -76,7 +76,7 @@ def get_month_label(i):
76
  #df['revenue'] = (df['vintage_unique_cases'] / df['predicted_monthly_payment_rate']).round(2)
77
  #df['Month'] = [get_month_label(i) for i in range(len(df))]
78
  df = pd.DataFrame()
79
- df_2 = pd.DataFrame()
80
 
81
  def update_table(start_date, end_date, window, user_text):
82
  #############################################################################################
@@ -122,10 +122,10 @@ def update_table(start_date, end_date, window, user_text):
122
  time.sleep(30)
123
 
124
  print(f"Run ID: {run_id}")
125
- data_payments = get_databricks_file("dbfs:/dbfs/FileStore/forecast_alleviatetax_payments_"+str(user_text).split('@')[0]+".csv")
126
  #data_metrics = get_databricks_file("dbfs:/dbfs/FileStore/forecast_alleviatetax_metrics.csv")
127
  data_predictions = get_databricks_file("dbfs:/dbfs/FileStore/forecast_alleviatetax_predictions_"+str(user_text).split('@')[0]+".csv")
128
- df_payments = pd.read_csv(StringIO(data_payments.decode('utf-8')))
129
  #new_columns = ['vintage', 'vintage_unique_cases'] + [f'M{col}' for col in df_payments.columns[2:]]
130
  #df_metrics = pd.read_csv(StringIO(data_metrics.decode('utf-8')))
131
  df_predictions = pd.read_csv(StringIO(data_predictions.decode('utf-8')))
@@ -135,10 +135,10 @@ def update_table(start_date, end_date, window, user_text):
135
  return {error: str(e)}
136
  #############################################################################################
137
  global df # Use global variable
138
- global df_2
139
  df = df_predictions.copy()
140
- df_2 = df_payments.copy()
141
- return df, df_2
142
 
143
  def save_csv(file_name):
144
  global df # Use global variable
@@ -180,11 +180,12 @@ with gr.Blocks(fill_height=True) as demo:
180
  range_input = gr.Slider(3, 12, 6, label="Window / Moving Average Period")
181
  gr.Markdown("Window = 3-period/months, the predictive model reacts more quickly to recent monthly payment fluctuations, but it may also include more noise.<br><br>Window = 12-period/months, the Forecast adjusts more slowly and is less sensitive to small fluctuations, making it more reliable, but also slower to react to sharp changes.")
182
 
183
- table_1 = gr.DataFrame(value=df, label="Predictions (consult 'revenue' column):")
184
- btn_update = gr.Button("Run Forecast")
185
 
186
- table_2 = gr.DataFrame(value=df_2, label="Forecast Inputs:")
187
- btn_update.click(fn=update_table, inputs=[start_input, prediction_input, range_input, user_text], outputs=[table_1,table_2])
 
188
 
189
 
190
  # Configure the buttons and the panel visibility
 
76
  #df['revenue'] = (df['vintage_unique_cases'] / df['predicted_monthly_payment_rate']).round(2)
77
  #df['Month'] = [get_month_label(i) for i in range(len(df))]
78
  df = pd.DataFrame()
79
+ #df_2 = pd.DataFrame()
80
 
81
  def update_table(start_date, end_date, window, user_text):
82
  #############################################################################################
 
122
  time.sleep(30)
123
 
124
  print(f"Run ID: {run_id}")
125
+ #data_payments = get_databricks_file("dbfs:/dbfs/FileStore/forecast_alleviatetax_payments_"+str(user_text).split('@')[0]+".csv")
126
  #data_metrics = get_databricks_file("dbfs:/dbfs/FileStore/forecast_alleviatetax_metrics.csv")
127
  data_predictions = get_databricks_file("dbfs:/dbfs/FileStore/forecast_alleviatetax_predictions_"+str(user_text).split('@')[0]+".csv")
128
+ #df_payments = pd.read_csv(StringIO(data_payments.decode('utf-8')))
129
  #new_columns = ['vintage', 'vintage_unique_cases'] + [f'M{col}' for col in df_payments.columns[2:]]
130
  #df_metrics = pd.read_csv(StringIO(data_metrics.decode('utf-8')))
131
  df_predictions = pd.read_csv(StringIO(data_predictions.decode('utf-8')))
 
135
  return {error: str(e)}
136
  #############################################################################################
137
  global df # Use global variable
138
+ #global df_2
139
  df = df_predictions.copy()
140
+ #df_2 = df_payments.copy()
141
+ return df#, df_2
142
 
143
  def save_csv(file_name):
144
  global df # Use global variable
 
180
  range_input = gr.Slider(3, 12, 6, label="Window / Moving Average Period")
181
  gr.Markdown("Window = 3-period/months, the predictive model reacts more quickly to recent monthly payment fluctuations, but it may also include more noise.<br><br>Window = 12-period/months, the Forecast adjusts more slowly and is less sensitive to small fluctuations, making it more reliable, but also slower to react to sharp changes.")
182
 
183
+ table_1 = gr.DataFrame(value=df, label="Predictions (consult 'revenue' column):")
184
+ btn_update = gr.Button("Run Forecast")
185
 
186
+ #table_2 = gr.DataFrame(value=df_2, label="Forecast Inputs:")
187
+ btn_update.click(fn=update_table, inputs=[start_input, prediction_input, range_input, user_text], outputs=[table_1#,table_2
188
+ ])
189
 
190
 
191
  # Configure the buttons and the panel visibility