FunctionRacerProblemsRace

Small Tree

Easyscikit-learnPython

Each row of X is a point with a label in y (0 or 1). Fit a decision tree that may ask at most 2 questions in a row (max_depth=2), with random_state=0, and return its predictions for the rows of X_new.

Example 1

X [[1],[2],[3],[4],[5],[6],[7],[8]]
y [0,0,0,1,1,1,0,0]
X_new [[0],[5],[9]]
returns [0,1,0]

Label 1 lives between 3.5 and 6.5, and two questions are enough to fence that stretch off.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More scikit-learn problems