Introduction to OpenAI Gym – Getting started with Machine Learning

#Introduction-to-OpenAI-Gym-–-Getting-started-with-Machine-Learning

The OpenAI Gym is a toolkit for developing and comparing reinforcement learning algorithms. There are a number of different Gym environments to choose from, which range from beginner to advanced. Each environment allows you to work out your machine learning algorithms. OpenAI gym is an incredibly fun and rewarding way to get started with machine learning. Gym is essentially a Python library that includes multiple machine learning challenges, in which the goal is the teach an agent to perform different tasks. Throughout this series we’ll look at a couple of different environments and show you a step by step process on how to build your very own reinforcement learning program.

Environments:

#Environments:

Toy Text: Simple text environments.

Algorithms: Learn to imitate computations.

Atari: Reach high scores in Atari 2600 games.

Box2D: Continuous control tasks in the Box2D simulator.

Classic Control: Control theory problems from the classic RL literature.

MuJoCo: Continuous control tasks, running in a fast physics simulator.

Robotics: Simulated goal-based tasks for the Fetch and ShadowHand robots.

Loading output library...

Installation:

#Installation:

First, we need to install the toolkit. You’ll need to have Python 3.5+ installed to work with these environments. Open your terminal and type the following:

1
pip install --user gym[all]

The all is included to install all the environments. This may take a few minutes.

Build from source:

#Build-from-source:

If you would prefer to build from source, you can also clone the Gym repository:

1
2
3
4
5
git clone https://github.com/openai/gym

cd gym

pip install --user -e .[all]

You’re now ready to begin coding on all the environments, with the exception of MuJoCo which requires an additional license key which can be acquired from their website https://www.roboti.us/ .

Let’s get started:

#Let’s-get-started:

""""This where I'll render out the CartrPole environment.""""

Conclusion:

#Conclusion:

Why Gym?

If your answer is “because all the cools kids are doing it”, then you’re in the right place.

All joking aside, machine learning is the future of technology and Gym has the ability to facilitate people of all skill level. Whether its teaching a cart to keep a stick up or training a humanoid robot to run in a virtual environment, OpenAI is an excellent toolkit to work with.

Following on from our CartPole-v1 example, in the next part of the series, I’ll show you how to train this agent using the Q-Learning method. This is a basic yet widely-used reinforcement learning technique.