knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "README-"
)
set.seed(0)

Reinforcement Learning

Build Status CRAN_Status_Badge DOI

ReinforcementLearning performs model-free reinforcement learning in R. This implementation enables the learning of an optimal policy based on sample sequences consisting of states, actions and rewards. In addition, it supplies multiple predefined reinforcement learning algorithms, such as experience replay.

Overview

The most important functions of ReinforcementLearning are:

Installation

You can easily install the latest version of ReinforcementLearning with

# Recommended option: download and install latest version from CRAN
install.packages("ReinforcementLearning")

# Alternatively, install the development version from GitHub:
# install.packages("devtools")
devtools::install_github("nproellochs/ReinforcementLearning")

Usage

This section shows the basic functionality of how to perform reinforcement learning. First, load the corresponding package ReinforcementLearning.

library(ReinforcementLearning)

The following example shows how to learn a reinforcement learning agent using input data in the form of sample sequences consisting of states, actions and rewards. The result of the learning process is a state-action table and an optimal policy that defines the best possible action in each state.

# Generate sample experience in the form of state transition tuples
data <- sampleGridSequence(N = 1000)
head(data)

# Define reinforcement learning parameters
control <- list(alpha = 0.1, gamma = 0.1, epsilon = 0.1)

# Perform reinforcement learning
model <- ReinforcementLearning(data, s = "State", a = "Action", r = "Reward", 
                               s_new = "NextState", control = control)

# Print result
print(model)

Learning Reinforcement Learning

If you are new to reinforcement learning, you are better off starting with a systematic introduction, rather than trying to learn from reading individual documentation pages. There are three good places to start:

  1. A thorough introduction to reinforcement learning is provided in Sutton (1998).

  2. The package vignette demonstrates the main functionalities of the ReinforcementLearning R package by drawing upon common examples from the literature (e.g. finding optimal game strategies).

  3. Multiple blog posts on R-bloggers demonstrate the capabilities of the ReinforcementLearning package using practical examples.

Contributing

If you experience any difficulties with the package, or have suggestions, or want to contribute directly, you have the following options:

License

ReinforcementLearning is released under the MIT License

Copyright (c) 2019 Nicolas Pröllochs & Stefan Feuerriegel



nproellochs/ReinforcementLearning documentation built on March 3, 2020, 12:22 a.m.