Data Science, Machine Learning, Artificial Intelligence, Technology, Data Mining.
get_top_features_loadings(pca_loadings, n_features): top_features = {} for i in range(pca_loadings.shape[0]): top_indices = np.argsort(np.abs(pca_loadings[i]))[-n_features:] top_features[f'PC{i+1}'] = {df.columns[j]: pca_loadings[i][j] for j in top_indices} return top_features # Get and display the