Guided Project: Build a Sentiment Analyser in PyCharm

Train a machine learning model that tells positive reviews from negative ones, measure how good it really is, and find where it goes wrong.

Guided project, Beginner · Machine Learning · about 1.5 hours · 1 module · certificate on completion

Taught by Khalidà Sultàn, AI Learning Companion.

About this course

In this guided project you build a working sentiment analyser from scratch in PyCharm: a model that reads a short product review and says whether it's positive or negative. Three short lessons explain the ideas you need, how TF-IDF turns words into numbers, how logistic regression learns which words matter, and how to tell whether a classifier is any good, each shown step by step in PyCharm's Python Console, editor and debugger. Then you build it: you load 40 labelled reviews written for the project, train a scikit-learn pipeline, test it on reviews it hasn't seen, check it with cross-validation, look at the words it relies on, and try it on sentences of your own, including the ones that fool it. You finish with a model you understand, and a clear sense of what a small text classifier can and can't do.

What you'll learn

  • Turn short texts into numbers with TF-IDF
  • Train a logistic regression sentiment classifier in a scikit-learn pipeline
  • Evaluate it with a test set, a confusion matrix and cross-validation
  • Test it on new sentences and explain where and why it fails

Skills you'll gain

Sentiment analysis, Text classification, TF-IDF, Logistic regression, scikit-learn, Model evaluation, Cross-validation

Tools

PyCharm, Python, scikit-learn

Before you start

Basic Python: variables, lists, functions and running a script. PyCharm (the free version is enough) and Python 3 installed; you'll install scikit-learn in the first lesson.

Modules

  1. Build, evaluate and test a sentiment analyser

    Learn how text becomes numbers and how a classifier learns from them, then build a sentiment analyser, measure it honestly and probe its limits.

    • From words to numbers: bag of words and TF-IDF (8 min)
    • Training a classifier: logistic regression in a pipeline (10 min)
    • Is it any good? Evaluating a classifier, and its limits (10 min)
    • Hands-on lab: Build and test a sentiment analyser

PyCharm is a trademark of JetBrains s.r.o. This course is independent: JetBrains hasn't made or endorsed it.

Start the course free