text_plain_output_1.png
from sklearn.preprocessing import StandardScaler,OneHotEncoder

import numpy as np

import pandas as pd

import seaborn as sns

data = pd.read_csv('/kaggle/input/adult-census-income/adult.csv')

target = data.pop('income')

data = data.drop('relationship', axis=1)

one_hot = OneHotEncoder()
ss = StandardScaler()

def trans_one_hot(column):
    trans = one_hot.fit_transform(data[column].values.reshape(-1, 1))
    array_name = trans.toarray().astype(int)
    return array_name
def trans_normalize(column):
    trans = ss.fit_transform(data[column].values.reshape(-1, 1))
    return trans

txt_arr = np.concatenate((trans_one_hot('workclass'), trans_one_hot('education'), trans_one_hot('marital.status'), trans_one_hot('occupation'), trans_one_hot('relationship_change'), trans_one_hot('race'), trans_one_hot('sex'), trans_one_hot('native.country')), axis=1)
num_arr = np.concatenate((trans_normalize('age'), trans_normalize('fnlwgt'), trans_normalize('education.num'), trans_normalize('capital.gain'), trans_normalize('capital.loss'), trans_normalize('hours.per.week')), axis=1)

pred_data = np.concatenate((txt_arr, num_arr), axis=1)

pred_pd = pd.DataFrame(pred_data)

pred_pd