Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Hands-On Q-Learning with Python

You're reading from  Hands-On Q-Learning with Python

Product type Book
Published in Apr 2019
Publisher Packt
ISBN-13 9781789345803
Pages 212 pages
Edition 1st Edition
Languages
Author (1):
Nazia Habib Nazia Habib
Profile icon Nazia Habib
Toc

Table of Contents (14) Chapters close

Preface 1. Section 1: Q-Learning: A Roadmap
2. Brushing Up on Reinforcement Learning Concepts 3. Getting Started with the Q-Learning Algorithm 4. Setting Up Your First Environment with OpenAI Gym 5. Teaching a Smartcab to Drive Using Q-Learning 6. Section 2: Building and Optimizing Q-Learning Agents
7. Building Q-Networks with TensorFlow 8. Digging Deeper into Deep Q-Networks with Keras and TensorFlow 9. Section 3: Advanced Q-Learning Challenges with Keras, TensorFlow, and OpenAI Gym
10. Decoupling Exploration and Exploitation in Multi-Armed Bandits 11. Further Q-Learning Research and Future Projects 12. Assessments 13. Other Books You May Enjoy

Solving a multi-armed bandit problem in Python – user advertisement clicks

In this section we'll be solving a multi-armed bandit problem using a simulated set of ad-click data. We'll generate a set of clicks for 5 different advertisements. Each ad will either be clicked or not clicked when it is shown to a user. Our goal is to determine which ad to show next based on how each ad is performing at any given point in the simulation.

We start with a baseline loop that chooses a random advertisement from the selection each time. This model does not learn from its actions and always chooses a random action. If the user clicks on the ad, we get a reward of 1; if not, we get a reward of 0.

We import the necessary packages and generate a data frame of simulated data using random numbers. We will specify a distribution of 90% zero values and 10% 1 values for this example...

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 $15.99/month. Cancel anytime