FunctionRacerProblemsRace

Keep the Useful Columns

Hardscikit-learnPython

Most of the columns of X are noise, and only some help predict y. Score every column by its F statistic for a linear relationship with y, keep the k best, and return their column numbers in increasing order.

Example 1

X [[0,0,0,0],[7,1,3,5],[4,2,6,1],[1,3,2,6],[8,4,5,2],[5,5,1,7],[2,6,4,3],[9,7,0,8],[6,8,3,4],[3,9,6,0],[0,10,2,5],[7,11,5,1],[4,12,1,6],[1,13,4,2],[8,14,0,7],[5,15,3,3],[2,16,6,8],[9,17,2,4],[6,18,5,0],[3,19,1,5],[0,20,4,1],[7,21,0,6],[4,22,3,2],[1,23,6,7],[8,24,2,3],[5,25,5,8],[2,26,1,4],[9,27,4,0],[6,28,0,5],[3,29,3,1]]
y [0,5,6,7,8,13,14,15,16,21,22,23,24,29,30,31,32,37,38,39,40,45,46,47,48,53,54,55,56,61]
k 1
returns [1]

y is twice column 1 plus a little noise. No other column has anything to do with 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