Skip to content

Instantly share code, notes, and snippets.

@marcelcaraciolo
Created May 2, 2014 05:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcelcaraciolo/3d798eb6c19b271c7de7 to your computer and use it in GitHub Desktop.
Save marcelcaraciolo/3d798eb6c19b271c7de7 to your computer and use it in GitHub Desktop.
from sklearn.decomposition import RandomizedPCA
from sklearn.preprocessing import StandardScaler
pca = RandomizedPCA(n_components=10)
std_scaler = StandardScaler()
X_train, X_test, y_train, y_test = train_test_split(data, labels, test_size=0.1)
X_train = pca.fit_transform(X_train)
X_test = pca.transform(X_test)
X_train = std_scaler.fit_transform(X_train)
X_test = std_scaler.transform(X_test)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment