Small Tree
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
8 <= len(X) <= 501 <= len(X_new) <= 8
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More scikit-learn problems
- Table of Hits and MissesEasy
- Vote of the NeighborsEasy
- Yes or NoEasy
- Average Over Five FoldsMedium
- Best Number of NeighborsMedium
- Centers of the GroupsMedium
- Column That Matters MostMedium
- How Well It RanksMedium