I have a dataset which has names of compounds and their compositions. Like below

Sulphuric Acid=>[H,S,O] (Hydrogen, sulphur, oxygen) Oxalic Acid=>[H,C,O] Sodium Oxalate=>[Na,C,O] Potassium Sulphate=>[K,S,O] ...

Now I would need to train a model which can tell me Sodium Sulphate as [Na,S,O]. Note that sodium sulphate represents something not in training dataset. I have tried searching for possible ideas but nothing came up. Then I thought it could be hierarchical clustering like

    |    |
Oxalate  Sodium
|  |      |
C  O      Na

But then in hierarchical clustering the base/leafs are different. But here they are shared. Its like a graph. So What machine learning algorithm can help? Any other clustering? NLP/word clustering (if yes How)?

Another approach I could think of is like Word2Vec where I generate embeddings for each word (C,H,Sodium), all will have embeddings. And based on what is closer to the word I am asking I will give output. But this needs huge amount of data. I only have around 1k common compounds. And the approach won't generalize to any problem like this with less data.


1 Answer 1


Try a one-hot encoding of the elements in your training set (H, C, I etc.) and the same for the chemical descriptors ('acid', 'oxalic' etc.). Then try feeding the data to a simple feed-forward neural network, mapping the one-hot encodings of the descriptors as your x_train and x_val to the chemical elements, which are your y_train and y_val.

For the encodings, take a look at the Scikit learn encoders.

I think such a simple approach may work, as the chemical names are logically named, so any experienced chemist knows exactly which elements to expect in a compound, given its name. Your problem doesn't require further information in the predictions, e.g. the actual chemical makeup, like $CH_3CH_2OH$ (ethanol).

Regarding a small amount of data: look into something like K-fold cross validation. Using this, you select some portion of the data to be your validation data, and train the model. You then repeat this process, selection a different portion of the data. This will help make the most of a limited dataset, although it may introduce overfitting because your model will eventually have seen all the data!

Here is a schematic of this method:

k-fold cross validation

Scikit Learn has a class that implements it for you.

  • 1
    $\begingroup$ Sorry If I have not been clear, I have to predict Elements given a compound name, so are you suggesting this as a multi-class classification where my output will have Elements probabilities and Input will have compound name? Also a concern is that I have only 1k entries so any Deep Learning Solution is inherently at a disadvantage since they need huge data. $\endgroup$
    – faizan
    Aug 19, 2018 at 20:52
  • $\begingroup$ @faizan - Using a few feed forward layers isn't going to require large amount of data, as you may only have a few hundred parameters. See my edits above for more information :-) $\endgroup$
    – n1k31t4
    Aug 20, 2018 at 11:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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