Kaggle competition: Otto Group Product Classification Challenge
%%time
model = train_model(train_dataloader, val_dataloader, model, epochs=5 )<find_best_params>
train = pd.read_csv('/kaggle/input/otto-group-product-classification-challenge/train.csv')
 X = train.iloc[:, 1:94]
y = train[['target']]
print(train.groupby('target')['id'].count())
 y = pd.get_dummies(y, columns=['target'])
 X_train, X_dev_test, y_train, y_dev_test = train_test_split(X, y, test_size=0.2)
 X_dev, X_test, y_dev, y_test = train_test_split(X_dev_test, y_dev_test, test_size=0.5)
 print('X_train shape: %s' % str(X_train.shape))
print('y_train shape: %s' % str(y_train.shape))
print('X_dev shape: %s' % str(X_dev.shape))
print('y_dev shape: %s' % str(y_dev.shape))
print('X_test shape: %s' % str(X_test.shape))
print('y_test shape: %s' % str(y_test.shape))
model.eval()
model.to(device)
 data = next(iter(val_dataloader))
start, stop = model(data['input_ids'], data['token_type_ids'], data['attention_mask'])
 print(start.argmax(1), torch.argmax(stop, dim=1))
print(data['start_targets'], data['end_targets'] )<drop_column>
model = tf.keras.models.Sequential(
 [
tf.keras.layers.Dense(128, activation='relu', kernel_regularizer=tf.keras.regularizers.l2(0.001)) ,
tf.keras.layers.Dense(128, activation='relu', kernel_regularizer=tf.keras.regularizers.l2(0.001)) ,
tf.keras.layers.Dense(9, activation='softmax'),
] 
)
 model.compile(loss='categorical_crossentropy', optimizer=tf.keras.optimizers.Adam(1e-3), metrics=['accuracy'])
 history = model.fit(X_train, y_train, epochs=20, validation_data=(X_dev, y_dev), batch_size=64)
 loss = history.history['loss']
accuracy = history.history['accuracy']
val_loss = history.history['val_loss']
val_accuracy = history.history['val_accuracy']
iteration = range(1, len(history.history['loss'])+1)
 loss_df = pd.DataFrame({'loss': loss, 'val_loss': val_loss}, index=iteration)
 loss_df.plot.line()
acc_df = pd.DataFrame({'accuracy': accuracy, 'val_accuracy': val_accuracy}, index=iteration)
 acc_df.plot.line()
test_albert_input = data_extractor(test, data_test=True, random=False )<predict_on_test>
model.evaluate(X_test, y_test )
<predict_on_test><EOS> 
submit = pd.read_csv('/kaggle/input/otto-group-product-classification-challenge/test.csv')
 X_submit = submit.drop(columns=['id'])
 predictions = model.predict(X_submit)
 pred = pd.DataFrame(predictions, columns=['Class_1', 'Class_2', 'Class_3', 'Class_4', 'Class_5', 'Class_6', 'Class_7', 'Class_8', 'Class_9'])
 result = pd.concat([submit[['id']], pred], axis=1)
 result.to_csv('/kaggle/working/output.csv', index=False)
 print(result.head())