O'Reilly logo
live online training icon Live Online training

Sentiment analysis for chatbots in Python

Building sentiment analysis methods for bots

Karol Przystalski
Kacper Lukawski

Sentiment analysis is, in many cases, a must-have feature when building a chatbot. In this hands-on three-hour training, Karol Przystalski walks you through the process of developing a chatbot that can perform sentiment analysis. You'll learn about data processing, focusing on data cleanup, the word vectorization process in Python, and how to use decision trees to build a simple sentiment analysis model based on tweets. Join in to discover how to measure the emotions behind your users’ sentences and apply a response strategy.

What you'll learn-and how you can apply it

By the end of this live, online course, you’ll understand:

  • How to prepare data for word vectorization
  • The process of developing a sentiment analysis method
  • How word vectorization and decision trees work

And you’ll be able to:

  • Build vectorization methods using common solutions in Python
  • Develop sentiment analysis methods
  • Clean and prepare your data for word vectorization using common Python libraries

This training course is for you because...

  • You're a data scientist with little to no experience with bots, natural language processing, or natural language understanding.
  • You're a Python developer who wants to extend your knowledge of bots for practical usage.
  • You're a developer who wants to extend your knowledge of Python for machine learning.


  • A working knowledge of Python
  • A basic understanding of machine learning (useful but not required)

Recommended preparation:

About your instructor

  • Karol Przystalski is CTO and founder of Codete. He obtained a Ph.D in Computer Science from the Institute of Fundamental Technological Research, Polish Academy of Sciences, and was a research assistant at Jagiellonian University in Cracow. His role at Codete is focused on leading and mentoring teams. The company has built a research lab that is working on machine learning methods and big data solutions in specialty areas such as pattern recognition and HDP implementation.

  • Kacper Lukawski is a Data Engineer and Tech Lead at Codete. He is currently involved in big data projects and internal research in the field of machine learning, and is enthusiastic about applying data science in various sectors.


The timeframes are only estimates and may vary according to how the class is progressing

Data cleaning (10 minutes)

  • Lecture: Introduction to data cleaning in Python

Preparing your data (40 minutes)

  • Lecture: Preparing Twitter data for word vectorization
  • Hands-on exercise: Use Python tools for data preparation

Break (10 minutes)

Word representation methods (35 minutes)

  • Lecture: Overview of methods—bag-of-words, tf-idf, word2vec
  • Hands-on exercise: Implement a bag-of-words model

Sentiment analysis method (15 minutes)

  • Lecture: Building a sentiment analysis method

Break (10 minutes)

Random forest for sentiment analysis (50 minutes)

  • Lecture: Overview and usage of random forest for sentiment analysis
  • Hands-on exercise: Use random forest for sentiment analysis

Available sentiment analysis libraries (10 minutes)