def train_model(train_df, valid_df, tokenizer, fold):
    X_train = transform_text(tokenizer, train_df)
    X_valid = transform_text(tokenizer, valid_df)
    Y_train = pd.get_dummies(train_df['label'])
    Y_valid = pd.get_dummies(valid_df['label']).to_numpy()
    model = Sequential()
    optimizer = tf.keras.optimizers.Adam(0.001)
    model.add(Embedding(config.MAX_NUM_WORDS, config.EMBEDDING_DIM, input_length=X_train.shape[1]))
    model.add(SpatialDropout1D(0.2))
    model.add(LSTM(100, dropout=0.2, recurrent_dropout=0.2, bias_regularizer=regularizers.l2(0.0001)))
    model.add(Dense(2, activation='softmax'))
    loss = 'categorical_crossentropy'
    model.compile(loss=loss, optimizer=optimizer, metrics=['accuracy'])
    epochs = config.EPOCHS
    batch_size = config.BATCH_SIZE
    history = model.fit(X_train, Y_train, epochs=epochs, batch_size=batch_size, validation_split=0.2)
    accr = model.evaluate(X_valid, Y_valid)
    print('Test set\n  Loss: {:0.3f}\n  Accuracy: {:0.3f}'.format(accr[0], accr[1]))
    model.save(f'{config.MODEL_PATH}_without_vaccine_{fold}.h5')
    evaluate(model, X_valid, Y_valid)
    plot_model(history, fold)
    plot_confusion_matrix(model, X_valid, Y_valid, fold)
def train_model(train_df, valid_df, tokenizer, fold):
    X_train = transform_text(tokenizer, train_df)
    X_valid = transform_text(tokenizer, valid_df)
    Y_train = pd.get_dummies(train_df['label'])
    Y_valid = pd.get_dummies(valid_df['label']).to_numpy()
    model = Sequential()
    optimizer = tf.keras.optimizers.Adam(0.001)
    model.add(Embedding(config.MAX_NUM_WORDS, config.EMBEDDING_DIM, input_length=X_train.shape[1]))
    model.add(SpatialDropout1D(0.2))
    model.add(LSTM(100, dropout=0.2, recurrent_dropout=0.2, bias_regularizer=regularizers.l2(0.0001)))
    model.add(Dense(2, activation='softmax'))
    loss = 'categorical_crossentropy'
    model.compile(loss=loss, optimizer=optimizer, metrics=['accuracy'])
    epochs = config.EPOCHS
    batch_size = config.BATCH_SIZE
    history = model.fit(X_train, Y_train, epochs=epochs, batch_size=batch_size, validation_split=0.2)
    accr = model.evaluate(X_valid, Y_valid)
    print('Test set\n  Loss: {:0.3f}\n  Accuracy: {:0.3f}'.format(accr[0], accr[1]))
    model.save(f'{config.MODEL_PATH}_without_vaccine_{fold}.h5')
    evaluate(model, X_valid, Y_valid)
    plot_model(history, fold)
    plot_confusion_matrix(model, X_valid, Y_valid, fold)