1

I have a set of structured features (that gets about 0.70 accuracy alone) and a text field (that gets about 0.85 accuracy alone) associated to each record. I have developed a classification model that accepts both structured and text data using Keras functional API but the performance of the mixed model is much lower than the model that is only based on text data:

input_st = Input(shape=(447))
dense_layer_1 = Dense(50, activation='relu')(input_st)
dense_layer_2 = Dense(50, activation='relu')(dense_layer_1)
dense_layer_3 = Dense(50, activation='relu')(dense_layer_2)
dense20_st = Dense(20, activation='relu')(dense_layer_3)
    
    
max_len = max([len(s.split()) for s in X_nt_train])   
tokenizer = Tokenizer()  
tokenizer.fit_on_texts(X_nt_train)   
vocab_size =len(tokenizer.word_index) + 1   
X_train_encoded = tokenizer.texts_to_sequences(X_nt_train)   
X_test_encoded = tokenizer.texts_to_sequences(X_test_nt_skewed)   
X_train_padded = pad_sequences(X_train_encoded, maxlen=max_len,padding='post')   
X_test_padded = pad_sequences(X_test_encoded, maxlen=max_len, padding='post')
    
inputs_note = Input(shape=(max_len,))   
embedding1 = Embedding(vocab_size, 100)(inputs1)   
conv1 = Conv1D(filters=64,kernel_size=1, activation='relu')(embedding1)   
drop1 = Dropout(0.5)(conv1)   
pool1 =layers.GlobalMaxPool1D()(drop1)

merged = concatenate([dense20_st,pool1 ])  dense_1 = Dense(10,activation='relu')(merged)  
output = Dense(1, activation='sigmoid')(dense_1)

model = Model(inputs=[input_st, inputs_note], outputs=output)  
model.compile(loss='binary_crossentropy', optimizer='adam',metrics=['acc'])

I have tried several ways to combine the result of the structured sub-model with that of the text sub-model (combining output-vectors, combining output probabilities, combining flattened output, different activation functions, ...) but none of them got a result even as good as the model solely based on text model. Any Idea?

Hasan Zafari
  • 355
  • 2
  • 6

0 Answers0