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.

Revisions

  1. aelnonym created this gist Oct 4, 2018.
    19 changes: 19 additions & 0 deletions SciKitPCA.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    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---------------------