Download README.md from dayun0071/NLP: direct link, hf CLI and curl.
- Browser
- Download file 7.08 kB
-
https://huggingface.co/datasets/dayun0071/NLP/resolve/main/README.md
- Command line
-
hf download hf://datasets/dayun0071/NLP/README.md
-
curl -L -o README.md https://huggingface.co/datasets/dayun0071/NLP/resolve/main/README.md
Financial headlines, topics, and large price moves
Question: How do headline language and topics relate to unusually large subsequent price moves, and how stable is that relationship across time?
Start with the HTML report or executed notebook. The course alignment guide explains the assignment connections and provides a seven-slide presentation outline.
Supplied lesson code and this revision
The Box notebook has the same 255 cell sources as the earlier supplied notebook. The dataset already matches its published labeled news dataset. The project now directly reuses the instructor's financial sentiment analyzer in course_baseline.py, reports its direction baseline on the original partitions, and then presents the Project 1 extensions separately. Preprocessing adaptations are documented; the baseline is not claimed to exactly reproduce the instructor's saved scores.
See lesson-to-project mapping, adapted baseline metrics, and original source partitions. The direction baseline and magnitude extension use different targets and partitions, so their scores are not an improvement comparison.
The revised presentation is Project_1_Course_Aligned_Presentation.pptx, with the five-minute script. It supersedes the earlier presentation. Present slides 1–7; slides 8–11 are backups.
Data and target
The attached ../news_data.csv contains individual headlines without return labels; it supports the raw-data audit. Supervised experiments use the public, labeled stock-day dataset referenced in the supplied lesson notebook: firobeid/SP_DOW_NASDAQ_stocks__News_Headlines_labeled, pinned to revision 35600ba11de0aa4de6a4d580c3e27dfcaa396677. Download URLs and SHA-256 hashes are recorded in source_manifest.json. The two sources have different units and coverage; their row counts are not interchangeable.
The target changes from the lesson's return direction to magnitude: class 1 means abs(returns) > 0.02; class 0 includes exactly 2% and smaller moves. This threshold is fixed before evaluation. The outcome uses supplied returns, not labels reconstructed from the unlabeled CSV.
Cleaning normalizes HTML entities and whitespace, removes invalid records, keeps one document per ticker/date, and retains only the earliest occurrence of each normalized full document. Return, price, ticker, and original partition fields are excluded from predictors.
Experiments and evaluation
The original partitions are combined and replaced with whole-date chronological windows:
| Dataset | Document dates |
|---|---|
| Train | Before March 25, 2020 |
| Test | April 1–June 23, 2020 |
| Inference | July 1, 2020 onward |
March 25–31 and June 24–30 are omitted. Model selection uses validation beginning February 1 within training; development fitting ends before January 25, leaving January 25–31 as another gap. These seven-calendar-day gaps are approximate precautions, not guarantees about unknown outcome horizons.
Five predetermined models are compared: majority-class dummy; Loughran–McDonald category rates, tone, and length with logistic regression; word-unigram TF-IDF with Naive Bayes; character 3–5-gram TF-IDF with Naive Bayes; and the same character representation with logistic regression. Validation macro-F1 selects the model, with balanced accuracy breaking ties. Models are refitted on full training data; the classification threshold remains 0.5. Held-out results do not change selection.
HW1 is represented through financial lexicon coverage and tone analysis. HW2 is represented through a fresh NMF baseline; no completed HW2 notebook was supplied. NMF fits eight topics on at most 20,000 sampled training documents, with up to 6,000 word/bigram features. Held-out documents use those fitted topics. Keywords, representative documents, topic frequencies, sentiment, and classification errors support interpretation; topic IDs are not ground-truth categories.
Results and files
Validation selected character TF-IDF with Naive Bayes. Its macro-F1 is 0.612 on train, 0.500 on test, and 0.522 on inference. On inference, macro-F1 exceeds the majority baseline's 0.419, but accuracy is lower (70.1% versus 72.2%) and large-move recall is only 16.0%. The evidence supports a weak retrospective signal, not a reliable forecasting system. See results interpretation for presentation-ready explanations of these tradeoffs.
- Computed findings: conclusions generated from the actual run.
- Model metrics, validation metrics, and split counts.
- Topic keywords, topic metrics, and inference errors.
- Figures and run metadata.
The notebook reports accuracy, balanced accuracy, macro-F1, large-move precision/recall, ROC-AUC, and average precision. Training scores are in-sample diagnostics. “Inference” is a later labeled historical holdout, not live unlabeled news.
Reproduce
Use Python 3.12. Keep news_data.csv and Loughran-McDonald_MasterDictionary_1993-2024.csv in the parent folder. Course PDFs and the lesson notebook are references, not runtime dependencies.
From this project1 folder, in PowerShell:
python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install -r requirements.txt
python fetch_course_data.py
python execute_notebook.py
On macOS/Linux, activate with source .venv/bin/activate instead. Downloading public data requires internet access but no Hugging Face token. Execution writes notebook outputs, HTML, figures, and result tables. build_notebook.py is an optional source generator: running it erases the notebook's saved outputs until execution completes again.
Interpretation limits
Daily headline timing, timezone, outcome construction, and price-adjustment metadata are not fully verified; after-close text may overlap the outcome interval. Source filtering already removes some extreme returns. Repeated stories may remain despite full-document deduplication. The 1993–2024 dictionary postdates the news sample and provides estimated tone, not human sentiment labels. Topic assignments are exploratory and model scores uncalibrated. Results describe retrospective associations; they establish neither causality nor trading profitability.