{
  "id": 107256,
  "title": "Some chemistry thoughts about improving 1JH coupling types ",
  "url": "/competitions/champs-scalar-coupling/discussion/107256",
  "author_name": "",
  "post_date": "2019-09-03T09:55:08.654922800Z",
  "votes": 10,
  "comment_count": 16,
  "views": 0,
  "content": "<p>Throughout the competition everybody noticed that the worse types were always 1JHC and 1JHN. Our team worked a lot on trying to improve these types specifically, by analyzing the molecules that were giving the largest difference in coupling constants, compared to the DFT value.</p>\n\n<p>What came out was that the 'worse' molecules were either:\n- Linear molecules (a lot of them) with triple bonded carbon/nitrogen atoms (so a lot of bond strain)\n- Aromatic molecules, that is, molecules that display electron delocalization.</p>\n\n<p>For aromatic molecules, electron delocalization is a dynamical effect: electrons are moving around, which results in the bonds moving around, and typically an aromatic molecule can be represented in many different ways, called mesomers, depending on which bonds are where. Of course ML models cannot account for this dynamical effect since we're giving them only one representation of the molecule, whereas DFT can somewhat account for aromaticity (though DFT can't in principle account for dynamical effects either, but we can help it do better).</p>\n\n<p>For instance, this is an aromatic molecule and a few of its mesomers:\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1983404%2F5039cf5ffffe32b14715c500f10c1629%2FScreenshot%20from%202019-07-23%2008-09-16.png?generation=1567504224516934&amp;alt=media\" alt=\"\"></p>\n\n<p>See how the bonds are moving around, describing the dynamical effect I told above.</p>\n\n<p>One thing we tried is data augmentation. Since mesomers are basically the same molecule but with different node/edge features, we used the same target coupling constant as the initial molecule. It miserably failed, and I was surprised of this failure (my being surprised of the failure of a feature I designed happened a lot during the competition...)</p>\n\n<p>Are there any thoughts from the ML specialists/chemists/organizers of this competition <a href=\"/larsbratholm\">@larsbratholm</a> , about how we could improve the modeling of these types of molecules?</p>",
  "messages": [
    {
      "id": "616621",
      "postDate": "09/03/2019 09:55:08",
      "content": "<p>Throughout the competition everybody noticed that the worse types were always 1JHC and 1JHN. Our team worked a lot on trying to improve these types specifically, by analyzing the molecules that were giving the largest difference in coupling constants, compared to the DFT value.</p>\n\n<p>What came out was that the 'worse' molecules were either:\n- Linear molecules (a lot of them) with triple bonded carbon/nitrogen atoms (so a lot of bond strain)\n- Aromatic molecules, that is, molecules that display electron delocalization.</p>\n\n<p>For aromatic molecules, electron delocalization is a dynamical effect: electrons are moving around, which results in the bonds moving around, and typically an aromatic molecule can be represented in many different ways, called mesomers, depending on which bonds are where. Of course ML models cannot account for this dynamical effect since we're giving them only one representation of the molecule, whereas DFT can somewhat account for aromaticity (though DFT can't in principle account for dynamical effects either, but we can help it do better).</p>\n\n<p>For instance, this is an aromatic molecule and a few of its mesomers:\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1983404%2F5039cf5ffffe32b14715c500f10c1629%2FScreenshot%20from%202019-07-23%2008-09-16.png?generation=1567504224516934&amp;alt=media\" alt=\"\"></p>\n\n<p>See how the bonds are moving around, describing the dynamical effect I told above.</p>\n\n<p>One thing we tried is data augmentation. Since mesomers are basically the same molecule but with different node/edge features, we used the same target coupling constant as the initial molecule. It miserably failed, and I was surprised of this failure (my being surprised of the failure of a feature I designed happened a lot during the competition...)</p>\n\n<p>Are there any thoughts from the ML specialists/chemists/organizers of this competition <a href=\"/larsbratholm\">@larsbratholm</a> , about how we could improve the modeling of these types of molecules?</p>",
      "rawMarkdown": "Throughout the competition everybody noticed that the worse types were always 1JHC and 1JHN. Our team worked a lot on trying to improve these types specifically, by analyzing the molecules that were giving the largest difference in coupling constants, compared to the DFT value.\n\nWhat came out was that the 'worse' molecules were either:\n- Linear molecules (a lot of them) with triple bonded carbon/nitrogen atoms (so a lot of bond strain)\n- Aromatic molecules, that is, molecules that display electron delocalization.\n\nFor aromatic molecules, electron delocalization is a dynamical effect: electrons are moving around, which results in the bonds moving around, and typically an aromatic molecule can be represented in many different ways, called mesomers, depending on which bonds are where. Of course ML models cannot account for this dynamical effect since we're giving them only one representation of the molecule, whereas DFT can somewhat account for aromaticity (though DFT can't in principle account for dynamical effects either, but we can help it do better).\n\nFor instance, this is an aromatic molecule and a few of its mesomers:\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1983404%2F5039cf5ffffe32b14715c500f10c1629%2FScreenshot%20from%202019-07-23%2008-09-16.png?generation=1567504224516934&amp;alt=media)\n\nSee how the bonds are moving around, describing the dynamical effect I told above.\n\nOne thing we tried is data augmentation. Since mesomers are basically the same molecule but with different node/edge features, we used the same target coupling constant as the initial molecule. It miserably failed, and I was surprised of this failure (my being surprised of the failure of a feature I designed happened a lot during the competition...)\n\nAre there any thoughts from the ML specialists/chemists/organizers of this competition @larsbratholm , about how we could improve the modeling of these types of molecules?",
      "votes": null
    },
    {
      "id": "616761",
      "postDate": "09/03/2019 12:47:31",
      "content": "<p>I don't really have a good answer to this. I can see the data augmentation failing, since the property isn't really an average over the property of the individual states. The common methods in QM ML all heavily utilize transferability in the sense that only the immediate environment around the atoms of interest will have a big impact on the property, and any long range effect can be described by classical approximations. This assumption doesn't hold for conjugated systems.\nMaybe one could account for this in molecular graphs somehow by specifying which bonds are part of the same conjugated system? Or maybe some representation of the 'shape' of the conjugated system could be added? \nI found a paper that have looked into conjugated systems in particular that might be interesting: <a href=\"https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5785769/\">10.1021/acscentsci.7b00405</a>. I think there's been other work done on this, but any papers elude me at the moment.</p>",
      "rawMarkdown": "I don't really have a good answer to this. I can see the data augmentation failing, since the property isn't really an average over the property of the individual states. The common methods in QM ML all heavily utilize transferability in the sense that only the immediate environment around the atoms of interest will have a big impact on the property, and any long range effect can be described by classical approximations. This assumption doesn't hold for conjugated systems.\nMaybe one could account for this in molecular graphs somehow by specifying which bonds are part of the same conjugated system? Or maybe some representation of the 'shape' of the conjugated system could be added? \nI found a paper that have looked into conjugated systems in particular that might be interesting: [10.1021/acscentsci.7b00405](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5785769/). I think there's been other work done on this, but any papers elude me at the moment.",
      "votes": null
    },
    {
      "id": "616880",
      "postDate": "09/03/2019 14:53:47",
      "content": "<p>When you say augmentation is a failure, what do you mean?  Did you duplicate the molecule into all of its mesomers and took their average prediction as final prediction?  If so, did you weight the loss for these by 1/N when you have N mesomers ?</p>\n\n<p>Edit after reading Lars Answer.  If I get the notion of conjugated systems correctly, then indeed averaging isn't great.  But, even great, it is the one that minimises expected error probably.  This leads to another question:</p>\n\n<p>Is one of the mesomer giving a good prediction?  If yes, then maybe one can train a model to predict which mesomer was used in the simulation?</p>",
      "rawMarkdown": "When you say augmentation is a failure, what do you mean?  Did you duplicate the molecule into all of its mesomers and took their average prediction as final prediction?  If so, did you weight the loss for these by 1/N when you have N mesomers ?\n\nEdit after reading Lars Answer.  If I get the notion of conjugated systems correctly, then indeed averaging isn't great.  But, even great, it is the one that minimises expected error probably.  This leads to another question:\n\nIs one of the mesomer giving a good prediction?  If yes, then maybe one can train a model to predict which mesomer was used in the simulation?",
      "votes": null
    },
    {
      "id": "618745",
      "postDate": "09/05/2019 12:57:21",
      "content": "<p>The mesomers is a way for us to visualize what is going on quantum mechanically, using our classical way or representing molecules and bonds. The quantum chemical description of the system has no notion of mesomers and can be seen as all of these states combined in a non-linear fashion. If we had given you the parameters needed for you to reconstruct the wave function / electron density for the training set, it might have been easier to learn these special cases. But it might also be possible to create the model in a way where the ensemble of all the possible mesomers is given as input and matched to a single output, rather than enforcing that every mesomer should have the same properties (which was what I interpreted that <a href=\"/borisdee\">@borisdee</a> tried).</p>",
      "rawMarkdown": "The mesomers is a way for us to visualize what is going on quantum mechanically, using our classical way or representing molecules and bonds. The quantum chemical description of the system has no notion of mesomers and can be seen as all of these states combined in a non-linear fashion. If we had given you the parameters needed for you to reconstruct the wave function / electron density for the training set, it might have been easier to learn these special cases. But it might also be possible to create the model in a way where the ensemble of all the possible mesomers is given as input and matched to a single output, rather than enforcing that every mesomer should have the same properties (which was what I interpreted that @borisdee tried).",
      "votes": null
    },
    {
      "id": "619428",
      "postDate": "09/06/2019 07:36:46",
      "content": "<p>That's correct <a href=\"/larsbratholm\">@larsbratholm</a> !</p>\n\n<p>And why would coupling types involving tripled bonded carbon/nitrogen atoms be so badly described? I thought that maybe it was because these are under-represented in the dataset. Maybe it could help by adding more of these bond types in the training set. </p>",
      "rawMarkdown": "That's correct @larsbratholm !\n\nAnd why would coupling types involving tripled bonded carbon/nitrogen atoms be so badly described? I thought that maybe it was because these are under-represented in the dataset. Maybe it could help by adding more of these bond types in the training set.",
      "votes": null
    },
    {
      "id": "619496",
      "postDate": "09/06/2019 08:30:48",
      "content": "<p><a href=\"/larsbratholm\">@larsbratholm</a> ,  thanks for your explanations, but many (most?) of us used bonds computed by openbabel which means we used the classical view.  It also means that mesomers have different bonds and bonds types.  Alternatively, openbabel only outputs one mesomer.  Therefore adding all mesomers as data, and looking which one yields bets predictions could make sense.  Given I didn't know about mesomers (I have zero chemistry knowledge) before now, and given Boris did thought of it, I think my questions are fair.</p>\n\n<p><a href=\"/borisdee\">@borisdee</a> , I would still love to get answers to my questions.  Is you data augmentation to use all mesomers of the molecule?  If so, did you look into which mesomers were giving best predictions?  And what do you mean by data augmentation failed miserably?</p>\n\n<p>Or was your message solely for Lars?   I naively thought I qualify as a ML specialist.  Maybe you think otherwise? ;)</p>",
      "rawMarkdown": "larsbratholm ,  thanks for your explanations, but many (most?) of us used bonds computed by openbabel which means we used the classical view.  It also means that mesomers have different bonds and bonds types.  Alternatively, openbabel only outputs one mesomer.  Therefore adding all mesomers as data, and looking which one yields bets predictions could make sense.  Given I didn't know about mesomers (I have zero chemistry knowledge) before now, and given Boris did thought of it, I think my questions are fair.\n\n@borisdee , I would still love to get answers to my questions.  Is you data augmentation to use all mesomers of the molecule?  If so, did you look into which mesomers were giving best predictions?  And what do you mean by data augmentation failed miserably?\n\nOr was your message solely for Lars?   I naively thought I qualify as a ML specialist.  Maybe you think otherwise? ;)",
      "votes": null
    },
    {
      "id": "619541",
      "postDate": "09/06/2019 09:11:56",
      "content": "<p>Don't be so grumpy <a href=\"/cpmpml\">@cpmpml</a> 😁  It's just that I'm still trying to figure out how to give you a proper answer!</p>",
      "rawMarkdown": "Don't be so grumpy @cpmpml 😁  It's just that I'm still trying to figure out how to give you a proper answer!",
      "votes": null
    },
    {
      "id": "619638",
      "postDate": "09/06/2019 11:54:20",
      "content": "<p>I'm not really grumpy, but yes, when people ask for help and don't even acknowledge an answer I can become a bit impatient ;)  Anyway, thanks for the answer, looking forward to whatever you can share.</p>",
      "rawMarkdown": "I'm not really grumpy, but yes, when people ask for help and don't even acknowledge an answer I can become a bit impatient ;)  Anyway, thanks for the answer, looking forward to whatever you can share.",
      "votes": null
    },
    {
      "id": "619656",
      "postDate": "09/06/2019 12:32:32",
      "content": "<p><a href=\"/cpmpml\">@cpmpml</a> \nSo what we did is duplicate all the molecules into their mesomers. Some molecules had no mesomer, some had 2, some had 20! For each mesomer, we set the target constant to that of the initial molecule. \nBut I admit I don't know whether we averaged the predictions of all mesomers. I guess we didn't, we just had these mesomers as additional training/test data, with target labels being that of the 'initial' molecule.</p>\n\n<p>I was expecting that this approach may be giving more 'weight' to the molecules with more mesomers, as the model would encounter them more than those with few mesomers, and maybe decrease the error made on those molecules. But it did not work, that is, lmae was not better.</p>\n\n<p>&gt; Is one of the mesomer giving a good prediction? If yes, then maybe one can train a model to predict which mesomer was used in the simulation?</p>\n\n<p>I don't know that. We did not train separate models depending on the mesomers. This would require to many calculations, since each molecule can have up to 20 mesomers.</p>\n\n<p>I hope it answers your question!</p>",
      "rawMarkdown": "cpmpml \nSo what we did is duplicate all the molecules into their mesomers. Some molecules had no mesomer, some had 2, some had 20! For each mesomer, we set the target constant to that of the initial molecule. \nBut I admit I don't know whether we averaged the predictions of all mesomers. I guess we didn't, we just had these mesomers as additional training/test data, with target labels being that of the 'initial' molecule.\n\nI was expecting that this approach may be giving more 'weight' to the molecules with more mesomers, as the model would encounter them more than those with few mesomers, and maybe decrease the error made on those molecules. But it did not work, that is, lmae was not better.\n\n&gt; Is one of the mesomer giving a good prediction? If yes, then maybe one can train a model to predict which mesomer was used in the simulation?\n\nI don't know that. We did not train separate models depending on the mesomers. This would require to many calculations, since each molecule can have up to 20 mesomers.\n\nI hope it answers your question!",
      "votes": null
    },
    {
      "id": "619730",
      "postDate": "09/06/2019 14:20:46",
      "content": "<p>Thanks!  My gut feeling is that you should have weighted mesomer by the inverse of mesomer number per molecule to make it work.  But this is mere speculation.</p>",
      "rawMarkdown": "Thanks!  My gut feeling is that you should have weighted mesomer by the inverse of mesomer number per molecule to make it work.  But this is mere speculation.",
      "votes": null
    },
    {
      "id": "619857",
      "postDate": "09/06/2019 17:02:11",
      "content": "<p>Well I can still try it! Will take a look at that thanks</p>",
      "rawMarkdown": "Well I can still try it! Will take a look at that thanks",
      "votes": null
    },
    {
      "id": "620536",
      "postDate": "09/07/2019 16:17:14",
      "content": "<p>We just added the mesomers to the training data and it did not give an immediate improvement on our \"bad\" coupling types. At the time I was considering using mesomers for augmentation our model however was in a rapidly developing from an architecture point of view and there were bigger fish to fry so I kept pushing mesomers to the \"take-care-about-later\" list, on which they stayed until the competition was over.</p>",
      "rawMarkdown": "We just added the mesomers to the training data and it did not give an immediate improvement on our \"bad\" coupling types. At the time I was considering using mesomers for augmentation our model however was in a rapidly developing from an architecture point of view and there were bigger fish to fry so I kept pushing mesomers to the \"take-care-about-later\" list, on which they stayed until the competition was over.",
      "votes": null
    },
    {
      "id": "621206",
      "postDate": "09/08/2019 10:18:52",
      "content": "<p>An after thought (I'm a chemist noob so please indulge me if tit is silly): why would mesomer only help for bad types?</p>",
      "rawMarkdown": "An after thought (I'm a chemist noob so please indulge me if tit is silly): why would mesomer only help for bad types?",
      "votes": null
    },
    {
      "id": "621340",
      "postDate": "09/08/2019 12:55:16",
      "content": "<p>No you're right it should help for every type. But it seems that all the worse molecules in 1JH types had a significant number of mesomers so we were expecting that at least these types would improve</p>",
      "rawMarkdown": "No you're right it should help for every type. But it seems that all the worse molecules in 1JH types had a significant number of mesomers so we were expecting that at least these types would improve",
      "votes": null
    },
    {
      "id": "626747",
      "postDate": "09/14/2019 19:26:36",
      "content": "<p><a href=\"/larsbratholm\">@larsbratholm</a> I've seen on another topic the calculation details you used in Gaussian to calculate the coupling constant. But I was wondering, how do you calculate the coupling constant from ab initio calculations? Is it a linear response of some sort?\nThanks! </p>",
      "rawMarkdown": "larsbratholm I've seen on another topic the calculation details you used in Gaussian to calculate the coupling constant. But I was wondering, how do you calculate the coupling constant from ab initio calculations? Is it a linear response of some sort?\nThanks!",
      "votes": null
    },
    {
      "id": "627819",
      "postDate": "09/16/2019 12:25:19",
      "content": "<p>It's been a while since I went through QM theory, but the scalar coupling is the second derivative of the electronic energy, with respect to the nuclear magnetic moments of the two nuclei. And I would think that Gaussian calculates this using response theory, as in section 2B <a href=\"https://aip.scitation.org/doi/10.1063/1.1321296\">here</a></p>",
      "rawMarkdown": "It's been a while since I went through QM theory, but the scalar coupling is the second derivative of the electronic energy, with respect to the nuclear magnetic moments of the two nuclei. And I would think that Gaussian calculates this using response theory, as in section 2B [here](https://aip.scitation.org/doi/10.1063/1.1321296)",
      "votes": null
    },
    {
      "id": "628003",
      "postDate": "09/16/2019 17:22:55",
      "content": "<p>Awesome thanks a lot! That's quite a calculation indeed. I understand the use of ML to predict these quantities rather than calculating them from first principles. Thanks for all your help</p>",
      "rawMarkdown": "Awesome thanks a lot! That's quite a calculation indeed. I understand the use of ML to predict these quantities rather than calculating them from first principles. Thanks for all your help",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 616761,
      "author_name": "larsbratholm",
      "author_url": "",
      "post_date": "09/03/2019 12:47:31",
      "content": "<p>I don't really have a good answer to this. I can see the data augmentation failing, since the property isn't really an average over the property of the individual states. The common methods in QM ML all heavily utilize transferability in the sense that only the immediate environment around the atoms of interest will have a big impact on the property, and any long range effect can be described by classical approximations. This assumption doesn't hold for conjugated systems.\nMaybe one could account for this in molecular graphs somehow by specifying which bonds are part of the same conjugated system? Or maybe some representation of the 'shape' of the conjugated system could be added? \nI found a paper that have looked into conjugated systems in particular that might be interesting: <a href=\"https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5785769/\">10.1021/acscentsci.7b00405</a>. I think there's been other work done on this, but any papers elude me at the moment.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 616880,
      "author_name": "cpmpml",
      "author_url": "",
      "post_date": "09/03/2019 14:53:47",
      "content": "<p>When you say augmentation is a failure, what do you mean?  Did you duplicate the molecule into all of its mesomers and took their average prediction as final prediction?  If so, did you weight the loss for these by 1/N when you have N mesomers ?</p>\n\n<p>Edit after reading Lars Answer.  If I get the notion of conjugated systems correctly, then indeed averaging isn't great.  But, even great, it is the one that minimises expected error probably.  This leads to another question:</p>\n\n<p>Is one of the mesomer giving a good prediction?  If yes, then maybe one can train a model to predict which mesomer was used in the simulation?</p>",
      "votes": null,
      "replies": [
        {
          "id": 618745,
          "author_name": "larsbratholm",
          "author_url": "",
          "post_date": "09/05/2019 12:57:21",
          "content": "<p>The mesomers is a way for us to visualize what is going on quantum mechanically, using our classical way or representing molecules and bonds. The quantum chemical description of the system has no notion of mesomers and can be seen as all of these states combined in a non-linear fashion. If we had given you the parameters needed for you to reconstruct the wave function / electron density for the training set, it might have been easier to learn these special cases. But it might also be possible to create the model in a way where the ensemble of all the possible mesomers is given as input and matched to a single output, rather than enforcing that every mesomer should have the same properties (which was what I interpreted that <a href=\"/borisdee\">@borisdee</a> tried).</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 619428,
          "author_name": "borisdee",
          "author_url": "",
          "post_date": "09/06/2019 07:36:46",
          "content": "<p>That's correct <a href=\"/larsbratholm\">@larsbratholm</a> !</p>\n\n<p>And why would coupling types involving tripled bonded carbon/nitrogen atoms be so badly described? I thought that maybe it was because these are under-represented in the dataset. Maybe it could help by adding more of these bond types in the training set. </p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 619496,
          "author_name": "cpmpml",
          "author_url": "",
          "post_date": "09/06/2019 08:30:48",
          "content": "<p><a href=\"/larsbratholm\">@larsbratholm</a> ,  thanks for your explanations, but many (most?) of us used bonds computed by openbabel which means we used the classical view.  It also means that mesomers have different bonds and bonds types.  Alternatively, openbabel only outputs one mesomer.  Therefore adding all mesomers as data, and looking which one yields bets predictions could make sense.  Given I didn't know about mesomers (I have zero chemistry knowledge) before now, and given Boris did thought of it, I think my questions are fair.</p>\n\n<p><a href=\"/borisdee\">@borisdee</a> , I would still love to get answers to my questions.  Is you data augmentation to use all mesomers of the molecule?  If so, did you look into which mesomers were giving best predictions?  And what do you mean by data augmentation failed miserably?</p>\n\n<p>Or was your message solely for Lars?   I naively thought I qualify as a ML specialist.  Maybe you think otherwise? ;)</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 619541,
          "author_name": "borisdee",
          "author_url": "",
          "post_date": "09/06/2019 09:11:56",
          "content": "<p>Don't be so grumpy <a href=\"/cpmpml\">@cpmpml</a> 😁  It's just that I'm still trying to figure out how to give you a proper answer!</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 619638,
          "author_name": "cpmpml",
          "author_url": "",
          "post_date": "09/06/2019 11:54:20",
          "content": "<p>I'm not really grumpy, but yes, when people ask for help and don't even acknowledge an answer I can become a bit impatient ;)  Anyway, thanks for the answer, looking forward to whatever you can share.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 619656,
          "author_name": "borisdee",
          "author_url": "",
          "post_date": "09/06/2019 12:32:32",
          "content": "<p><a href=\"/cpmpml\">@cpmpml</a> \nSo what we did is duplicate all the molecules into their mesomers. Some molecules had no mesomer, some had 2, some had 20! For each mesomer, we set the target constant to that of the initial molecule. \nBut I admit I don't know whether we averaged the predictions of all mesomers. I guess we didn't, we just had these mesomers as additional training/test data, with target labels being that of the 'initial' molecule.</p>\n\n<p>I was expecting that this approach may be giving more 'weight' to the molecules with more mesomers, as the model would encounter them more than those with few mesomers, and maybe decrease the error made on those molecules. But it did not work, that is, lmae was not better.</p>\n\n<p>&gt; Is one of the mesomer giving a good prediction? If yes, then maybe one can train a model to predict which mesomer was used in the simulation?</p>\n\n<p>I don't know that. We did not train separate models depending on the mesomers. This would require to many calculations, since each molecule can have up to 20 mesomers.</p>\n\n<p>I hope it answers your question!</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 619730,
          "author_name": "cpmpml",
          "author_url": "",
          "post_date": "09/06/2019 14:20:46",
          "content": "<p>Thanks!  My gut feeling is that you should have weighted mesomer by the inverse of mesomer number per molecule to make it work.  But this is mere speculation.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 619857,
          "author_name": "borisdee",
          "author_url": "",
          "post_date": "09/06/2019 17:02:11",
          "content": "<p>Well I can still try it! Will take a look at that thanks</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 620536,
          "author_name": "christofhenkel",
          "author_url": "",
          "post_date": "09/07/2019 16:17:14",
          "content": "<p>We just added the mesomers to the training data and it did not give an immediate improvement on our \"bad\" coupling types. At the time I was considering using mesomers for augmentation our model however was in a rapidly developing from an architecture point of view and there were bigger fish to fry so I kept pushing mesomers to the \"take-care-about-later\" list, on which they stayed until the competition was over.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 621206,
          "author_name": "cpmpml",
          "author_url": "",
          "post_date": "09/08/2019 10:18:52",
          "content": "<p>An after thought (I'm a chemist noob so please indulge me if tit is silly): why would mesomer only help for bad types?</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 621340,
          "author_name": "borisdee",
          "author_url": "",
          "post_date": "09/08/2019 12:55:16",
          "content": "<p>No you're right it should help for every type. But it seems that all the worse molecules in 1JH types had a significant number of mesomers so we were expecting that at least these types would improve</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 626747,
      "author_name": "borisdee",
      "author_url": "",
      "post_date": "09/14/2019 19:26:36",
      "content": "<p><a href=\"/larsbratholm\">@larsbratholm</a> I've seen on another topic the calculation details you used in Gaussian to calculate the coupling constant. But I was wondering, how do you calculate the coupling constant from ab initio calculations? Is it a linear response of some sort?\nThanks! </p>",
      "votes": null,
      "replies": [
        {
          "id": 627819,
          "author_name": "larsbratholm",
          "author_url": "",
          "post_date": "09/16/2019 12:25:19",
          "content": "<p>It's been a while since I went through QM theory, but the scalar coupling is the second derivative of the electronic energy, with respect to the nuclear magnetic moments of the two nuclei. And I would think that Gaussian calculates this using response theory, as in section 2B <a href=\"https://aip.scitation.org/doi/10.1063/1.1321296\">here</a></p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 628003,
          "author_name": "borisdee",
          "author_url": "",
          "post_date": "09/16/2019 17:22:55",
          "content": "<p>Awesome thanks a lot! That's quite a calculation indeed. I understand the use of ML to predict these quantities rather than calculating them from first principles. Thanks for all your help</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "616621": "Throughout the competition everybody noticed that the worse types were always 1JHC and 1JHN. Our team worked a lot on trying to improve these types specifically, by analyzing the molecules that were giving the largest difference in coupling constants, compared to the DFT value.\n\nWhat came out was that the 'worse' molecules were either:\n- Linear molecules (a lot of them) with triple bonded carbon/nitrogen atoms (so a lot of bond strain)\n- Aromatic molecules, that is, molecules that display electron delocalization.\n\nFor aromatic molecules, electron delocalization is a dynamical effect: electrons are moving around, which results in the bonds moving around, and typically an aromatic molecule can be represented in many different ways, called mesomers, depending on which bonds are where. Of course ML models cannot account for this dynamical effect since we're giving them only one representation of the molecule, whereas DFT can somewhat account for aromaticity (though DFT can't in principle account for dynamical effects either, but we can help it do better).\n\nFor instance, this is an aromatic molecule and a few of its mesomers:\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1983404%2F5039cf5ffffe32b14715c500f10c1629%2FScreenshot%20from%202019-07-23%2008-09-16.png?generation=1567504224516934&amp;alt=media)\n\nSee how the bonds are moving around, describing the dynamical effect I told above.\n\nOne thing we tried is data augmentation. Since mesomers are basically the same molecule but with different node/edge features, we used the same target coupling constant as the initial molecule. It miserably failed, and I was surprised of this failure (my being surprised of the failure of a feature I designed happened a lot during the competition...)\n\nAre there any thoughts from the ML specialists/chemists/organizers of this competition @larsbratholm , about how we could improve the modeling of these types of molecules?",
    "616761": "I don't really have a good answer to this. I can see the data augmentation failing, since the property isn't really an average over the property of the individual states. The common methods in QM ML all heavily utilize transferability in the sense that only the immediate environment around the atoms of interest will have a big impact on the property, and any long range effect can be described by classical approximations. This assumption doesn't hold for conjugated systems.\nMaybe one could account for this in molecular graphs somehow by specifying which bonds are part of the same conjugated system? Or maybe some representation of the 'shape' of the conjugated system could be added? \nI found a paper that have looked into conjugated systems in particular that might be interesting: [10.1021/acscentsci.7b00405](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5785769/). I think there's been other work done on this, but any papers elude me at the moment.",
    "616880": "When you say augmentation is a failure, what do you mean?  Did you duplicate the molecule into all of its mesomers and took their average prediction as final prediction?  If so, did you weight the loss for these by 1/N when you have N mesomers ?\n\nEdit after reading Lars Answer.  If I get the notion of conjugated systems correctly, then indeed averaging isn't great.  But, even great, it is the one that minimises expected error probably.  This leads to another question:\n\nIs one of the mesomer giving a good prediction?  If yes, then maybe one can train a model to predict which mesomer was used in the simulation?",
    "618745": "The mesomers is a way for us to visualize what is going on quantum mechanically, using our classical way or representing molecules and bonds. The quantum chemical description of the system has no notion of mesomers and can be seen as all of these states combined in a non-linear fashion. If we had given you the parameters needed for you to reconstruct the wave function / electron density for the training set, it might have been easier to learn these special cases. But it might also be possible to create the model in a way where the ensemble of all the possible mesomers is given as input and matched to a single output, rather than enforcing that every mesomer should have the same properties (which was what I interpreted that @borisdee tried).",
    "619428": "That's correct @larsbratholm !\n\nAnd why would coupling types involving tripled bonded carbon/nitrogen atoms be so badly described? I thought that maybe it was because these are under-represented in the dataset. Maybe it could help by adding more of these bond types in the training set.",
    "619496": "larsbratholm ,  thanks for your explanations, but many (most?) of us used bonds computed by openbabel which means we used the classical view.  It also means that mesomers have different bonds and bonds types.  Alternatively, openbabel only outputs one mesomer.  Therefore adding all mesomers as data, and looking which one yields bets predictions could make sense.  Given I didn't know about mesomers (I have zero chemistry knowledge) before now, and given Boris did thought of it, I think my questions are fair.\n\n@borisdee , I would still love to get answers to my questions.  Is you data augmentation to use all mesomers of the molecule?  If so, did you look into which mesomers were giving best predictions?  And what do you mean by data augmentation failed miserably?\n\nOr was your message solely for Lars?   I naively thought I qualify as a ML specialist.  Maybe you think otherwise? ;)",
    "619541": "Don't be so grumpy @cpmpml 😁  It's just that I'm still trying to figure out how to give you a proper answer!",
    "619638": "I'm not really grumpy, but yes, when people ask for help and don't even acknowledge an answer I can become a bit impatient ;)  Anyway, thanks for the answer, looking forward to whatever you can share.",
    "619656": "cpmpml \nSo what we did is duplicate all the molecules into their mesomers. Some molecules had no mesomer, some had 2, some had 20! For each mesomer, we set the target constant to that of the initial molecule. \nBut I admit I don't know whether we averaged the predictions of all mesomers. I guess we didn't, we just had these mesomers as additional training/test data, with target labels being that of the 'initial' molecule.\n\nI was expecting that this approach may be giving more 'weight' to the molecules with more mesomers, as the model would encounter them more than those with few mesomers, and maybe decrease the error made on those molecules. But it did not work, that is, lmae was not better.\n\n&gt; Is one of the mesomer giving a good prediction? If yes, then maybe one can train a model to predict which mesomer was used in the simulation?\n\nI don't know that. We did not train separate models depending on the mesomers. This would require to many calculations, since each molecule can have up to 20 mesomers.\n\nI hope it answers your question!",
    "619730": "Thanks!  My gut feeling is that you should have weighted mesomer by the inverse of mesomer number per molecule to make it work.  But this is mere speculation.",
    "619857": "Well I can still try it! Will take a look at that thanks",
    "620536": "We just added the mesomers to the training data and it did not give an immediate improvement on our \"bad\" coupling types. At the time I was considering using mesomers for augmentation our model however was in a rapidly developing from an architecture point of view and there were bigger fish to fry so I kept pushing mesomers to the \"take-care-about-later\" list, on which they stayed until the competition was over.",
    "621206": "An after thought (I'm a chemist noob so please indulge me if tit is silly): why would mesomer only help for bad types?",
    "621340": "No you're right it should help for every type. But it seems that all the worse molecules in 1JH types had a significant number of mesomers so we were expecting that at least these types would improve",
    "626747": "larsbratholm I've seen on another topic the calculation details you used in Gaussian to calculate the coupling constant. But I was wondering, how do you calculate the coupling constant from ab initio calculations? Is it a linear response of some sort?\nThanks!",
    "627819": "It's been a while since I went through QM theory, but the scalar coupling is the second derivative of the electronic energy, with respect to the nuclear magnetic moments of the two nuclei. And I would think that Gaussian calculates this using response theory, as in section 2B [here](https://aip.scitation.org/doi/10.1063/1.1321296)",
    "628003": "Awesome thanks a lot! That's quite a calculation indeed. I understand the use of ML to predict these quantities rather than calculating them from first principles. Thanks for all your help"
  },
  "source": "meta"
}