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:
- 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.
- Calculate the total error of the predictor’s rules — the number of training rows whose value’s majority class disagrees with the actual target.
- 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
| Outlook | Yes | No | Rule | Errors |
|---|---|---|---|---|
| Sunny | 3 | 2 | Yes | 2 |
| Overcast | 4 | 0 | Yes | 0 |
| Rainy | 2 | 3 | No | 2 |
| Total | 4 |
Temp
| Temp | Yes | No | Rule | Errors |
|---|---|---|---|---|
| Hot | 2 | 2 | (tie) | 2 |
| Mild | 4 | 2 | Yes | 2 |
| Cool | 3 | 1 | Yes | 1 |
| Total | 5 |
Humidity
| Humidity | Yes | No | Rule | Errors |
|---|---|---|---|---|
| High | 3 | 4 | No | 3 |
| Normal | 6 | 1 | Yes | 1 |
| Total | 4 |
Windy
| Windy | Yes | No | Rule | Errors |
|---|---|---|---|---|
| False | 6 | 2 | Yes | 2 |
| True | 3 | 3 | (tie) | 3 |
| Total | 5 |
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 Yes | Actual No | ||
|---|---|---|---|
| Predicted Yes | 7 | 2 | PPV = 7/9 = 0.78 |
| Predicted No | 2 | 3 | NPV = 3/5 = 0.60 |
| Sensitivity = 0.78 | Specificity = 0.60 | Accuracy = 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.