I have an interesting problem that I am uncertain about how to even get started. I am working on a binary classifier that will take a chemical name, encoded as a string, and predict whether it is a 'good' or 'bad' name. I have had quite good success doing this by examining the structure of the chemical directly, but I would like to explore whether I can learn anything about the given name of the chemical itself (as the name can contain some structural information about the molecule that my encoding of the molecular structure is missing). I have been searching around trying to find anything built into sklearn to do text feature extraction. There is quite a bit, but it mostly seems to me like they are used for encoding whole sentences or paragraphs. My input would be very long, single words such as:




And as such, I'm not certain a bag of words or one-hot encoding of the strings would work. Could anyone perhaps point me in the right direction on methodologies or algorithms that might possibly be able to extract features from these strings such that I could train a binary classifier on them?


You can train an RNN with character embeddings. This can be done by splitting the name into sequences of chars and vectorize them numerically. If you are working with Keras, you can feed them into an Embedding() layer that will learn how to represent characters. RNN layers will then process their sequence. At the output node, your Network will perform a classification ('good'/'bad').

  • $\begingroup$ Thank you, I don't have much experience with Keras, but I am going to see if I can figure out an approximation with it and go through there using your advice. $\endgroup$ – Aaron Johnson Jan 23 '20 at 18:25
  • $\begingroup$ alternatively, if there are some recurrent patterns in chemical names (as I suppose), you might write a script that operationalizes some variable. In this way, you can avoid using embeddings (long and computationally expensive to train) and use some other staistical or ML algorithm. Unfortunately I have no background in chemistry, and I can't help you in this specific domain. $\endgroup$ – Leevo Jan 23 '20 at 19:32
  • $\begingroup$ Right, that is a very good method that has been attempted before at my organization, but with a database containing hundreds of millions of chemical names, it becomes difficult to identify enough of those patterns to write a script that would output a meaningful vector. One first approach I'm going to attempt (before 'deep' diving ;), into keras, is a character ngram vectorization of the name, followed by training a random forest binary classifier on that vector. Not super optimistic it will work, but again, first attempt $\endgroup$ – Aaron Johnson Jan 23 '20 at 20:03

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.