FunctionRacerProblemsRace

Column That Matters Most

Mediumscikit-learnPython

Fit a random forest of 25 trees (random_state=0) to predict y from the columns of X, and return the number of the column the forest found most useful: the one with the highest feature importance.

Example 1

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

The label is exactly column 1. The other two columns are unrelated to it.

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