import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler

names = ['Sample', 'Clump Thickness','Uniformity of Cell Size','Uniformity of Cell Shape','Marginal Adhesion','Single Epithelial Cell Size','Bare Nuclei','Bland Chromatin', 'Normal Nucleoli', 'Mitoses', 'class']

df = pd.read_csv('breast.data.csv', header=None, names=names)
X = np.array(df.iloc[:, 1:9])
y = np.array(df['class'])

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3) 

sc = StandardScaler()  
X_train = sc.fit_transform(X_train)  
X_test = sc.transform(X_test)  

from sklearn.decomposition import PCA
pca = PCA()

x_train = pca.fit_transform(X_train)
X_test = pca.transform(X_test)  
variance = pca.explained_variance_ratio_ 

for i in range(0, 8):
  print(names[i+1], variance[i])
