Country
You are in the Nigeria edition. Type your country to switch.
Nigeria
Loading every country…
No country matches. Check the spelling, or choose "Any country" for the Global edition.
Your learning profile
Financial Data Lab · Lesson 6 of 8
Lab 6: a sentiment classifier on sample headlines
This lab builds the simplest possible sentiment classifier, a word list that scores invented headlines as positive or negative, and measures it honestly with a confusion matrix, accuracy and precision. It then shows where word counting fails: negation, finance-specific meanings and headlines that are neutral.
This lesson is complete in writing. A video for it is on its way.
What you will learn
- By the end you can build a word-list sentiment classifier for headlines in a few lines of Python.
- You can measure it honestly on headlines labelled by people, using accuracy and a confusion matrix.
- You can work out precision and recall for one class from a confusion matrix.
- You can explain why negation, finance-specific words and tuning on the test headlines lead to misleading results.
Key terms in this lesson
- Sentiment analysis
- Scoring text as positive, negative or neutral in tone. In finance it is applied to news, filings and call transcripts, and it often misreads context and negation.
- Label
- The answer a supervised model is trained to predict, such as whether a loan was repaid or next month's return. Choosing the label is a design decision that shapes everything the model learns.
- Classification accuracy
- The share of cases a classifier labels correctly. It can mislead when one class is much more common than another.
- Confusion matrix
- A table that compares a classifier's answers with the true labels, counting correct and incorrect results for each class. It shows which mistakes a model makes, which accuracy alone hides.
- Overfitting
- Tuning a model or strategy so closely to past data that it captures noise and fails on new data.
- Test set
- Data kept aside and not used to build or tune a model, so it gives an honest check of performance on unseen cases. It loses its value if it is used again and again.
- Step 1: The simplest classifier there is, not started
- Step 2: The labelled headlines and the code, not started
- Step 3: Measuring it honestly, not started
- Step 4: Where word counting fails, not started
- Step 5: The tuning trap, not started
About 9 min of reading
Step 1 of 5
The simplest classifier there is
Opening this step…
Step 2 of 5
The labelled headlines and the code
This step opens when you finish the one above.
Step 3 of 5
Measuring it honestly
This step opens when you finish the one above.
Step 4 of 5
Where word counting fails
This step opens when you finish the one above.
Step 5 of 5
The tuning trap
This step opens when you finish the one above.
Key takeaways
The key takeaways open when you finish every step.
Lesson quiz
6 questions. You need 85% to pass.
The quiz opens when you finish every step.
Read first
Stockertim Learn is education. It explains how investing works and never recommends buying or selling anything.
Popular this week: Basics: BeginnerStock market: Intermediate