{
  "id": 52716,
  "title": "How to use scale_pos_weight in LightGBM and XGBoost",
  "url": "/competitions/talkingdata-adtracking-fraud-detection/discussion/52716",
  "author_name": "",
  "post_date": "2018-03-22T12:41:20.781089600Z",
  "votes": null,
  "comment_count": 1,
  "views": 0,
  "content": "<p>Hi,\nI know that 'scale_pos_weight' in LightGBM and XGB is used for imbalanced classification problems. I have the following questions about it:</p>\n\n<ol>\n<li><p>How is it calculated for these algorithms? </p></li>\n<li><p>Is the criteria same for both XGB and LightGBM?</p></li>\n<li><p>What is the correct way to set it?\nFrom the documentation of XGB, I found:</p></li>\n</ol>\n\n<blockquote>\n  <p>Control the balance of positive and negative weights, useful for unbalanced classes. A typical value to consider: sum(negative cases) / sum(positive cases)</p>\n</blockquote>\n\n<p>For this dataset it would be equal to: 99.81/0.19 = 525.315</p>\n\n<p>Is this really the correct way to do it for LightGBM as well? In LightGBM ketnals, 99 has been used as scale_pos_weight.</p>",
  "messages": [
    {
      "id": "301177",
      "postDate": "03/22/2018 12:41:20",
      "content": "<p>Hi,\nI know that 'scale_pos_weight' in LightGBM and XGB is used for imbalanced classification problems. I have the following questions about it:</p>\n\n<ol>\n<li><p>How is it calculated for these algorithms? </p></li>\n<li><p>Is the criteria same for both XGB and LightGBM?</p></li>\n<li><p>What is the correct way to set it?\nFrom the documentation of XGB, I found:</p></li>\n</ol>\n\n<blockquote>\n  <p>Control the balance of positive and negative weights, useful for unbalanced classes. A typical value to consider: sum(negative cases) / sum(positive cases)</p>\n</blockquote>\n\n<p>For this dataset it would be equal to: 99.81/0.19 = 525.315</p>\n\n<p>Is this really the correct way to do it for LightGBM as well? In LightGBM ketnals, 99 has been used as scale_pos_weight.</p>",
      "rawMarkdown": "Hi,\nI know that 'scale_pos_weight' in LightGBM and XGB is used for imbalanced classification problems. I have the following questions about it:\n\n 1. How is it calculated for these algorithms? \n\n 2. Is the criteria same for both XGB and LightGBM?\n\n 3. What is the correct way to set it?\nFrom the documentation of XGB, I found:\n\n&gt;  Control the balance of positive and negative weights, useful for unbalanced classes. A typical value to consider: sum(negative cases) / sum(positive cases)\n\nFor this dataset it would be equal to: 99.81/0.19 = 525.315\n\nIs this really the correct way to do it for LightGBM as well? In LightGBM ketnals, 99 has been used as scale_pos_weight.",
      "votes": null
    },
    {
      "id": "301237",
      "postDate": "03/22/2018 14:17:32",
      "content": "<p>Bumping it higher than the kernels does help a bit, although the impact is not massive.</p>",
      "rawMarkdown": "Bumping it higher than the kernels does help a bit, although the impact is not massive.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 301237,
      "author_name": "konradb",
      "author_url": "",
      "post_date": "03/22/2018 14:17:32",
      "content": "<p>Bumping it higher than the kernels does help a bit, although the impact is not massive.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "301177": "Hi,\nI know that 'scale_pos_weight' in LightGBM and XGB is used for imbalanced classification problems. I have the following questions about it:\n\n 1. How is it calculated for these algorithms? \n\n 2. Is the criteria same for both XGB and LightGBM?\n\n 3. What is the correct way to set it?\nFrom the documentation of XGB, I found:\n\n&gt;  Control the balance of positive and negative weights, useful for unbalanced classes. A typical value to consider: sum(negative cases) / sum(positive cases)\n\nFor this dataset it would be equal to: 99.81/0.19 = 525.315\n\nIs this really the correct way to do it for LightGBM as well? In LightGBM ketnals, 99 has been used as scale_pos_weight.",
    "301237": "Bumping it higher than the kernels does help a bit, although the impact is not massive."
  },
  "source": "meta"
}