Akshit Chaturvedi
commited on
Commit
Β·
344e0b5
1
Parent(s):
29691ba
Updated dropdown names
Browse files
app.py
CHANGED
|
@@ -34,25 +34,48 @@ DEFAULT_PROPHET_PARAMS = {
|
|
| 34 |
'growth': 'linear'
|
| 35 |
}
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
# --- Load Model Hyperparameters ---
|
| 38 |
model_hyperparams_catalogue = {}
|
|
|
|
|
|
|
|
|
|
| 39 |
print("STARTUP INFO: Loading model hyperparameter configurations...")
|
| 40 |
if os.path.exists(MODEL_PARAMS_DIR):
|
| 41 |
for filename in os.listdir(MODEL_PARAMS_DIR):
|
| 42 |
if filename.startswith(MODEL_PARAMS_PREFIX) and filename.endswith(".json"):
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
#
|
| 46 |
-
model_hyperparams_catalogue[
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
else:
|
| 49 |
print(f"STARTUP WARNING: Model parameters directory '{MODEL_PARAMS_DIR}' not found.")
|
| 50 |
|
| 51 |
-
|
| 52 |
-
|
|
|
|
|
|
|
| 53 |
print("STARTUP WARNING: No model configurations loaded. Ticker dropdown will be empty.")
|
| 54 |
else:
|
| 55 |
-
print(f"STARTUP INFO: Available models for dropdown: {
|
| 56 |
|
| 57 |
# --- Data Fetching and Caching Logic ---
|
| 58 |
def load_data_cache():
|
|
@@ -312,7 +335,7 @@ with gr.Blocks(css="footer {visibility: hidden}", title="Stock/Commodity Forecas
|
|
| 312 |
with gr.Row():
|
| 313 |
with gr.Column(scale=1):
|
| 314 |
ticker_dropdown = gr.Dropdown(
|
| 315 |
-
choices=
|
| 316 |
label="Select Ticker Symbol",
|
| 317 |
info="Choose the stock/commodity to forecast."
|
| 318 |
)
|
|
|
|
| 34 |
'growth': 'linear'
|
| 35 |
}
|
| 36 |
|
| 37 |
+
# In app.py, near the top with other configurations
|
| 38 |
+
|
| 39 |
+
TICKER_TO_FULL_NAME = {
|
| 40 |
+
"DBA": "Invesco DB Agriculture Fund (DBA)",
|
| 41 |
+
"FCX": "Freeport-McMoRan Inc. (FCX)",
|
| 42 |
+
"GLD": "SPDR Gold Shares (GLD)",
|
| 43 |
+
"NEM": "Newmont Corporation (NEM)",
|
| 44 |
+
"SLV": "iShares Silver Trust (SLV)",
|
| 45 |
+
"UNG": "United States Natural Gas Fund (UNG)",
|
| 46 |
+
"USO": "United States Oil Fund (USO)",
|
| 47 |
+
"XOM": "Exxon Mobil Corporation (XOM)"
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
# --- Load Model Hyperparameters ---
|
| 51 |
model_hyperparams_catalogue = {}
|
| 52 |
+
# This will now store (display_name, ticker_symbol) for the dropdown
|
| 53 |
+
dropdown_choices = []
|
| 54 |
+
|
| 55 |
print("STARTUP INFO: Loading model hyperparameter configurations...")
|
| 56 |
if os.path.exists(MODEL_PARAMS_DIR):
|
| 57 |
for filename in os.listdir(MODEL_PARAMS_DIR):
|
| 58 |
if filename.startswith(MODEL_PARAMS_PREFIX) and filename.endswith(".json"):
|
| 59 |
+
ticker_symbol = filename.replace(MODEL_PARAMS_PREFIX, "").replace(".json", "")
|
| 60 |
+
|
| 61 |
+
# Store the actual hyperparameters with the ticker_symbol as the key
|
| 62 |
+
model_hyperparams_catalogue[ticker_symbol] = DEFAULT_PROPHET_PARAMS.copy() # Or load from JSON if needed
|
| 63 |
+
|
| 64 |
+
# Get the full name for display, default to ticker if not found
|
| 65 |
+
display_name = TICKER_TO_FULL_NAME.get(ticker_symbol, ticker_symbol)
|
| 66 |
+
dropdown_choices.append((display_name, ticker_symbol)) # (label, value) tuple
|
| 67 |
+
|
| 68 |
+
print(f"STARTUP INFO: Registered model config for: {ticker_symbol} (Display: {display_name})")
|
| 69 |
else:
|
| 70 |
print(f"STARTUP WARNING: Model parameters directory '{MODEL_PARAMS_DIR}' not found.")
|
| 71 |
|
| 72 |
+
# Sort dropdown choices by the display name (the first element of the tuple)
|
| 73 |
+
dropdown_choices = sorted(dropdown_choices, key=lambda x: x[0])
|
| 74 |
+
|
| 75 |
+
if not dropdown_choices:
|
| 76 |
print("STARTUP WARNING: No model configurations loaded. Ticker dropdown will be empty.")
|
| 77 |
else:
|
| 78 |
+
print(f"STARTUP INFO: Available models for dropdown: {dropdown_choices}")
|
| 79 |
|
| 80 |
# --- Data Fetching and Caching Logic ---
|
| 81 |
def load_data_cache():
|
|
|
|
| 335 |
with gr.Row():
|
| 336 |
with gr.Column(scale=1):
|
| 337 |
ticker_dropdown = gr.Dropdown(
|
| 338 |
+
choices=dropdown_choices, # Use the list of (label, value) tuples
|
| 339 |
label="Select Ticker Symbol",
|
| 340 |
info="Choose the stock/commodity to forecast."
|
| 341 |
)
|