1. Home
  2. Explore
  3. Computer Science
  4. Rule-Based Machine Learning

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Rule-Based Machine Learning

Rule-Based Machine Learning and Learning Classifier Systems

Overview of Rule-Based Machine Learning

Rule-based machine learning is an alternative modeling paradigm that represents the problem space in a piecewise manner. Instead of a single model capturing a decision boundary, the model consists of a rule set — a collection of individual rules, each covering a conditional piece of the overall model.

  • Each rule is an IF:THEN expression that maps feature values to a target outcome.

  • The model as a whole is the set of rules; no single rule alone constitutes the model.

  • Rules are not mutually exclusive — their coverage regions can overlap, helping the model handle ambiguous areas more robustly.

Example Rule

IF feature color is red AND feature shape is octagon, THEN predict stop sign.

This conditional nature means the prediction only applies when an instance satisfies all conditions in the "IF" part.

Types of Rule-Based Algorithms

  • Association rule mining — popular in consumer analytics

  • Artificial immune systems — used for anomaly detection

  • Learning classifier systems (LCS) — focused on standard classification problems (the focus of these notes)


Learning Classifier Systems (LCS)

Despite the name "Learning Classifier Systems" (used for over 40 years), a more descriptive name would be "evolutionary rule set learner". LCS algorithms are a family of rule-based machine learning methods where rule discovery is driven by an evolutionary algorithm (typically a genetic algorithm).

Core Inspiration from Neo-Darwinian Evolution

  • Selection: More fit rules are chosen to reproduce.

  • Recombination (crossover): Parent rules exchange genetic material to produce offspring.

  • Mutation: Random changes introduce variation.

  • Survival of the fittest: In a limited-population environment, fit rules survive; less fit rules die off.

LCS employs population-based search — many candidate solutions (rules) are explored simultaneously, but only a subset of rules forms the final model.

Example Rule Set for Biomedical Data

Rule

Condition

Prediction

1

IF SNP A = 0 AND BMI < 20

Control

2

IF SNP X = 1

Case

3

IF BMI between 30 and 40

Case

…

…

…

No single rule works alone; together they form the model.


Advantages of LCS

  • Interpretability and explainability: Many LCS variants are as interpretable as decision trees (though some are less so).

  • Handling complex multivariate interactions: LCS is well-suited for modeling interactions between many features.

  • Modeling heterogeneous associations: Captures different patterns in different subpopulations — a type of complexity many algorithms struggle with.

  • Model-free: Avoids assumptions about linearity, boundary shape, or that all features must be included.

  • Implicit and explicit generalization pressures: Help prevent overfitting.

  • Adaptable and updatable: The model can be improved with new data without retraining from scratch.

  • Flexible: Can be customized for various problems.

Disadvantages of LCS

  • Not widely known: Few practitioners use or compare them to other algorithms.

  • Few implementations: Limited availability in standard ML packages (though this is improving).

  • Computationally expensive: Especially for hyperparameter tuning; however, LCS has only a few key hyperparameters.

  • Little theoretical work: The open-endedness makes mathematical convergence proofs nearly impossible; success relies on empirical evidence.

  • Variable interpretability: Some implementations are less interpretable than decision trees.

  • Vulnerable to overfitting (like many algorithms).


The LCS Algorithm: Step-by-Step

The algorithm processes one data instance at a time over many iteration cycles. Below is the schematic overview, followed by detailed explanations of each step.

Training Cycle Schematic (High-Level)

  1. Training data (called the environment) — instances are shuffled to avoid bias.

  2. Pass current instance to the rule population (initially empty).

  3. Matching: Find rules whose conditions are satisfied by the instance.

  4. Form the match set [M].

  5. Separate match set into correct set [C] and incorrect set [I] (based on predicted vs. true class).

  6. If [C] is empty, activate covering to generate a new rule.

  7. Rule evaluation: Update parameters for rules in [C] and [I].

  8. Subsumption (explicit generalization).

  9. Genetic algorithm (rule discovery): select two parents from [C], apply crossover and mutation to create offspring.

  10. Deletion: If population exceeds max size, delete least fit rules.

The cycle repeats through the dataset multiple times until a stop criterion (e.g., maximum iterations) is met.


Detailed Steps

1. Training Data Representation

Features are ordered from left to right. In this illustration, each feature is binary (0 or 1, shown as orange or blue). The outcome is a separate label (e.g., white hexagon = class 0, black = class 1). LCS is best suited for binary and multi-class classification but can be extended to regression.

2. Rule Population — Structure of a Rule

A rule has two parts: condition (left side) and action (right side, the predicted class). In the visual representation:

  • Specified features appear as filled half-circles (blue for 1, orange for 0).

  • Unspecified features are shown as empty half-circles with a # symbol — these are wildcards that match any value.

A rule is an implication: IF condition(s) are satisfied, THEN predict action.

Wildcards are crucial for interpretability and feature selection — if a feature is not useful, the algorithm learns to use a wildcard.

