code: def _transform(self, X, dim):
      covariance = calculate_covariance_matrix(X)
      eigenvalues, eigenvectors = np.linalg.eig(covariance)
      # Sort eigenvalues and eigenvector by largest eigenvalues
      idx = eigenvalues.argsort()[::-1]
      eigenvalues = eigenvalues[idx][:dim]
      eigenvectors = np.atleast_1d(eigenvectors[:, idx])[:, :dim]
      # Project the data onto principal components
      X_transformed = X.dot(eigenvectors)
  
      return X_transformed
  
file_path: ML-From-Scratch/mlfromscratch/utils/misc.py
imports: import progressbar
  from mpl_toolkits.mplot3d import Axes3D
  import matplotlib.pyplot
  import matplotlib.cm
  import matplotlib.colors
  import numpy
  from mlfromscratch.utils.data_operation import calculate_covariance_matrix
  from mlfromscratch.utils.data_operation import calculate_correlation_matrix
  from mlfromscratch.utils.data_manipulation import standardize
label_desc: Use image node_id 2 for calling the Plot obj's underlying member method code with example usage: obj._transform(X, dim) and returns: X_transformed