> For the complete documentation index, see [llms.txt](https://www.mlcompendium.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.mlcompendium.com/predictive-ml/learning-classifier-systems.md).

# Learning Classifier Systems

Learning Classifier Systems (LCS) sit next to genetic algorithms for the case where the learner is a rule population rather than a single model. The page first defines LCS, then narrows to XCS, the variant with a scikit-learn implementation and a tutorial.

The same notes are in [Genetic Algorithms & Genetic Programming](/predictive-ml/genetic-algorithms-and-genetic-programming.md).

### LCS

The starting point is the Wikipedia definition, because it names the two parts every LCS has. (WIKI) [Learning classifier systems](https://en.wikipedia.org/wiki/Learning_classifier_system), or LCS, are a paradigm of [rule-based machine learning](https://en.wikipedia.org/wiki/Rule-based_machine_learning) methods that combine a discovery component (e.g. typically a [genetic algorithm](https://en.wikipedia.org/wiki/Genetic_algorithm)) with a learning component (performing either [supervised learning](https://en.wikipedia.org/wiki/Supervised_learning), [reinforcement learning](https://en.wikipedia.org/wiki/Reinforcement_learning), or [unsupervised learning](https://en.wikipedia.org/wiki/Unsupervised_learning)). The learning component is the choice that matters: in supervised learning the training data is labeled with the expected answers, while in unsupervised learning the model finds patterns or structures in unlabeled data.

### XCS

With the general definition in place, XCS is the concrete variant that picks reinforcement learning as its learning component. [XCS](http://hosford42.github.io/xcs/) is a type of [Learning Classifier System (LCS)](http://en.wikipedia.org/wiki/Learning_classifier_system), a [machine learning](http://en.wikipedia.org/wiki/Machine_learning) algorithm that utilizes a [genetic algorithm](http://en.wikipedia.org/wiki/Genetic_algorithm) acting on a rule-based system, to solve a [reinforcement learning](http://en.wikipedia.org/wiki/Reinforcement_learning) problem.

To run it, [Scikit-xcs](https://github.com/UrbsLab/scikit-XCS) is the scikit-learn compatible implementation of XCS, described by its authors as the most popular and best studied learning classifier system algorithm to date. The figure below is from that repository.

<figure><img src="https://83674056-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mgd48oS5_duTKOVE_Et%2Fuploads%2Fgit-blob-a1655dc32351e2b52b76a98c73ea87dd71676c97%2Fgimg-d7eaf61118ae.png?alt=media" alt=""><figcaption><p>Scikit-xcs.</p></figcaption></figure>

For a guided walk through the same algorithm, the XCS [Tutorial](https://pythonhosted.org/xcs/) goes with the hosford42 XCS package linked above.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.mlcompendium.com/predictive-ml/learning-classifier-systems.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
