Horje
pca python Code Example
pca python
import numpy as np
from sklearn.decomposition import PCA

pca = PCA(n_components = 3) # Choose number of components
pca.fit(X) # fit on X_train if train/test split applied

print(pca.explained_variance_ratio_)
pca python
from sklearn.decomposition import PCA

pca = PCA(n_components=3)
pca.fit(features)
features_pca = pca.transform(features)
print("original shape:   ", features.shape)
print("transformed shape:", features_pca.shape)
print(pca.explained_variance_)
print(pca.explained_variance_ratio_)
pca python
from sklearn.decomposition import PCA
pca = PCA(n_components=2)
X_train = pca.fit_transform(X_train)
X_test = pca.transform(X_test)
scikit learn pca
from sklearn.decomposition import KernelPCA
kpca = KernelPCA(n_components = 2, kernel = 'rbf')
X_train = kpca.fit_transform(X_train)
X_test = kpca.transform(X_test)




Python

Related
check dictionary is empty or not in python Code Example check dictionary is empty or not in python Code Example
save model pickle Code Example save model pickle Code Example
string to hex python Code Example string to hex python Code Example
df count missing values Code Example df count missing values Code Example
no module named pyplot Code Example no module named pyplot Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
6