This is the reference solution for the AI110 Module 3 Tinker The Mood Machine. The stubbed methods are implemented, the dataset is expanded, and the model card is filled in, so you can compare it against the classifier you built. It is one reasonable solution, not the only correct one — the goal of the lab is honest reasoning about model behavior, not a perfect accuracy score.
Starter repo:
ai110-module3tinker-themoodmachine-starter
pip install -r requirements.txt
python main.py # rule-based model + interactive loop
python ml_experiments.py # scikit-learn model on the same datamood_analyzer.pypreprocess— lowercases, splits, strips edge punctuation, and preserves emoji/emoticon tokens.score_text— ±1 per matched word, with negation handling: a negation word ("not", "never", …) flips the sign of the next few sentiment words, so "not happy" scores negative. (Negation is the required modeling enhancement.)predict_label— returnsmixedwhen both positive and negative signals fire, otherwise maps the score's sign topositive/negative/neutral.explain— reports the score and the exact positive/negative tokens behind a prediction.
dataset.py— word lists expanded (incl. a few emojis/emoticons);SAMPLE_POSTSgrown to 15 with slang, sarcasm, emojis, and mixed-feeling posts, all with alignedTRUE_LABELS.model_card.md— filled in with grounded examples of correct and incorrect predictions.
- Rule-based accuracy ≈ 0.87. The two misses are both sarcasm — "I absolutely love getting stuck in traffic" and "wow amazing another meeting" — which token counting cannot detect. That failure is the lesson, and it's documented in the model card.
- ML accuracy = 1.00 on the training set. That looks better, but it's only because the model memorized the 15 examples it was trained on. On genuinely new sarcastic text it would fail the same way. Small data → confident but fragile.
If your rule-based model handles simple negation, returns a sensible label for obvious cases, and you can explain why it gets sarcasm wrong, you've hit the objectives. Matching this exemplar's exact accuracy is not the goal — being able to trace and document each prediction is.