Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Challenge: Whitening via Eigenvalue Decomposition | Whitening and Decorrelation
Feature Scaling and Normalization Deep Dive

bookChallenge: Whitening via Eigenvalue Decomposition

Завдання

Swipe to start coding

You are given a dataset X (2D NumPy array) with correlated features. Your goal is to perform feature whitening — transforming the data so that features become uncorrelated and have unit variance, using eigenvalue decomposition of the covariance matrix.

Steps:

  1. Center the data (subtract column means).
  2. Compute the covariance matrix cov_matrix using np.cov(X_centered, rowvar=False).
  3. Perform eigenvalue decomposition with np.linalg.eigh.
  4. Compute a regularized whitening matrix:
    eps = 1e-10
    eig_vals_safe = np.where(eig_vals < eps, eps, eig_vals)
    whitening_matrix = eig_vecs @ np.diag(1.0 / np.sqrt(eig_vals_safe)) @ eig_vecs.T
    
    The eps prevents division by zero for near-zero eigenvalues (rank-deficient data).
  5. Compute the whitened data:
    X_whitened = X_centered @ whitening_matrix
    
  6. Verify that the covariance of X_whitened is close to the identity matrix in the nonzero subspace.

Рішення

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 3. Розділ 4
single

single

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

close

Awesome!

Completion rate improved to 5.26

bookChallenge: Whitening via Eigenvalue Decomposition

Свайпніть щоб показати меню

Завдання

Swipe to start coding

You are given a dataset X (2D NumPy array) with correlated features. Your goal is to perform feature whitening — transforming the data so that features become uncorrelated and have unit variance, using eigenvalue decomposition of the covariance matrix.

Steps:

  1. Center the data (subtract column means).
  2. Compute the covariance matrix cov_matrix using np.cov(X_centered, rowvar=False).
  3. Perform eigenvalue decomposition with np.linalg.eigh.
  4. Compute a regularized whitening matrix:
    eps = 1e-10
    eig_vals_safe = np.where(eig_vals < eps, eps, eig_vals)
    whitening_matrix = eig_vecs @ np.diag(1.0 / np.sqrt(eig_vals_safe)) @ eig_vecs.T
    
    The eps prevents division by zero for near-zero eigenvalues (rank-deficient data).
  5. Compute the whitened data:
    X_whitened = X_centered @ whitening_matrix
    
  6. Verify that the covariance of X_whitened is close to the identity matrix in the nonzero subspace.

Рішення

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 3. Розділ 4
single

single

some-alt