Book Image

Mastering Probabilistic Graphical Models with Python

By : Ankur Ankan
Book Image

Mastering Probabilistic Graphical Models with Python

By: Ankur Ankan

Overview of this book

Table of Contents (14 chapters)
Mastering Probabilistic Graphical Models Using Python
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Predictions from the model using pgmpy


In the previous sections, we have seen various algorithms to computing conditional distributions and learnt how to do MAP queries on the models. A MAP query is essentially a way to predict the states of variables, given the states of other variables. In a real-life problem, we are given some data with which we try to create a model for our problem. Then, using this trained model, we try to predict the states of variables for some new data point. This is the process with which we approach our supervised learning problems in machine learning.

Now, to design the models, we need to create CPDs or factors, add them to the base model, create an inference object, and then do MAP queries over it for new data points to predict variable states. This whole process is done very often in machine learning, so pgmpy provides the direct methods fit and predict to simplify the whole process. Let's look at some code to understand how this works. To keep it simple, we...