Skip to content
Saed Sayad

OneR

OneR builds one simple rule per predictor from frequency tables and keeps the most accurate — often nearly as good as far more complex classifiers.

5 min read · Updated August 8, 2026

OneR — short for “One Rule” — is a simple yet surprisingly accurate classification algorithm. It generates one rule for each predictor in the data, then selects the rule set with the smallest total error as its “one rule.” Despite testing only one attribute at a time, OneR has been shown to produce rules only slightly less accurate than state-of-the-art algorithms, while staying simple enough for humans to read at a glance (Holte, 1993).

The OneR algorithm

For each predictor:

  1. For each value of that predictor, make a rule:
    • count how often each class appears for that value,
    • find the most frequent class,
    • make the rule assign that class to this value.
  2. Calculate the total error of the predictor’s rules — the number of training rows whose value’s majority class disagrees with the actual target.
  3. Choose the predictor with the smallest total error.

OneR sits one step above ZeroR: instead of the majority class of the whole dataset, it uses the majority class within each value of its single best predictor.

Worked example: Play Golf

Using the same 14-row Play Golf dataset as ZeroR (9 Yes, 5 No), construct a frequency table for each predictor against the target.

Outlook

OutlookYesNoRuleErrors
Sunny32Yes2
Overcast40Yes0
Rainy23No2
Total4

Temp

TempYesNoRuleErrors
Hot22(tie)2
Mild42Yes2
Cool31Yes1
Total5

Humidity

HumidityYesNoRuleErrors
High34No3
Normal61Yes1
Total4

Windy

WindyYesNoRuleErrors
False62Yes2
True33(tie)3
Total5

Outlook and Humidity tie at 4 errors each, ahead of Temp and Windy at 5. The tie is broken in favor of Outlook — its rule set contains a perfectly pure branch (Overcast is always Yes) — giving the OneR model:

Predictor contribution

The total error from the frequency tables is itself the measure of each predictor’s contribution: a low total error means a high contribution to the model’s predictive power. Here Outlook (4) and Humidity (4) carry the signal, while Temp and Windy (5 each) add little on their own.

Model evaluation

Applying the Outlook rules to the training data gives the following confusion matrix:

Actual YesActual No
Predicted Yes72PPV = 7/9 = 0.78
Predicted No23NPV = 3/5 = 0.60
Sensitivity = 0.78Specificity = 0.60Accuracy = 0.71

That is real predictive power — accuracy rises from the ZeroR baseline of 0.64 to 0.71 using a single attribute, with balanced sensitivity and specificity. OneR produces no scores or probabilities, so evaluation charts that need a ranking (Gain, Lift, K-S, ROC) do not apply; see Model Evaluation — Classification.

In practice

scikit-learn has no built-in OneR, but the whole algorithm is a few lines of pandas: groupby each predictor on the target, take the modal class per value, and count errors. Its real modern role is as a fast feature screen: running OneR over every column of a wide table is a cheap way to rank single-feature predictive power before committing to a heavier model, and OneR’s frequency tables are exactly the structure that Naive Bayes and Decision Trees refine further. Numerical predictors must be binned first, since OneR needs discrete values.

Common pitfalls

  • Ignoring predictor interactions. One attribute at a time cannot capture combinations; a Decision Tree can.
  • Feeding it raw numbers. OneR needs discrete values — bin numerical predictors first or every row becomes its own value.
  • Arbitrary tie-breaking. Ties within a value (Hot: 2 Yes, 2 No) or between predictors (Outlook vs. Humidity) need a stated, consistent resolution.
  • Expecting probabilities. OneR outputs a class, not a score, so threshold-based evaluation is impossible.

Summary

OneR builds one majority-class rule per predictor value and keeps the predictor with the smallest total error. On the Play Golf data it selects Outlook — Sunny or Overcast means Yes, Rainy means No — reaching 0.71 accuracy over the 0.64 ZeroR baseline with three interpretable rules.