Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -162,12 +162,24 @@ description_text = """
|
|
| 162 |
|
| 163 |
This dashboard allows you to explore the sentiment of news articles related to major tech companies (Apple, Tesla, Microsoft, Meta, Alphabet) and compare it with their stock prices.
|
| 164 |
|
| 165 |
-
- **Multiple companies per news**: Some news articles mention more than one company. Each news item is associated with the relevant companies in the dataset.
|
| 166 |
- **Dataset structure**: The dataset includes a company column; each row corresponds to a news item for a specific company.
|
| 167 |
- **Sentiment aggregation**: Select a time aggregation level (Month or Year) to see how sentiment evolves over time.
|
| 168 |
- **NASDAQ comparison**: Selecting "NASDAQ" shows the general market sentiment alongside the company-specific sentiment.
|
| 169 |
- **Visual insights**: Top-left graph shows average sentiment score and closing price for the selected company.
|
| 170 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
|
| 172 |
# --- Input options ---
|
| 173 |
companies = sorted(df['Company'].unique().tolist()) + ["NASDAQ"]
|
|
@@ -184,7 +196,7 @@ with gr.Blocks() as demo:
|
|
| 184 |
dropdown_companies = gr.Dropdown(
|
| 185 |
choices=companies,
|
| 186 |
value=None,
|
| 187 |
-
multiselect=
|
| 188 |
label="Select Companies"
|
| 189 |
)
|
| 190 |
|
|
@@ -206,6 +218,9 @@ with gr.Blocks() as demo:
|
|
| 206 |
# Output
|
| 207 |
data_table = gr.Dataframe(label="Sentiment Table", type="pandas")
|
| 208 |
sentiment_plot = gr.Plot(label="Sentiment Trend")
|
|
|
|
|
|
|
|
|
|
| 209 |
|
| 210 |
|
| 211 |
submit_btn.click(
|
|
|
|
| 162 |
|
| 163 |
This dashboard allows you to explore the sentiment of news articles related to major tech companies (Apple, Tesla, Microsoft, Meta, Alphabet) and compare it with their stock prices.
|
| 164 |
|
|
|
|
| 165 |
- **Dataset structure**: The dataset includes a company column; each row corresponds to a news item for a specific company.
|
| 166 |
- **Sentiment aggregation**: Select a time aggregation level (Month or Year) to see how sentiment evolves over time.
|
| 167 |
- **NASDAQ comparison**: Selecting "NASDAQ" shows the general market sentiment alongside the company-specific sentiment.
|
| 168 |
- **Visual insights**: Top-left graph shows average sentiment score and closing price for the selected company.
|
| 169 |
"""
|
| 170 |
+
# --- Findings from thesis (specific companies and years) ---
|
| 171 |
+
findings_text = """
|
| 172 |
+
### Key Findings
|
| 173 |
+
|
| 174 |
+
- Some news articles refer to multiple companies, e.g., the same article may mention Apple and Tesla.
|
| 175 |
+
- Merging news with stock prices allows analyzing correlations between sentiment and stock movements for each company.
|
| 176 |
+
- **Apple (2018, 2019, 2022):** Sentiment trends generally align with closing prices, showing similar monthly patterns.
|
| 177 |
+
- **Tesla (2018, 2019, 2022):** More volatility observed; sentiment aligns with stock movement but is more sensitive to news on Elon Musk’s actions.
|
| 178 |
+
- **Microsoft, Meta, Alphabet:** Across periods, sentiment trends follow stock prices with moderate correlation.
|
| 179 |
+
- The custom sentiment model is more aligned with actual stock movements compared to FinBERT, which is more influenced by word positivity/negativity.
|
| 180 |
+
- Aggregating sentiment by month or year helps identify broader trends while reducing noise from daily fluctuations.
|
| 181 |
+
- Including “NASDAQ” as a general market reference allows comparison of individual companies’ sentiment with overall market sentiment.
|
| 182 |
+
"""
|
| 183 |
|
| 184 |
# --- Input options ---
|
| 185 |
companies = sorted(df['Company'].unique().tolist()) + ["NASDAQ"]
|
|
|
|
| 196 |
dropdown_companies = gr.Dropdown(
|
| 197 |
choices=companies,
|
| 198 |
value=None,
|
| 199 |
+
multiselect=False,
|
| 200 |
label="Select Companies"
|
| 201 |
)
|
| 202 |
|
|
|
|
| 218 |
# Output
|
| 219 |
data_table = gr.Dataframe(label="Sentiment Table", type="pandas")
|
| 220 |
sentiment_plot = gr.Plot(label="Sentiment Trend")
|
| 221 |
+
|
| 222 |
+
# Findings section
|
| 223 |
+
gr.Markdown(findings_text)
|
| 224 |
|
| 225 |
|
| 226 |
submit_btn.click(
|