image_output_11.png image_output_17.png image_output_14.png image_output_13.png image_output_5.png image_output_18.png image_output_7.png image_output_4.png image_output_8.png image_output_16.png image_output_6.png image_output_12.png image_output_3.png image_output_2.png image_output_1.png image_output_10.png image_output_15.png image_output_9.png image_output_19.png
from sklearn.decomposition import PCA

import pandas as pd

train_data = pd.read_csv('../input/tabular-playground-series-mar-2021/train.csv')
test_data = pd.read_csv('../input/tabular-playground-series-mar-2021/test.csv')

all_data = pd.concat([train_data, test_data])
all_data

train_data.shape

all_data.drop('id', axis=1, inplace=True)
train_data.drop('id', axis=1, inplace=True)
test_data.drop('id', axis=1, inplace=True)

pca = PCA(n_components=1)
cont1_2 = pca.fit_transform(all_data[['cont1', 'cont2']])
print(pca.explained_variance_ratio_)
cont1_2