Unsupervised Machine Learning: Hidden Markov Models in Python

HMMs for stock price analysis, language modeling, web analytics, biology, and PageRank.

Register for this Course

$29.99 $199.99 USD 85% OFF!

Login or signup to register for this course

Have a coupon? Click here.

Course Data

Lectures: 76
Length: 10h 40m
Skill Level: All Levels
Languages: English
Includes: Lifetime access, certificate of completion (shareable on LinkedIn, Facebook, and Twitter), Q&A forum

Course Description

The Hidden Markov Model or HMM is all about learning sequences.

A lot of the data that would be very useful for us to model is in sequences. Stock prices are sequences of prices. Language is a sequence of words. Credit scoring involves sequences of borrowing and repaying money, and we can use those sequences to predict whether or not you’re going to default. In short, sequences are everywhere, and being able to analyze them is an important skill in your data science toolbox.

The easiest way to appreciate the kind of information you get from a sequence is to consider what you are reading right now. If I had written the previous sentence backwards, it wouldn’t make much sense to you, even though it contained all the same words. So order is important.

While the current fad in deep learning is to use recurrent neural networks to model sequences, I want to first introduce you guys to a machine learning algorithm that has been around for several decades now - the Hidden Markov Model.

This course follows directly from my first course in Unsupervised Machine Learning for Cluster Analysis, where you learned how to measure the probability distribution of a random variable. In this course, you’ll learn to measure the probability distribution of a sequence of random variables.

You guys know how much I love deep learning, so there is a little twist in this course. We’ve already covered gradient descent and you know how central it is for solving deep learning problems. I claimed that gradient descent could be used to optimize any objective function. In this course I will show you how you can use gradient descent to solve for the optimal parameters of an HMM, as an alternative to the popular expectation-maximization algorithm.

We’re going to do it in Theano and Tensorflow, which are popular libraries for deep learning. This is also going to teach you how to work with sequences in Theano and Tensorflow, which will be very useful when we cover recurrent neural networks and LSTMs.

This course is also going to go through the many practical applications of Markov models and hidden Markov models. We’re going to look at a model of sickness and health, and calculate how to predict how long you’ll stay sick, if you get sick. We’re going to talk about how Markov models can be used to analyze how people interact with your website, and fix problem areas like high bounce rate, which could be affecting your SEO. We’ll build language models that can be used to identify a writer and even generate text - imagine a machine doing your writing for you. HMMs have been very successful in natural language processing or NLP.

We’ll look at what is possibly the most recent and prolific application of Markov models - Google’s PageRank algorithm. And finally we’ll discuss even more practical applications of Markov models, including generating images, smartphone autosuggestions, and using HMMs to answer one of the most fundamental questions in biology - how is DNA, the code of life, translated into physical or behavioral attributes of an organism?

All of the materials of this course can be downloaded and installed for FREE. We will do most of our work in Numpy and Matplotlib, along with a little bit of Theano. I am always available to answer your questions and help you along your data science journey.

This course focuses on "how to build and understand", not just "how to use". Anyone can learn to use an API in 15 minutes after reading some documentation. It's not about "remembering facts", it's about "seeing for yourself" via experimentation. It will teach you how to visualize what's happening in the model internally. If you want more than just a superficial look at machine learning models, this course is for you.

See you in class!



Suggested Prerequisites:

  • calculus
  • linear algebra
  • probability
  • Python coding: if/else, loops, lists, dicts, sets
  • Numpy coding: matrix and vector operations, loading a CSV file
  • Be comfortable with the multivariate Gaussian distribution
  • Cluster Analysis and Unsupervised Machine Learning in Python will provide you with sufficient background


Tips for success:

  • Use the video speed changer! Personally, I like to watch at 2x.
  • Take handwritten notes. This will drastically increase your ability to retain the information.
  • Write down the equations. If you don't, I guarantee it will just look like gibberish.
  • Ask lots of questions on the discussion board. The more the better!
  • Don't get discouraged if you can't solve every exercise right away. Sometimes it'll take hours, days, or maybe weeks!
  • Write code yourself, this is an applied course! Don't be a "couch potato".

Testimonials and Success Stories


I am one of your students. Yesterday, I presented my paper at ICCV 2019. You have a significant part in this, so I want to sincerely thank you for your in-depth guidance to the puzzle of deep learning. Please keep making awesome courses that teach us!

I just watched your short video on “Predicting Stock Prices with LSTMs: One Mistake Everyone Makes.” Giggled with delight.

You probably already know this, but some of us really and truly appreciate you. BTW, I spent a reasonable amount of time making a learning roadmap based on your courses and have started the journey.

