Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Hands-On Markov Models with Python

You're reading from   Hands-On Markov Models with Python Implement probabilistic models for learning complex data sequences using the Python ecosystem

Arrow left icon
Product type Paperback
Published in Sep 2018
Publisher Packt
ISBN-13 9781788625449
Length 178 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Authors (2):
Arrow left icon
Ankur Ankan Ankur Ankan
Author Profile Icon Ankur Ankan
Ankur Ankan
Abinash Panda Abinash Panda
Author Profile Icon Abinash Panda
Abinash Panda
Arrow right icon
View More author details
Toc

Code example

In the following code example we implement a simple MDP:

import numpy as np
import random


class MDP(object):
"""
Defines a Markov Decision Process containing:

- States, s
- Actions, a
- Rewards, r(s,a)
- Transition Matrix, t(s,a,_s)

Includes a set of abstract methods for extended class will
need to implement.

"""

def __init__(self, states=None, actions=None, rewards=None, transitions=None,
discount=.99, tau=.01, epsilon=.01):
"""
Parameters:
-----------
states: 1-D array
The states of the environment

actions: 1-D array
The possible actions by the agent.

rewards: 2-D array
The rewards corresponding to each action at each state of the environment.

transitions: 2-D array
The transition probabilities between the states of the environment.

...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image