Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -254,13 +254,32 @@ def main():
|
|
| 254 |
# ---------------------------------------------------------
|
| 255 |
correlation = plot_data['price'].corr(plot_data['avg_sentiment'])
|
| 256 |
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 260 |
elif correlation < -0.5:
|
| 261 |
-
corr_text = "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 262 |
|
| 263 |
-
st.metric("วิเคราะห์ความสัมพันธ์ระหว่างอารมณ์ของข่าวกับราคาหุ้น (Correlation)", corr_text, f"{correlation:.2f}")
|
| 264 |
|
| 265 |
# ---------------------------------------------------------
|
| 266 |
# Forecast Sentiment
|
|
|
|
| 254 |
# ---------------------------------------------------------
|
| 255 |
correlation = plot_data['price'].corr(plot_data['avg_sentiment'])
|
| 256 |
|
| 257 |
+
# Default text
|
| 258 |
+
corr_text = "ไม่มีความสัมพันธ์กัน"
|
| 259 |
+
|
| 260 |
+
# Positive correlations
|
| 261 |
+
if correlation > 0.75:
|
| 262 |
+
corr_text = f"Correlation = {correlation:.2f} มีความสัมพันธ์กันอย่างมากในทิศทางเดียวกัน"
|
| 263 |
+
elif correlation > 0.5:
|
| 264 |
+
corr_text = f"Correlation = {correlation:.2f} มีความสัมพันธ์กันปานกลางในทิศทางเดียวกัน"
|
| 265 |
+
elif correlation > 0.25:
|
| 266 |
+
corr_text = f"Correlation = {correlation:.2f} มีความสัมพันธ์กันเล็กน้อยในทิศทางเดียวกัน"
|
| 267 |
+
|
| 268 |
+
# Negative correlations
|
| 269 |
+
elif correlation < -0.75:
|
| 270 |
+
corr_text = f"Correlation = {correlation:.2f} มีความสัมพันธ์กันอย่างมากในทิศทางตรงกันข้าม"
|
| 271 |
elif correlation < -0.5:
|
| 272 |
+
corr_text = f"Correlation = {correlation:.2f} มีความสัมพันธ์กันปานกลางในทิศทางตรงกันข้าม"
|
| 273 |
+
elif correlation < -0.25:
|
| 274 |
+
corr_text = f"Correlation = {correlation:.2f} มีความสัมพันธ์กันเล็กน้อยในทิศทางตรงกันข้าม"
|
| 275 |
+
|
| 276 |
+
# ไม่มีความสัมพันธ์ (between -0.25 and 0.25)
|
| 277 |
+
else:
|
| 278 |
+
corr_text = f"Correlation = {correlation:.2f} ไม่มีความสัมพันธ์กัน"
|
| 279 |
+
|
| 280 |
+
# Show metric
|
| 281 |
+
st.metric("วิเคราะห์ความสัมพันธ์ระหว่างอารมณ์ของข่าวกับราคาหุ้น", corr_text, f"{correlation:.2f}")
|
| 282 |
|
|
|
|
| 283 |
|
| 284 |
# ---------------------------------------------------------
|
| 285 |
# Forecast Sentiment
|