text_plain_output_2.png application_vnd.jupyter.stderr_output_1.png
from scipy.stats import chisquare

from sklearn.decomposition import PCA

from sklearn.decomposition import PCA

import pandas as pd

import pandas as pd
df = pd.read_csv('../input/people.csv')

from scipy.stats import chisquare
chars = [i for i in df.columns.values if 'char_' in i]
flags = []
for feat in df[chars]:
    group = df[chars].groupby(feat)
    for otherfeat in df[chars].drop(feat, axis=1):
        summary = group[otherfeat].count()
        if chisquare(summary)[1] < 0.05:
            flags.append(feat)
            flags.append(otherfeat)
flags = set(flags)

from sklearn.decomposition import PCA
dums = df[chars].select_dtypes(include=['bool']).astype(float)
dums = dums.join(pd.get_dummies(df[[i for i in chars if i not in dums.columns.values]]))

from sklearn.decomposition import PCA
pca = PCA(n_components=2)
components = pca.fit_transform(dums)
print(pca.explained_variance_ratio_)