text_html_output_1.png
from sklearn.preprocessing import OneHotEncoder

from tensorflow import keras

from tensorflow.keras import layers

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

import seaborn as sns

train = pd.read_csv('/kaggle/input/tabular-playground-series-feb-2022/train.csv', index_col=0)
test = pd.read_csv('/kaggle/input/tabular-playground-series-feb-2022/test.csv', index_col=0)
submission = pd.read_csv('/kaggle/input/tabular-playground-series-feb-2022/sample_submission.csv', index_col=0)

cols_with_missing_train = [col for col in train.columns if train[col].isnull().any()]
cols_with_missing_test = [col for col in test.columns if test[col].isnull().any()]

from sklearn.preprocessing import OneHotEncoder
a = train.target.values
a = a.reshape(-1, 1)
OH_encoder = OneHotEncoder(handle_unknown='ignore', sparse=False)
OH_cols_train = pd.DataFrame(OH_encoder.fit_transform(a))
OH_cols_train.index = train.index
num_X_train = train.drop('target', axis=1)
OH_X_train = pd.concat([num_X_train, OH_cols_train], axis=1)
OH_X_train

y_train.shape

model = None
model = keras.Sequential([layers.BatchNormalization(), layers.Dense(100, activation='relu', input_shape=[286]), layers.Dropout(0.25), layers.BatchNormalization(), layers.Dense(80, activation='relu'), layers.Dropout(0.25), layers.BatchNormalization(), layers.Dense(40, activation='relu'), layers.Dropout(0.25), layers.BatchNormalization(), layers.Dense(10, activation='relu'), layers.BatchNormalization(), layers.Dense(10, activation='sigmoid')])
model.compile(optimizer='adam', loss='categorical_crossentropy')
history = model.fit(X_train, y_train, validation_data=(X_valid, y_valid), batch_size=3000, epochs=100)
sns.set(rc={'figure.figsize': (10, 5)})
history_df = pd.DataFrame(history.history)
history_df.loc[:, ['loss', 'val_loss']].plot()