text_plain_output_1.png
import numpy as np # linear algebra

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

train_df = pd.read_csv('/kaggle/input/neolen-house-price-prediction/train.csv')
test_df = pd.read_csv('/kaggle/input/neolen-house-price-prediction/test.csv')

train_df = train_df.drop(['Id'], axis=1)
test_df = test_df.drop(['Id'], axis=1)
labels = train_df['SalePrice']
data = pd.concat([train_df, test_df], ignore_index=True)
data = data.drop('SalePrice', 1)

nans = pd.isnull(data).sum()
nans[nans > 0]

data = data.drop('PoolQC', 1)
data = data.drop('Fence', 1)
data = data.drop('MiscFeature', 1)
data = data.drop('Alley', 1)

data.dtypes.value_counts()

all_columns = data.columns.values
non_categorical = ['LotFrontage', 'LotArea', 'MasVnrArea', 'BsmtFinSF1', 'BsmtFinSF2', 'BsmtUnfSF', 'TotalBsmtSF', '1stFlrSF', '2ndFlrSF', 'LowQualFinSF', 'GrLivArea', 'GarageArea', 'WoodDeckSF', 'OpenPorchSF', 'EnclosedPorch', '3SsnPorch', 'ScreenPorch', 'PoolArea', 'MiscVal']
categorical = [value for value in all_columns if value not in non_categorical]

data = pd.get_dummies(data)
data.fillna(0)
data[data == -np.inf] = 0

def avg(x):
    s = np.sum(x, axis=0)
    s = s / x.shape[0]
    return s

def std(x):
    m = avg(x)
    s = np.subtract(x, m)
    s = np.power(s, 2)
    c = s.shape
    s = np.sum(s, axis=0)
    s = np.divide(s, c[0] - 1)
    s = np.sqrt(s)
    return s

def standardize(x):
    A = avg(x)
    S = std(x)
    x = np.subtract(x, A)
    x = np.divide(x, S)
    return x

data_transformed = data.to_numpy()

t = standardize(data_transformed)

def cov(x):
    cov = np.dot(x.T, x)
    cov = np.divide(cov, x.shape[0])
    return cov

tr = cov(t)

e, v = LA.eig(tr)
print(e)
print(v)