Machine Learning Showcase: Self-balancing personal transport

The Problem

Have you ever wondered how those self-balancing personal transporters are able to keep the passenger stably balanced even while they are moving? Reinforcement learning is the key!

 The problem mentioned above is aptly named the “Cartpole Problem” because it involves balancing a pole on a cart… well, sort of…

Getting Started

After specifying the problem using what is known as a “problem domain,” we initialize the algorithm. It then gets to work trying to solve the problem.


The algorithm receives a reward for every timestep in which the “person” remains upright. The timesteps are grouped into what we call “episodes.”

An episode ends when the “person” is more than 15 degrees from vertical or if the cart needs to travel more a certain distance from the starting point to keep the person upright.

Problem Solved

After a couple of minutes, NXS Core’s reinforcement learning algorithm learns the problem well enough to keep the “person” stable on the cart.