Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -29,6 +29,9 @@ kmeans_artifact = joblib.load("kmeans_model.joblib")
|
|
| 29 |
kmeans_model = kmeans_artifact["model"]
|
| 30 |
cluster_scaler = kmeans_artifact["scaler"]
|
| 31 |
cluster_features_names = kmeans_artifact["feature_names"]
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
|
| 34 |
################### FEATURE GATHERING
|
|
@@ -129,11 +132,14 @@ def predict_volatility(date):
|
|
| 129 |
|
| 130 |
# Feature engineering
|
| 131 |
df = engineer_features(df)
|
| 132 |
-
df = df.dropna()
|
| 133 |
|
|
|
|
| 134 |
# Clustering
|
| 135 |
df = assign_cluster(df)
|
| 136 |
|
|
|
|
|
|
|
|
|
|
| 137 |
# ---------------- NOWCASTING ----------------
|
| 138 |
X_xgb = df.iloc[-1:][xgb_features]
|
| 139 |
X_ngb = df.iloc[-1:][ngb_features]
|
|
|
|
| 29 |
kmeans_model = kmeans_artifact["model"]
|
| 30 |
cluster_scaler = kmeans_artifact["scaler"]
|
| 31 |
cluster_features_names = kmeans_artifact["feature_names"]
|
| 32 |
+
if "cluster" in cluster_features_names:
|
| 33 |
+
raise ValueError("cluster_features_names must NOT include 'cluster'")
|
| 34 |
+
|
| 35 |
|
| 36 |
|
| 37 |
################### FEATURE GATHERING
|
|
|
|
| 132 |
|
| 133 |
# Feature engineering
|
| 134 |
df = engineer_features(df)
|
|
|
|
| 135 |
|
| 136 |
+
# Clustering
|
| 137 |
# Clustering
|
| 138 |
df = assign_cluster(df)
|
| 139 |
|
| 140 |
+
assert "cluster" in df.columns, "Cluster feature missing after assignment"
|
| 141 |
+
|
| 142 |
+
|
| 143 |
# ---------------- NOWCASTING ----------------
|
| 144 |
X_xgb = df.iloc[-1:][xgb_features]
|
| 145 |
X_ngb = df.iloc[-1:][ngb_features]
|