Understand the idea
Production uses fold-local quantile bins for continuous values. Binary flags stay discrete. This is the Playground’s implementation, which differs in discretisation details from the original One-R paper.
Supplied for this practice
These objects are prepared afresh before your editor runs.
X- Feature dataframe for the declared population, preserving row indices.
X = df[['distance', 'fragile']] y- Target series, aligned with
X.y = df.label model- An unfitted recipe is supplied; construction has not learned parameters. Fit it here only when the task requests fitting.
model = Pipeline([('prepare', OneRPreprocessor(numeric_features=['distance'], categorical_features=['fragile'])), ('model', OneRClassifier(bins=5))])
Outputs you create
answer- The requested result, with the values, labels and row order described by this task.
distance | service | fragile | label |
|---|---|---|---|
| 1 | standard | 0 | on time |
| 2 | express | 1 | on time |
| 3 | economy | 0 | late |
| 4 | standard | 1 | on time |
| 5 | express | 0 | on time |
| 6 | economy | 1 | on time |
| 7 | standard | 0 | on time |
| 8 | express | 1 | on time |
- Fit the numeric rule and inspect its predictions.
answerHints
Think: Numeric One-R learns intervals before it can map new values to labels.
Tools: Pipeline.fit and predict with numeric-rule preparation.
Approach: Fit the supplied recipe on the aligned features and labels, then inspect predictions.
Explained solution
model.fit(X,y)
answer=model.predict(X)
The fit learns the interval/rule structure; these in-sample outputs illustrate behaviour rather than held-away performance.