3. Matching

Compare the current training instance with each rule's condition. Wildcards automatically match. If all specified features match, the rule goes into the match set. If any specified feature does not match, the rule is excluded.

Key: Matching ignores the rule's predicted class and the instance's true class — only the condition matters.

4. Match Set [M] and Correct/Incorrect Sets

[M] contains all rules that matched the instance. Then each rule's predicted class is compared to the true class:

  • Rules that predicted correctly → correct set [C]

  • Rules that predicted incorrectly → incorrect set [I]

5. Covering Mechanism (if [C] is empty)

If no rule matches and also predicts correctly, covering creates a new rule:

  • Start from the current training instance.

  • Randomly choose a subset of features to specify (keeping the observed values).

  • For quantitative features, a random range including the observed value is used.

  • All other features become wildcards.

  • The predicted class is set to the instance's true class.

Covering ensures that the algorithm only explores rules that are relevant to the data.

6. Rule Evaluation — Parameter Updates

Each rule (classifier) in the population maintains several parameters:

Parameter

Description

Numerosity

Number of virtual copies of the rule (multiple identical rules are merged into one with higher numerosity).

Match count

How many times the rule has been in a match set.

Correct count

How many times the rule was in a correct set.

Accuracy

correct count / match count (not to be confused with model accuracy).

Fitness

Typically a function of accuracy — e.g., accuracy^5 in noiseless problems, or simply accuracy in noisy problems.

Important: High rule accuracy does not guarantee a good rule. A rule that matches only one instance and predicts correctly has 100% accuracy but likely overfits.

During parameter updates:

  • Rules in [C] receive an accuracy/fitness increase.

  • Rules in [I] receive a decrease.

7. Implicit Generalization Pressure

Rules with fewer specified features (simpler rules) are probabilistically more likely to appear in match sets. This gives them a higher chance of being selected as parents by the genetic algorithm, creating an evolutionary pressure toward simpler, more general rules.

8. Subsumption — Explicit Generalization

Subsumption removes overfit rules by having a more general rule "consume" a more specific one.

  • For rule A to subsume rule B:

    1. Both must predict the same class.

    2. A must completely cover the problem space covered by B (i.e., B's condition is a subset of A's).

    3. A must be at least as accurate as B.

If subsumption occurs:

  • The consumed rule (B) is removed from the population.

  • The consuming rule (A) gets its numerosity increased, giving it greater survival chance and more influence in predictions.

9. Genetic Algorithm (GA) — Intelligent Rule Discovery

The GA selects two parent rules from the current correct set [C], using methods like roulette wheel selection or tournament selection (fitter rules have higher probability of being chosen).

Crossover: Randomly exchanges specified vs. wildcard status between the two parent copies. For example, a specified blue value from one rule might swap with an orange value from the other.

Mutation: Randomly changes a feature from specified to wildcard (or vice versa) at any position. If a feature becomes newly specified, its value is set to match the current training instance — ensuring the offspring still matches the instance.

The two offspring rules receive initialized parameter values and are added to the population.

10. Deletion Mechanism

When the total rule population size (sum of all numerosities) exceeds a user-specified maximum, a rule is selected for deletion. Selection probability is inversely proportional to fitness — the least fit rules are most likely to be deleted.

This maintains a manageable population size and computational efficiency.


Post-Training: Rule Compaction and Prediction

After training ends:

  • Rule compaction: Remove rules that never saw enough training data or are no more accurate than random chance.

  • The final model consists of a subset of the evolved rules.

Prediction Array for New Data

When making predictions on new instances:

  1. Pass the instance to the final rule population.

  2. Apply matching to form the match set.

  3. Use the prediction array to decide the class.

The prediction array aggregates support for each class based on the numerosity and fitness of the rules in the match set that predict that class. The class with the most support is the final prediction.


Summary of LCS Algorithm Flow

Training Data → [Current Instance] → Rule Population
    → Matching → Match Set [M]
        → Split into Correct [C] and Incorrect [I] sets
            → If [C] empty → Covering (generate new rule)
        → Parameter updates (fitness, accuracy)
        → Subsumption (remove overfit rules)
        → Genetic Algorithm (select parents, crossover, mutation → offspring)
        → Deletion (if population too large, remove least fit)
    → Repeat for next instance until stop criterion
→ Compaction → Final Rule Set → Prediction Array → Predictions on new data

Further Resources

  • An animated video (approx. 12 minutes) provides a visual walkthrough of LCS.

  • Introductory textbook on LCS algorithms by Ryan Urbanowicz and Will Brown offers deeper coverage.

  • Scikit-learn compatible implementations of three LCS algorithms are available on the associated lab's GitHub page.

Learning classifier systems represent a powerful, interpretable, and flexible family of algorithms particularly valuable for biomedical data science where complex interactions and heterogeneous associations are common. While less mainstream than tree-based or neural network methods, they offer unique advantages for piecewise modeling with built-in feature selection and generalization.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent