Skip to main content

Accuracy-based Learning Classifier Systems with Rule Combining

Project description

XCS-RC

Accuracy-based Learning Classifier Systems with Rule Combining mechanism, shortly XCS-RC for Python3, loosely based on Martin Butz's XCS Java code (2001). Read my PhD thesis here for the complete algorithmic description.

Rule Combining is novel function that employs inductive reasoning, replacing all Darwinian genetic operation like mutation and crossover. It can handle binaries and real, reaching better correctness rate and population size quicker than several XCS instances. My earlier papers comparing them can be obtained at here and here.


Relevant links


Installation

pip install xcs-rc

Initialization

import xcs_rc
agent = xcs_rc.Agent()

Classic Reinforcement Learning cycle

# input: binary string, e.g., "100110" or decimal array
state = str(randint(0, 1))

# pick methods: 0 = explore, 1 = exploit, 2 = explore_it
action = agent.next_action(state, pick_method=1)

# determine reward and apply it, e.g.,
reward = agent.maxreward if action == int(state[0]) else 0.0
agent.apply_reward(reward)

Partially Observable Markov Decision Process (POMDP) environment

# create env and agent
env = xcs_rc.MarkovEnv('maze4')  # maze4 is built-in
env.add_agents(num=1, tcomb=100, xmax=50)
agent = env.agents[0]

for episode in range(8000):
    steps = env.one_episode(pick_method=2)  # returns the number of taken steps

Print population, save it to CSV file, or use append mode

agent.pop.print(title="Population")
agent.save('xcs_population.csv', title="Final XCS Population")
agent.save('xcs_pop_every_100_cycles.csv', title="Cycle: ###", save_mode='a')

Finally, inserting rules to population

# automatically load the last set (important for append mode)
agent.load("xcs_population.csv", empty_first=True)
agent.pop.add(my_list_of_rules)  # from a list of classifiers

Main Parameters

XCS-RC Parameters

  • tcomb: combining period, number of learning cycles before the next rule combining
  • predtol: prediction tolerance, maximum difference between two classifiers to be combined
  • prederrtol: prediction error tolerance, threshold for deletion of inappropriately combined rules

How to Set

agent.tcomb = 50 # perform rule combining every 50 cycles
agent.predtol = 20.0 # combines rules whose prediction value differences <= 20.0
agent.prederrtol = 10.0 # remove if error > 10.0, after previously below it

Latest updates

  • all related to mutation and crossover is removed
  • dependencies like pandas and numpy are removed, as well as data science features

Results

Classical Problems: multiplexer and Markov environment:

Binary MP11-HIGH

Real MP6-HIGH

Markov Maze4

Flappy Bird from PyGame Learning Environment:

Flappy Bird XCS-RC plot

Flappy Bird XCS-RC youtube

Youtube: CartPole-v0 Benchmark from OpenAI Gym:

CartPole XCS-RC

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xcs-rc-1.3.3.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xcs_rc-1.3.3-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file xcs-rc-1.3.3.tar.gz.

File metadata

  • Download URL: xcs-rc-1.3.3.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.9

File hashes

Hashes for xcs-rc-1.3.3.tar.gz
Algorithm Hash digest
SHA256 fe3838285b417596ae951fbbe26f8af9cac77acf8f2fad392fc2ba28a1b102e2
MD5 1188c0d2b63149fa004484e6a59a7290
BLAKE2b-256 f7ce83673ad8590549aa33cb976c8eb4cd595cb793a5d3aea9c0c6d4211a22d8

See more details on using hashes here.

File details

Details for the file xcs_rc-1.3.3-py3-none-any.whl.

File metadata

  • Download URL: xcs_rc-1.3.3-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.9

File hashes

Hashes for xcs_rc-1.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c4cbf5159fb9d329c950804b767a14c7b25d9aa550deb53ca5e8329c70f2b0fb
MD5 9f4513781e32e9cf7a461f4a22a622b3
BLAKE2b-256 5a291ae2b00f7afc635a7b4488c285ecbe1dff7c1ff3a814cfe9798825ccf48d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page