text_plain_output_1.png
from sklearn.preprocessing import MinMaxScaler

from sklearn.preprocessing import OrdinalEncoder

import numpy as np # linear algebra

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

df = pd.read_csv('/kaggle/input/autism-screening-for-toddlers/Toddler Autism dataset July 2018.csv')

obj_cols = x_train.select_dtypes(include='object').columns
obj_cols

float_cols = x_train.select_dtypes(include='int64').columns
float_cols

from sklearn.preprocessing import OrdinalEncoder
oe = OrdinalEncoder(categories=[x_train[i].unique() for i in obj_cols])
oe.fit(x_train[obj_cols])
x_train_cat_encoded = oe.transform(x_train[obj_cols])
x_test_cat_encoded = oe.transform(x_test[obj_cols])

from sklearn.preprocessing import MinMaxScaler
scaler = MinMaxScaler()
scaler.fit(x_train[float_cols])
x_train_float_encoded = scaler.transform(x_train[float_cols])
x_test_float_encoded = scaler.transform(x_test[float_cols])

x_train_processed = np.hstack((x_train_cat_encoded, x_train_float_encoded))
x_test_processed = np.hstack((x_test_cat_encoded, x_test_float_encoded))

feature_names = np.concatenate([obj_cols, float_cols])

x_train_final = pd.DataFrame(x_train_processed, columns=feature_names)

x_train_final