![]() ![]() DataFrame ( data = X, columns = ) # Initialize and keep all PCs model = pca () # Fit transform out = model. ![]() randint ( 0, 1, 250 ) # Combine into dataframe X = np. ![]() # We want to extract feature f1 as most important, followed by f2 etc f1 = np. results ) # Import libraries import numpy as np import pandas as pd from pca import pca # Lets create a dataset with features that have decreasing variance. #, #, #, #, # y = # label = Compute explained variance Īfter the fit_transform, the cumulative expained variance is stored together with the explained variance per PC. fit_transform ( X ) # Data looks like this: # X=array(, #, #, #, #. model = pca ( n_components = 0.95 ) # Reduce the data towards 3 PCs model = pca ( n_components = 3 ) # Fit transform results = model. data, columns = label, index = y ) # Initialize to reduce the data up to the nubmer of componentes that explains 95% of the variance. Import numpy as np from sklearn.datasets import load_iris import pandas as pd # Load pca from pca import pca # Load dataset label = load_iris (). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |