AI Glossary / AI and machine learning / Intermediate

CN2 algorithm

Definition

The CN2 algorithm is a rule-induction method that learns classification rules from labeled examples. It searches for useful combinations of conditions and expresses the resulting model as readable if-then rules, including in settings where examples contain noise.

What it means

A business may have historical records showing the attributes of a case and its assigned outcome. CN2 tries to turn patterns in those records into rules such as “if the issue concerns installation and the product is new, predict this support category.”

The rules are learned from examples rather than written entirely by an expert. Their readability can help reviewers inspect what the model has found, but readable does not mean correct or fair.

CN2 is a specific historical algorithm and family of later implementations. It should not be used as a generic name for every rule-based system. The learning procedure, scoring choices and rule semantics should be identified when comparing implementations.

How it works

The method searches candidate conditions and combinations, retaining a limited set of promising candidates rather than exhaustively trying every possible rule. This style of search is often described as beam search.

It evaluates candidate rules using their coverage and class distribution, selects a useful rule, and continues learning further rules from the remaining or reweighted examples according to the variant.

The final prediction depends on how the rules are organized and how uncovered cases are handled. Ordered rules, unordered variants and default predictions should be distinguished in a deployment report. Independent testing remains necessary even when the rules look sensible.

Three practical examples

  • A help-desk analyst learns candidate routing rules from previously categorized tickets and asks specialists to review them.
  • A manufacturing team explores which recorded conditions are associated with inspection outcomes.
  • A teaching project compares a learned rule list with a decision tree on the same small classification problem.

Think of it this way

Think of a supervisor learning practical rules of thumb by reviewing completed cases. A useful rule covers enough examples to matter while avoiding too many incorrect assignments.

The analogy has a limit. A supervisor brings background knowledge and can recognize a misleading recording practice. CN2 searches the attributes and labels supplied to it. It can faithfully learn an accidental pattern that an experienced person would reject.

Worked example

Comparing two candidate rules

Suppose an invented support dataset contains 200 labeled tickets. Candidate Rule A covers 40 tickets, of which 32 belong to the proposed category. Its observed precision is 32 divided by 40, or 80%.

Candidate Rule B adds another condition. It covers only ten tickets, nine of which belong to that category, giving 90% observed precision. Rule B looks more accurate locally but helps with far fewer cases and rests on less evidence.

A rule learner needs a scoring and selection procedure that balances such differences. The raw percentages alone do not reproduce CN2's full search or establish which rule should win.

The analyst also tests the rules on later tickets. If the added condition records a supervisor's action after routing, it is unavailable at prediction time and must not be used. A short readable rule can contain leakage just as a complex model can.

Illustrative case study

A fictional repairs company wants to make ticket routing easier to explain. It trains a CN2-style model and reviews the resulting conditions with service staff.

One apparently strong rule uses a field indicating whether a specialist eventually handled the ticket. Staff point out that this field is completed only after routing. The team removes it and rebuilds the model with information available when a request first arrives.

They retain manual review for cases not covered reliably by the learned rules and compare routing errors with the current process. The project values inspectable conditions, while recognizing that transparency does not remove the need for valid data and evaluation.

Common misconceptions and mistakes

  • Assuming learned rules are automatically expert knowledge: they reflect observed data and labels.
  • Preferring a tiny perfect rule without examining coverage: a rule matching one case may not generalize.
  • Ignoring rule order: overlapping conditions can produce different outcomes under different semantics.
  • Treating readable conditions as protection against leakage: future information can appear in a simple rule.

Business use

CN2 is relevant when interpretable classification rules are useful for discussion or when a team is studying rule-learning methods. It can help expose candidate patterns for expert review.

Ask for each rule's coverage, errors and behavior on new data. Confirm the default action when no rule matches. If rules will be translated into a production workflow, preserve their ordering and missing-value behavior so the implementation matches the evaluated model.

People also ask

Is CN2 a decision tree?

No. It learns rules, although both approaches can produce understandable conditions.

Can it learn from imperfect examples?

The original method was designed with noisy domains in mind, but data quality still matters.

Must every learned rule be used automatically?

No. Rules can first serve as hypotheses for specialist review or decision support.

Check your understanding

A rule is correct on all three cases it covers. Another is correct on 180 of 200 cases. Can you declare the first rule better from precision alone?

Answer: No. Coverage, uncertainty, the cost of errors and performance on independent cases all matter. Three examples provide very limited evidence.

Related terms

  • Rule induction
  • Beam search
  • Classification
  • Decision lists
  • coverage
  • decision list

Learn next

Read rule induction. Inspect a short rule list and identify overlap, default handling, available-at-decision-time inputs and the number of examples supporting each condition.

  • Rule induction

More in AI and machine learning

  • Clustering error - Clustering error is a measure of how wrong a clustering's group assignments are, usually counted as the smallest number of items that would need to move...
  • Clustering high-dimensional data - Clustering high-dimensional data means grouping records described by many features, often hundreds or thousands.
  • Clustering illusion - The clustering illusion is the tendency to see meaningful patterns or causes in clusters and streaks that can arise through chance.
  • Co-adaptation - Co-adaptation is a failure mode in neural networks where individual units become useful only in the company of specific other units, making the network...
  • Co-training - Co-training is a semi-supervised method where two models learn the same task from two different views of the data, each labeling examples it is confident...
  • Cognitive robotics - Cognitive robotics is the study and engineering of robots that connect perception, learning, reasoning and action to operate adaptively in their surroundings.

Sources

Clark and Niblett, The CN2 Induction Algorithm: https://axon.cs.byu.edu/~martinez/classes/678/Papers/CN2.pdf. Publication record: https://mlanthology.org/mlj/1989/clark1989mlj-cn2/. Primary paper excerpt consulted; teaching cases are fictional. The rule-search, ordering and covering variants were checked in the official Orange implementation documentation: https://orange3.readthedocs.io/en/3.4.0/widgets/classify/cn2ruleinduction.html. The original paper PDF could not be retrieved in this review.

Previous: Clutter Next: Co-adaptation

  • Home
  • Daily AI Updates
  • Blog
  • AIFBL Academy
  • AI Glossary
  • Products and Tools
  • Store
  • Free CFO AI Prompt Pack
  • About Shihan Sheriff
  • Privacy Policy
  • Terms of Use
  • Refund Policy
  • Cookie Policy
  • Earnings Disclaimer