Skip to content

Instantly share code, notes, and snippets.

@aelnonym
Created October 4, 2018 05:05
Show Gist options
  • Select an option

  • Save aelnonym/d6c2eecf331375f03f4fe3f21e5f1090 to your computer and use it in GitHub Desktop.

Select an option

Save aelnonym/d6c2eecf331375f03f4fe3f21e5f1090 to your computer and use it in GitHub Desktop.
from sklearn.preprocessing import StandardScaler
from sklearn.decomposition import PCA
# Escalando com SciKitLearn----------------------------------------
scaler = StandardScaler()
scaler.fit(X) # Fit on training set only.
# Apply transform to both the training set and the test set.
X = scaler.transform(X)
x_test = scaler.transform(x_test)
# Aplicando PCA
pca = PCA(.95) # Variancia .95
pca.fit(X)
X = pca.transform(X)
x_test = pca.transform(x_test)
# Fim escalamento/ redução de dimensionalidade---------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment