Spaces:
Runtime error
Runtime error
Akshit Chaturvedi commited on
Commit ·
d3b8d4d
1
Parent(s): 0fbbfa6
updated readme
Browse files
app.py
CHANGED
|
@@ -36,8 +36,8 @@ def predict_stock(ticker):
|
|
| 36 |
if not ticker:
|
| 37 |
return "⚠️ Please enter a ticker symbol.", None, None
|
| 38 |
|
| 39 |
-
|
| 40 |
-
print(f"Processing {ticker}")
|
| 41 |
|
| 42 |
try:
|
| 43 |
# 1. Get Data
|
|
@@ -55,7 +55,6 @@ def predict_stock(ticker):
|
|
| 55 |
if 'Close' in df.columns:
|
| 56 |
df = df[['Close']].reset_index()
|
| 57 |
else:
|
| 58 |
-
# Fallback for single level extraction
|
| 59 |
df = data['Close'].reset_index()
|
| 60 |
except:
|
| 61 |
# Brute force flatten
|
|
@@ -77,13 +76,12 @@ def predict_stock(ticker):
|
|
| 77 |
return f"❌ Not enough historical data found for {ticker} (Need > 100 days).", None, None
|
| 78 |
|
| 79 |
# 2. Train Model
|
|
|
|
| 80 |
m = NeuralProphet(
|
| 81 |
yearly_seasonality=True,
|
| 82 |
weekly_seasonality=True,
|
| 83 |
daily_seasonality=False,
|
| 84 |
-
learning_rate=0.01
|
| 85 |
-
# Disable progress bars for clean logs
|
| 86 |
-
trainer_config={"enable_progress_bar": False}
|
| 87 |
)
|
| 88 |
|
| 89 |
m.fit(df, freq="D")
|
|
@@ -117,7 +115,7 @@ def predict_stock(ticker):
|
|
| 117 |
"""
|
| 118 |
|
| 119 |
# 6. Generate Plots
|
| 120 |
-
#
|
| 121 |
fig_forecast = m.plot(forecast)
|
| 122 |
fig_components = m.plot_components(forecast)
|
| 123 |
|
|
|
|
| 36 |
if not ticker:
|
| 37 |
return "⚠️ Please enter a ticker symbol.", None, None
|
| 38 |
|
| 39 |
+
# Status update for the logs
|
| 40 |
+
print(f"Processing {ticker}...")
|
| 41 |
|
| 42 |
try:
|
| 43 |
# 1. Get Data
|
|
|
|
| 55 |
if 'Close' in df.columns:
|
| 56 |
df = df[['Close']].reset_index()
|
| 57 |
else:
|
|
|
|
| 58 |
df = data['Close'].reset_index()
|
| 59 |
except:
|
| 60 |
# Brute force flatten
|
|
|
|
| 76 |
return f"❌ Not enough historical data found for {ticker} (Need > 100 days).", None, None
|
| 77 |
|
| 78 |
# 2. Train Model
|
| 79 |
+
# FIX: Removed 'trainer_config' to prevent PyTorch Lightning crash
|
| 80 |
m = NeuralProphet(
|
| 81 |
yearly_seasonality=True,
|
| 82 |
weekly_seasonality=True,
|
| 83 |
daily_seasonality=False,
|
| 84 |
+
learning_rate=0.01
|
|
|
|
|
|
|
| 85 |
)
|
| 86 |
|
| 87 |
m.fit(df, freq="D")
|
|
|
|
| 115 |
"""
|
| 116 |
|
| 117 |
# 6. Generate Plots
|
| 118 |
+
# Note: We rely on standard m.plot() which returns a plotly figure
|
| 119 |
fig_forecast = m.plot(forecast)
|
| 120 |
fig_components = m.plot_components(forecast)
|
| 121 |
|