Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- import matplotlib.pyplot as plt
- from matplotlib.figure import Figure
- from sklearn.decomposition import PCA
- from sklearn.preprocessing import StandardScaler
- #---------- Reading input
- df = pd.read_csv("test.csv", index_col=[0])
- print( df )
- features = df.columns
- print( features )
- x = df.loc[:, features].values
- print( x )
- targets = df.index
- print( targets )
- #---------- Do PCA
- x = StandardScaler().fit_transform(x)
- pca = PCA(n_components=2)
- principalComponents = pca.fit_transform(x)
- print( principalComponents )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement