Spaces:
Running
Running
Sync from GitHub
Browse files- app/ai_engine.py +6 -5
app/ai_engine.py
CHANGED
|
@@ -234,13 +234,14 @@ def aggregate_daily_sentiment(
|
|
| 234 |
for date, group in df.groupby("date"):
|
| 235 |
weights = calc_weights(group)
|
| 236 |
|
|
|
|
| 237 |
daily_data.append({
|
| 238 |
"date": date,
|
| 239 |
-
"sentiment_index": (group["score"] * weights).sum(),
|
| 240 |
-
"news_count": len(group),
|
| 241 |
-
"avg_positive": group["prob_positive"].mean(),
|
| 242 |
-
"avg_neutral": group["prob_neutral"].mean(),
|
| 243 |
-
"avg_negative": group["prob_negative"].mean(),
|
| 244 |
})
|
| 245 |
|
| 246 |
# Upsert daily sentiments
|
|
|
|
| 234 |
for date, group in df.groupby("date"):
|
| 235 |
weights = calc_weights(group)
|
| 236 |
|
| 237 |
+
# Convert numpy types to native Python types for database compatibility
|
| 238 |
daily_data.append({
|
| 239 |
"date": date,
|
| 240 |
+
"sentiment_index": float((group["score"] * weights).sum()),
|
| 241 |
+
"news_count": int(len(group)),
|
| 242 |
+
"avg_positive": float(group["prob_positive"].mean()),
|
| 243 |
+
"avg_neutral": float(group["prob_neutral"].mean()),
|
| 244 |
+
"avg_negative": float(group["prob_negative"].mean()),
|
| 245 |
})
|
| 246 |
|
| 247 |
# Upsert daily sentiments
|