Can we add other features along with Text to a ML model . Like giving text and other features as one input combining them and predict the output value. As model can learn some more better if given some extra features along with text from tf-idf vector matrix. Can we input other features along with tf-idf vector matrix to a ML model or DL model.


Yes you definitely can. Here's an example: Using Convolutional Neural Networks to Classify Hate-Speech

The authors used classic embeddings concatenated with a vector of size 28 representing the presence or not (in a tweet) of each letter of the alphabet (26) plus any digit (1) plus any other symbol (1). So basically for a tweet like 'I love NLP!' the representation would be:


where you have the classic embeddings for each word, then a one hot vector for the alphabet letters, another hot vector (just a binary variable actually) for digits and one last that check for the presence of any other symbol (! in this case). The resulting concatenated vector is then passed to a LSTM, convolution layer or whatever architecture you want to use.

Consider that there are infinite other variables that you can concatenate to the embeddings. For example you could concatenate counters for each alphabet letter or any other symbol in a sentence (in this case I suggest to separately normalise these variables between 0 and 1 before concatenating them to the embeddings), one-hot representation of n-grams or dependencies, the total number of words, presence or not and counters of capital letters, presence of entities, sentiment scores obtained through external resources like Vader (see nltk) and so on.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.