FunctionRacerProblemsRace

Two Main Directions

Mediumscikit-learnPython

Principal component analysis finds the directions along which a table varies most. Fit it on X keeping 2 components and return the share of the total variance each of the two explains, largest first.

Example 1

X [[1,2,0],[2,4,0],[3,6,0],[4,8,0],[5,10,0],[6,12,0]]
returns [1.0,0.0]

Every row is a multiple of (1, 2, 0): all the variation lies along one direction.

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