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

Preface

This book focuses on the theoretical as well as practical uses of probabilistic graphical models, commonly known as PGM. This is a technique in machine learning in which we use the probability distribution over different variables to learn the model. In this book, we have discussed the different types of networks that can be constructed and the various algorithms for doing inference or predictions over these models. We have added examples wherever possible to make the concepts easier to understand. We also have code examples to promote understanding the concepts more effectively and working on real-life problems.

What this book covers

Chapter 1, Bayesian Network Fundamentals, discusses Bayesian networks (a type of graphical model), its representation, and the independence conditions that this type of network implies.

Chapter 2, Markov Network Fundamentals, discusses the other type of graphical model known as Markov network, its representation, and the independence conditions implied by it.

Chapter 3, Inference – Asking Questions to Models, discusses the various exact inference techniques used in graphical models to predict over newer data points.

Chapter 4, Approximate Inference, discusses the various methods for doing approximate inference in graphical models. As doing exact inference in the case of many real-life problems is computationally very expensive, approximate methods give us a faster way to do inference in such problems.

Chapter 5, Model Learning – Parameter Estimation in Bayesian Networks, discusses the various methods to learn a Bayesian network using data points that we have observed. This chapter also discusses the various methods of learning the network structure with observed data.

Chapter 6, Model Learning – Parameter Estimation in Markov Networks, discusses various methods for learning parameters and network structure in the case of Markov networks.

Chapter 7, Specialized Models, discusses some special cases in Bayesian and Markov models that are very widely used in real-life problems, such as Naive Bayes, Hidden Markov models, and others.

What you need for this book

In this book, we have used IPython to run all the code examples. It is not necessary to use IPython but we recommend you to use it. Most of the code examples use pgmpy and sckit-learn. Also, we have used NumPy at places to generate random data.

Who this book is for

This book will be useful for researchers, machine learning enthusiasts, and people who are working in the data science field and have a basic idea of machine learning or graphical models. This book will help readers to understand the details of graphical models and use them in their day-to-day data science problems.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "We are provided with five variables, namely sepallength, sepalwidth, petallength, petalwidth, and flowerspecies."

A block of code is set as follows:

[default]
raw_data = np.random.randint(low=0, high=2, size=(1000, 5))
data = pd.DataFrame(raw_data, columns=['D', 'I', 'G', 'S', 'L'])

student_model = BayesianModel([('D', 'G'), ('I', 'G'), ('G', 'L'), ('I', 'S')])

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

[default]
raw_data = np.random.randint(low=0, high=2, size=(1000, 5))
data = pd.DataFrame(raw_data, columns=['D', 'I', 'G', 'S', 'L'])

student_model = BayesianModel([('D', 'G'), ('I', 'G'), ('G', 'L'), ('I', 'S')])

student_model = BayesianModel([('D', 'G'), ('I', 'G'), ('G', 'L'), ('I', 'S')])

New terms and important words are shown in bold.

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from http://www.packtpub.com/sites/default/files/downloads/4684OS_ColorImages.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.