Meesho-inspired catalog analytics pipeline wants a one-dimensional summary of correlated product features. You need to compute the leading PCA direction so the team can project each product onto the dominant variance direction.
Return the first principal component of X: centre the data, form the population covariance matrix, and take the eigenvector of the largest eigenvalue. Scale it to unit length and flip its sign if necessary so that its entry of largest magnitude is positive (the first such entry on a tie).
Implement solve(X).
Returns. Return a unit-norm float NumPy vector with one entry per feature.
Example 1
Input:
solve([[1, 1], [2, 2], [3, 3]])
Output:
[0.707107, 0.707107]
Example 2
Input:
solve([[1.0, 0.0], [-1.0, 0.0], [2.0, 0.1], [-2.0, -0.1]])
Output:
[0.9992, 0.039984]
No results yet
Run your code to check it against the examples, or submit to run every test.