{
  "id": 100547,
  "title": "how to handle NA is distance feature",
  "url": "/competitions/champs-scalar-coupling/discussion/100547",
  "author_name": "",
  "post_date": "2019-07-19T06:17:44.089813200Z",
  "votes": null,
  "comment_count": 10,
  "views": 0,
  "content": "<p>Hi, Wanted the check how everyone is handling NA in distance features. For example, distance from N for a molecule which doesn't have N in it will be NA. We can't set it to 0. Should we set it to a negative value or a crazy high value (9999)? I am currently using LGBM.  But want an imputation approach which works for all types of models. Thanks in advance for your response.</p>",
  "messages": [
    {
      "id": "579708",
      "postDate": "07/19/2019 06:17:44",
      "content": "<p>Hi, Wanted the check how everyone is handling NA in distance features. For example, distance from N for a molecule which doesn't have N in it will be NA. We can't set it to 0. Should we set it to a negative value or a crazy high value (9999)? I am currently using LGBM.  But want an imputation approach which works for all types of models. Thanks in advance for your response.</p>",
      "rawMarkdown": "Hi, Wanted the check how everyone is handling NA in distance features. For example, distance from N for a molecule which doesn't have N in it will be NA. We can't set it to 0. Should we set it to a negative value or a crazy high value (9999)? I am currently using LGBM.  But want an imputation approach which works for all types of models. Thanks in advance for your response.",
      "votes": null
    },
    {
      "id": "579716",
      "postDate": "07/19/2019 06:27:40",
      "content": "<p>Why not <a href=\"https://www.kaggle.com/c/champs-scalar-coupling/discussion/100242\">compute all distances</a>?  </p>",
      "rawMarkdown": "Why not [compute all distances](https://www.kaggle.com/c/champs-scalar-coupling/discussion/100242)?",
      "votes": null
    },
    {
      "id": "579807",
      "postDate": "07/19/2019 08:47:14",
      "content": "<p><a href=\"/cpmpml\">@cpmpml</a>  This is super awesome. thanks for pointing me to your kernel.</p>",
      "rawMarkdown": "cpmpml  This is super awesome. thanks for pointing me to your kernel.",
      "votes": null
    },
    {
      "id": "579862",
      "postDate": "07/19/2019 10:22:51",
      "content": "<p>LightGBM can handle NaN value.\nhowever, the best way to handle NaN depends on the feature property. So we should try some pattern(keep nan, fill -1, fill mean, fill big value, and so on) with thought of the feature property.</p>\n\n<p>If you want to know more detail, read the discussion or official document.\n<a href=\"https://www.kaggle.com/c/home-credit-default-risk/discussion/57918#336028\">https://www.kaggle.com/c/home-credit-default-risk/discussion/57918#336028</a></p>",
      "rawMarkdown": "LightGBM can handle NaN value.\nhowever, the best way to handle NaN depends on the feature property. So we should try some pattern(keep nan, fill -1, fill mean, fill big value, and so on) with thought of the feature property.\n\nIf you want to know more detail, read the discussion or official document.\nhttps://www.kaggle.com/c/home-credit-default-risk/discussion/57918#336028",
      "votes": null
    },
    {
      "id": "579886",
      "postDate": "07/19/2019 11:17:40",
      "content": "<p>I use np.inf for LGBM and 1/distance feature for NN</p>",
      "rawMarkdown": "I use np.inf for LGBM and 1/distance feature for NN",
      "votes": null
    },
    {
      "id": "579896",
      "postDate": "07/19/2019 11:27:10",
      "content": "<p>If you have NaNs in your features then, from a physical point of view, it makes sense to fill NaN values for distance features with infinity and inverse distances and potentials with zeros because if an atom is at an infinite distance its influence (potential or inverse distance) is zero.</p>",
      "rawMarkdown": "If you have NaNs in your features then, from a physical point of view, it makes sense to fill NaN values for distance features with infinity and inverse distances and potentials with zeros because if an atom is at an infinite distance its influence (potential or inverse distance) is zero.",
      "votes": null
    },
    {
      "id": "580597",
      "postDate": "07/20/2019 12:42:51",
      "content": "<p>was thinking the same. but was not sure what impact inf value will have on the model. Generally, we should try to keep the features in similar value range, right?</p>",
      "rawMarkdown": "was thinking the same. but was not sure what impact inf value will have on the model. Generally, we should try to keep the features in similar value range, right?",
      "votes": null
    },
    {
      "id": "580598",
      "postDate": "07/20/2019 12:44:57",
      "content": "<p>Thanks for the tip <a href=\"/go5kuramubon\">@go5kuramubon</a>. I ran the model without fixing the NaNs and the score improved. Somehow the idea of leaving NaN didn't feel good.</p>",
      "rawMarkdown": "Thanks for the tip @go5kuramubon. I ran the model without fixing the NaNs and the score improved. Somehow the idea of leaving NaN didn't feel good.",
      "votes": null
    },
    {
      "id": "580631",
      "postDate": "07/20/2019 13:54:34",
      "content": "<p>If you use neural network, then you should not use infinity and definitely you should scale all values to the same range, e. g. standard scaling is that all features are scaled to have unit variance and zero mean.  For regression trees they do not have to be scaled as the algorithm works different way.\nI do not think that neural networks in quantum chemistry use distance features, at least not directly. If you want to try NNs, then I would start with Schnet. </p>",
      "rawMarkdown": "If you use neural network, then you should not use infinity and definitely you should scale all values to the same range, e. g. standard scaling is that all features are scaled to have unit variance and zero mean.  For regression trees they do not have to be scaled as the algorithm works different way.\nI do not think that neural networks in quantum chemistry use distance features, at least not directly. If you want to try NNs, then I would start with Schnet.",
      "votes": null
    },
    {
      "id": "580674",
      "postDate": "07/20/2019 14:49:17",
      "content": "<p>Thanks <a href=\"/somnambwl\">@somnambwl</a> will look at Schnet</p>",
      "rawMarkdown": "Thanks @somnambwl will look at Schnet",
      "votes": null
    },
    {
      "id": "580786",
      "postDate": "07/20/2019 18:49:39",
      "content": "<p>Using lightgbm - had a Big Ben sandwich (a Pittsburgh special) bet with my team mate regarding replacement of nan values with 0 for a set of features were I thought a zero was the logical value - there was a 0.004 difference in our leader board score (i owe him a sandwich).  My takeaway was that lightgbm is smart enough to use nan or zero.</p>",
      "rawMarkdown": "Using lightgbm - had a Big Ben sandwich (a Pittsburgh special) bet with my team mate regarding replacement of nan values with 0 for a set of features were I thought a zero was the logical value - there was a 0.004 difference in our leader board score (i owe him a sandwich).  My takeaway was that lightgbm is smart enough to use nan or zero.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 579716,
      "author_name": "cpmpml",
      "author_url": "",
      "post_date": "07/19/2019 06:27:40",
      "content": "<p>Why not <a href=\"https://www.kaggle.com/c/champs-scalar-coupling/discussion/100242\">compute all distances</a>?  </p>",
      "votes": null,
      "replies": [
        {
          "id": 579807,
          "author_name": "harisharma",
          "author_url": "",
          "post_date": "07/19/2019 08:47:14",
          "content": "<p><a href=\"/cpmpml\">@cpmpml</a>  This is super awesome. thanks for pointing me to your kernel.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 579862,
      "author_name": "go5kuramubon",
      "author_url": "",
      "post_date": "07/19/2019 10:22:51",
      "content": "<p>LightGBM can handle NaN value.\nhowever, the best way to handle NaN depends on the feature property. So we should try some pattern(keep nan, fill -1, fill mean, fill big value, and so on) with thought of the feature property.</p>\n\n<p>If you want to know more detail, read the discussion or official document.\n<a href=\"https://www.kaggle.com/c/home-credit-default-risk/discussion/57918#336028\">https://www.kaggle.com/c/home-credit-default-risk/discussion/57918#336028</a></p>",
      "votes": null,
      "replies": [
        {
          "id": 580598,
          "author_name": "harisharma",
          "author_url": "",
          "post_date": "07/20/2019 12:44:57",
          "content": "<p>Thanks for the tip <a href=\"/go5kuramubon\">@go5kuramubon</a>. I ran the model without fixing the NaNs and the score improved. Somehow the idea of leaving NaN didn't feel good.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 579886,
      "author_name": "silantev",
      "author_url": "",
      "post_date": "07/19/2019 11:17:40",
      "content": "<p>I use np.inf for LGBM and 1/distance feature for NN</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 579896,
      "author_name": "somnambwl",
      "author_url": "",
      "post_date": "07/19/2019 11:27:10",
      "content": "<p>If you have NaNs in your features then, from a physical point of view, it makes sense to fill NaN values for distance features with infinity and inverse distances and potentials with zeros because if an atom is at an infinite distance its influence (potential or inverse distance) is zero.</p>",
      "votes": null,
      "replies": [
        {
          "id": 580597,
          "author_name": "harisharma",
          "author_url": "",
          "post_date": "07/20/2019 12:42:51",
          "content": "<p>was thinking the same. but was not sure what impact inf value will have on the model. Generally, we should try to keep the features in similar value range, right?</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 580631,
          "author_name": "somnambwl",
          "author_url": "",
          "post_date": "07/20/2019 13:54:34",
          "content": "<p>If you use neural network, then you should not use infinity and definitely you should scale all values to the same range, e. g. standard scaling is that all features are scaled to have unit variance and zero mean.  For regression trees they do not have to be scaled as the algorithm works different way.\nI do not think that neural networks in quantum chemistry use distance features, at least not directly. If you want to try NNs, then I would start with Schnet. </p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 580674,
          "author_name": "harisharma",
          "author_url": "",
          "post_date": "07/20/2019 14:49:17",
          "content": "<p>Thanks <a href=\"/somnambwl\">@somnambwl</a> will look at Schnet</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 580786,
      "author_name": "pcjimmmy",
      "author_url": "",
      "post_date": "07/20/2019 18:49:39",
      "content": "<p>Using lightgbm - had a Big Ben sandwich (a Pittsburgh special) bet with my team mate regarding replacement of nan values with 0 for a set of features were I thought a zero was the logical value - there was a 0.004 difference in our leader board score (i owe him a sandwich).  My takeaway was that lightgbm is smart enough to use nan or zero.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "579708": "Hi, Wanted the check how everyone is handling NA in distance features. For example, distance from N for a molecule which doesn't have N in it will be NA. We can't set it to 0. Should we set it to a negative value or a crazy high value (9999)? I am currently using LGBM.  But want an imputation approach which works for all types of models. Thanks in advance for your response.",
    "579716": "Why not [compute all distances](https://www.kaggle.com/c/champs-scalar-coupling/discussion/100242)?",
    "579807": "cpmpml  This is super awesome. thanks for pointing me to your kernel.",
    "579862": "LightGBM can handle NaN value.\nhowever, the best way to handle NaN depends on the feature property. So we should try some pattern(keep nan, fill -1, fill mean, fill big value, and so on) with thought of the feature property.\n\nIf you want to know more detail, read the discussion or official document.\nhttps://www.kaggle.com/c/home-credit-default-risk/discussion/57918#336028",
    "579886": "I use np.inf for LGBM and 1/distance feature for NN",
    "579896": "If you have NaNs in your features then, from a physical point of view, it makes sense to fill NaN values for distance features with infinity and inverse distances and potentials with zeros because if an atom is at an infinite distance its influence (potential or inverse distance) is zero.",
    "580597": "was thinking the same. but was not sure what impact inf value will have on the model. Generally, we should try to keep the features in similar value range, right?",
    "580598": "Thanks for the tip @go5kuramubon. I ran the model without fixing the NaNs and the score improved. Somehow the idea of leaving NaN didn't feel good.",
    "580631": "If you use neural network, then you should not use infinity and definitely you should scale all values to the same range, e. g. standard scaling is that all features are scaled to have unit variance and zero mean.  For regression trees they do not have to be scaled as the algorithm works different way.\nI do not think that neural networks in quantum chemistry use distance features, at least not directly. If you want to try NNs, then I would start with Schnet.",
    "580674": "Thanks @somnambwl will look at Schnet",
    "580786": "Using lightgbm - had a Big Ben sandwich (a Pittsburgh special) bet with my team mate regarding replacement of nan values with 0 for a set of features were I thought a zero was the logical value - there was a 0.004 difference in our leader board score (i owe him a sandwich).  My takeaway was that lightgbm is smart enough to use nan or zero."
  },
  "source": "meta"
}