Looking forward to your new stuff.

Thank you for doing this! I wish everyone who call’s themselves a Data Scientist would take the time to do this either as a refresher or learn the material. I have had to work with so many people in prior roles that wanted to jump right into machine learning on my teams and didn’t even understand the first thing about the basics you have in here!!

I am signing up so that I have the easy refresh when needed and the see what you consider important, as well as to support your great work, thank you.

Thank you, I think you have opened my eyes. I was using API to implement Deep learning algorithms and each time I felt I was messing out on some things. So thank you very much.

I have been intending to send you an email expressing my gratitude for the work that you have done to create all of these data science courses in Machine Learning and Artificial Intelligence. I have been looking long and hard for courses that have mathematical rigor relative to the application of the ML & AI algorithms as opposed to just exhibit some 'canned routine' and then viola here is your neural network or logistical regression. ...

READ MORE

I have now taken a few classes from some well-known AI profs at Stanford (Andrew Ng, Christopher Manning, …) with an overall average mark in the mid-90s. Just so you know, you are as good as any of them. But I hope that you already know that.

I wish you a happy and safe holiday season. I am glad you chose to share your knowledge with the rest of us.

Hi Sir I am a student from India. I've been wanting to write a note to thank you for the courses that you've made because they have changed my career. I wanted to work in the field of data science but I was not having proper guidance but then I stumbled upon your "Logistic Regression" course in March and since then, there's been no looking back. I learned ANNs, CNNs, RNNs, Tensorflow, NLP and whatnot by going through your lectures. The knowledge that I gained enabled me to get a job as a Business Technology Analyst at one of my dream firms even in the midst of this pandemic. For that, I shall always be grateful to you. Please keep making more courses with the level of detail that you do in low-level libraries like Theano.

I just wanted to reach out and thank you for your most excellent course that I am nearing finishing.

And, I couldn't agree more with some of your "rants", and found myself nodding vigorously!

You are an excellent teacher, and a rare breed.

And, your courses are frankly, more digestible and teach a student far more than some of the top-tier courses from ivy leagues I have taken in the past.

(I plan to go through many more courses, one by one!)

I know you must be deluged with complaints in spite of the best content around That's just human nature.

Also, satisfied people rarely take the time to write, so I thought I will write in for a change. :)

Hello, Lazy Programmer!

In the process of completing my Master’s at Hunan University, China, I am writing this feedback to you in order to express my deep gratitude for all the knowledge and skills I have obtained studying your courses and following your recommendations.

The first course of yours I took was on Convolutional Neural Networks (“Deep Learning p.5”, as far as I remember). Answering one of my questions on the Q&A board, you suggested I should start from the beginning – the Linear and Logistic Regression courses. Despite that I assumed I had already known many basic things at that time, I overcame my “pride” and decided to start my journey in Deep Learning from scratch. ...

READ MORE

By the way, if you are interested to hear. I used the HMM classification, as it was in your course (95% of the script, I had little adjustments there), for the Customer-Care department in a big known fintech company. to predict who will call them, so they can call him before the rush hours, and improve the service. Instead of a poem, I Had a sequence of the last 24 hours' events that the customer had, like: "Loaded money", "Usage in the food service", "Entering the app", "Trying to change the password", etc... the label was called or didn't call. The outcome was great. They use it for their VIP customers. Our data science department and I got a lot of praise.

Lectures

Introduction and Outline

3 Lectures · 17min
  1. Introduction and Outline: Why would you want to use an HMM? (05:05) (FREE preview available)
  2. Where to get the Code and Data (09:21)
  3. How to Succeed in this Course (03:04)

Markov Models

4 Lectures · 43min
  1. The Markov Property (07:34)
  2. The Markov Model (12:30)
  3. Probability Smoothing and Log-Probabilities (07:50)
  4. The Math of Markov Chains (15:12)

Markov Models: Example Problems and Applications

6 Lectures · 36min
  1. Example Problem: Sick or Healthy (03:27)
  2. Example Problem: Expected number of continuously sick days (02:54)
  3. Example application: SEO and Bounce Rate Optimization (08:54)
  4. Example Application: Build a 2nd-order language model and generate phrases (13:07)
  5. Example Application: Google’s PageRank algorithm (05:05)
  6. Suggestion Box (03:10)

Hidden Markov Models for Discrete Observations

19 Lectures · 02hr 54min
  1. From Markov Models to Hidden Markov Models (06:03)
  2. HMM - Basic Examples (08:04)
  3. Parameters of an HMM (07:00)
  4. The 3 Problems of an HMM (05:43)
  5. The Forward-Backward Algorithm (part 1) (16:59)
  6. The Forward-Backward Algorithm (part 2) (07:09)
  7. The Forward-Backward Algorithm (part 3) (07:19)
  8. The Viterbi Algorithm (part 1) (06:15)
  9. The Viterbi Algorithm (part 2) (15:05)
  10. HMM Training (part 1) (04:41)
  11. HMM Training (part 2) (10:22)
  12. HMM Training (part 3) (13:34)
  13. HMM Training (part 4) (13:17)
  14. How to Choose the Number of Hidden States (07:02)
  15. Baum-Welch Updates for Multiple Observations (04:54)
  16. Discrete HMM in Code (20:34)
  17. The underflow problem and how to solve it (05:06)
  18. Discrete HMM Updates in Code with Scaling (11:54)
  19. Scaled Viterbi Algorithm in Log Space (03:39)

Discrete HMMs Using Deep Learning Libraries

6 Lectures · 54min
  1. Gradient Descent Tutorial (04:31)
  2. Theano Scan Tutorial (12:41)
  3. Discrete HMM in Theano (11:43)
  4. Improving our Gradient Descent-Based HMM (05:10)
  5. Tensorflow Scan Tutorial (12:43)
  6. Discrete HMM in Tensorflow (07:28)

HMMs for Continuous Observations

6 Lectures · 01hr 00min
  1. Gaussian Mixture Models with Hidden Markov Models (04:13)
  2. Generating Data from a Real-Valued HMM (06:36)
  3. Continuous-Observation HMM in Code (part 1) (18:38)
  4. Continuous-Observation HMM in Code (part 2) (05:13)
  5. Continuous HMM in Theano (16:33)
  6. Continuous HMM in Tensorflow (09:27)

HMMs for Classification

3 Lectures · 16min
  1. Unsupervised or Supervised? (02:59)
  2. Generative vs. Discriminative Classifiers (02:31)
  3. HMM Classification on Poetry Data (Robert Frost vs. Edgar Allan Poe) (10:37)

Bonus Example: Parts-of-Speech Tagging

2 Lectures · 11min
  1. Parts-of-Speech Tagging Concepts (05:01)
  2. POS Tagging with an HMM (05:59)

Helpful Review

3 Lectures · 18min
  1. Review of Gaussian Mixture Models (03:05)
  2. Theano Basics: Variables, Functions, Expressions, Optimization (07:47)
  3. TensorFlow Basics: Variables, Functions, Expressions, Optimization (07:27)

Markov Models (Legacy)

3 Lectures · 16min
  1. The Markov Property (04:40)
  2. Markov Models (07:03)
  3. The Math of Markov Chains (05:16)

HMM Legacy Lectures

7 Lectures · 27min
  1. The Forward-Backward Algorithm (04:28)
  2. Visual Intuition for the Forward Algorithm (03:33)
  3. The Viterbi Algorithm (02:58)
  4. Visual Intuition for the Viterbi Algorithm (03:17)
  5. The Baum-Welch Algorithm (02:39)
  6. Baum-Welch Explanation and Intuition (06:35)
  7. How can we choose the number of hidden states? (04:23)

Setting Up Your Environment (Appendix/FAQ by Student Request)

3 Lectures · 42min
  1. Pre-Installation Check (04:13)
  2. Anaconda Environment Setup (20:21)
  3. How to install Numpy, Scipy, Matplotlib, Pandas, IPython, Theano, and TensorFlow (17:33)

Extra Help With Python Coding for Beginners (Appendix/FAQ by Student Request)

5 Lectures · 52min
  1. How to Code Yourself (part 1) (15:55)
  2. How to Code Yourself (part 2) (09:24)
  3. Proof that using Jupyter Notebook is the same as not using it (12:29)
  4. Python 2 vs Python 3 (04:38)
  5. Is Theano Dead? (10:04)

Effective Learning Strategies for Machine Learning (Appendix/FAQ by Student Request)

4 Lectures · 59min
  1. How to Succeed in this Course (Long Version) (10:25)
  2. Is this for Beginners or Experts? Academic or Practical? Fast or slow-paced? (22:05)
  3. What order should I take your courses in? (part 1) (11:19)
  4. What order should I take your courses in? (part 2) (16:07)

Appendix / FAQ Finale

2 Lectures · 08min
  1. What is the Appendix? (02:48)
  2. Where to get discount coupons and FREE deep learning material (05:49)
This website is using cookies. That's Fine