{
  "id": 78470,
  "title": "Please recommend some strategies to handle outliers when doing regression",
  "url": "/competitions/elo-merchant-category-recommendation/discussion/78470",
  "author_name": "Zhuang Jia",
  "post_date": "2019-01-24T08:31:48.221000",
  "votes": 18,
  "comment_count": 23,
  "views": 0,
  "content": "<p>Do we have some strategies to handle outliers when doing regression, if the outliers is important to us?</p>",
  "messages": [
    {
      "id": 460680,
      "postDate": "2019-01-24T08:31:48.220Z",
      "content": "<p>Do we have some strategies to handle outliers when doing regression, if the outliers is important to us?</p>",
      "rawMarkdown": "Do we have some strategies to handle outliers when doing regression, if the outliers is important to us?",
      "votes": 18
    },
    {
      "id": 460843,
      "postDate": "2019-01-24T14:28:43.567Z",
      "content": "<ol>\n<li><p>If you want to fit more closely to outliers: Change the metric you use for minimizing the sum of the residuals. That is, instead of minimizing the sum of the squared residuals, maybe minimize for the sum of the residuals to the power of 5. </p></li>\n<li><p>If you want to fit less closely to outliers: Remove the outliers from your sample, or change the the optimization from minimizing the sum of the squared residuals, to minimizing the sum of the L1 residuals maybe. Or minimizing the sum of the Square Root Residuals</p></li>\n</ol>\n\n<p>I think you can also set weights for each point if these don't work. So, you can specify all non-outlier points have a weight of 1, but the outlier points have a weight of 10.</p>",
      "rawMarkdown": "1. If you want to fit more closely to outliers: Change the metric you use for minimizing the sum of the residuals. That is, instead of minimizing the sum of the squared residuals, maybe minimize for the sum of the residuals to the power of 5. \n\n2. If you want to fit less closely to outliers: Remove the outliers from your sample, or change the the optimization from minimizing the sum of the squared residuals, to minimizing the sum of the L1 residuals maybe. Or minimizing the sum of the Square Root Residuals\n\nI think you can also set weights for each point if these don't work. So, you can specify all non-outlier points have a weight of 1, but the outlier points have a weight of 10.",
      "votes": 16,
      "replies": [
        {
          "id": 461008,
          "postDate": "2019-01-25T01:25:11.040Z",
          "content": "<p>Thanks, very helpful! I'v tried weight for outlier and non-outlier just as you said.</p>",
          "rawMarkdown": "Thanks, very helpful! I'v tried weight for outlier and non-outlier just as you said.",
          "votes": 1
        },
        {
          "id": 461238,
          "postDate": "2019-01-25T15:42:27.517Z",
          "rawMarkdown": "",
          "isDeleted": true
        },
        {
          "id": 461535,
          "postDate": "2019-01-26T09:31:25.850Z",
          "content": "<p><a href=\"/jiazhuang\">@jiazhuang</a> May I know what worked and did not work for you so far with handling outliers?</p>",
          "rawMarkdown": "@jiazhuang May I know what worked and did not work for you so far with handling outliers?"
        },
        {
          "id": 461573,
          "postDate": "2019-01-26T12:17:03.163Z",
          "content": "<p>@CoreyLevinson I tried to use the loss function of minimizing for the sum of the residuals to the power of 5 as follows:</p>\n\n<pre><code>def custom_asymmetric_train(y_true, y_pred):\n    residual = (y_true - y_pred).astype(\"float\")\n    grad = -5*residual**4\n    hess = 20.0*residual**3\n    return grad, hess\n\ndef custom_asymmetric_valid(y_true, y_pred):\n    residual = (y_true - y_pred).astype(\"float\")\n    loss = residual**5\n    return \"custom_asymmetric_eval\", np.mean(loss), False\n\nmodel = LGBMClassifier(boosting_type=\"gbdt\", objective=custom_asymmetric_train）\n\nmodel.fit( X_train, y_train, eval_set=eval_set, eval_metric=custom_asymmetric_valid）\n</code></pre>\n\n<p>However, the loss does not change for each CV. Any help on this?</p>",
          "rawMarkdown": "@CoreyLevinson I tried to use the loss function of minimizing for the sum of the residuals to the power of 5 as follows:\n\n    def custom_asymmetric_train(y_true, y_pred):\n        residual = (y_true - y_pred).astype(\"float\")\n        grad = -5*residual**4\n        hess = 20.0*residual**3\n        return grad, hess\n\n    def custom_asymmetric_valid(y_true, y_pred):\n        residual = (y_true - y_pred).astype(\"float\")\n        loss = residual**5\n        return \"custom_asymmetric_eval\", np.mean(loss), False\n\n    model = LGBMClassifier(boosting_type=\"gbdt\", objective=custom_asymmetric_train）\n\n    model.fit( X_train, y_train, eval_set=eval_set, eval_metric=custom_asymmetric_valid）\n\nHowever, the loss does not change for each CV. Any help on this?",
          "votes": 4
        },
        {
          "id": 461637,
          "postDate": "2019-01-26T16:05:50.050Z",
          "content": "<ol>\n<li>Try multiplying the learning rate by 100, or dividing the learning rate by 100 to verify if the loss actually does not change.</li>\n<li>I know that the model improves by travelling in the negative gradient direction, but maybe from the function <code>custom_asymmetric_train</code> it is not expecting you to already negate it.</li>\n<li><p>Try this, I know in previous competition my custom stuff did not work unless I specified parameters to 'None':</p>\n\n<p>import lightgbm as lgb</p>\n\n<pre><code>params = {\n    'boosting_type': 'gbdt',\n    'objective': 'None',\n    'metric': 'None',\n}\n\nmodel = lgb.train(params,\n                lgb_train, # a LGBM Dataset\n                num_boost_round=10,\n                fobj=custom_asymmetric_train,\n                feval=custom_asymmetric_valid,\n                valid_sets=eval_set # Also should be a LGBM Dataset I think\n)\n</code></pre></li>\n</ol>",
          "rawMarkdown": "1. Try multiplying the learning rate by 100, or dividing the learning rate by 100 to verify if the loss actually does not change.\n2. I know that the model improves by travelling in the negative gradient direction, but maybe from the function `custom_asymmetric_train` it is not expecting you to already negate it.\n3. Try this, I know in previous competition my custom stuff did not work unless I specified parameters to 'None':\n\n\n\n    import lightgbm as lgb\n    \n        params = {\n            'boosting_type': 'gbdt',\n            'objective': 'None',\n            'metric': 'None',\n        }\n        \n        model = lgb.train(params,\n                        lgb_train, # a LGBM Dataset\n                        num_boost_round=10,\n                        fobj=custom_asymmetric_train,\n                        feval=custom_asymmetric_valid,\n                        valid_sets=eval_set # Also should be a LGBM Dataset I think\n        )",
          "votes": 4
        },
        {
          "id": 462275,
          "postDate": "2019-01-28T02:53:15.273Z",
          "content": "<p>@CoreyLevinson Thanks! Let me try it.</p>",
          "rawMarkdown": "@CoreyLevinson Thanks! Let me try it."
        },
        {
          "id": 463359,
          "postDate": "2019-01-29T21:21:43.247Z",
          "rawMarkdown": "",
          "isDeleted": true
        },
        {
          "id": 463844,
          "postDate": "2019-01-30T17:52:43.940Z",
          "content": "<p><a href=\"/xiaojiu1414\">@xiaojiu1414</a>, @CoreyLevinson\nI tried to use the function above but it throws exception </p>\n\n<p>TypeError: unsupported operand type(s) for -: 'float' and 'Dataset'</p>\n\n<p>Print type() shows that the first parameter (y_true) is a numpy array while the second (y_pred) is a lightGBM dataset.\nAny idea how to convert it to numpy? I found .get_data() function but it does not work either.</p>",
          "rawMarkdown": "@xiaojiu1414, @CoreyLevinson\nI tried to use the function above but it throws exception \n\nTypeError: unsupported operand type(s) for -: 'float' and 'Dataset'\n\nPrint type() shows that the first parameter (y_true) is a numpy array while the second (y_pred) is a lightGBM dataset.\nAny idea how to convert it to numpy? I found .get_data() function but it does not work either.",
          "votes": 1
        },
        {
          "id": 464013,
          "postDate": "2019-01-31T04:01:17.770Z",
          "content": "<p>That is happening because you are using lightgbm instead of lightgbm scikt learn API</p>",
          "rawMarkdown": "That is happening because you are using lightgbm instead of lightgbm scikt learn API",
          "votes": 2
        },
        {
          "id": 464014,
          "postDate": "2019-01-31T04:02:55.673Z",
          "content": "<p>You can use the following format:\ndef custom_asymmetric_train(preds, train_data):</p>\n\n<pre><code>y_true = train_data.get_label()\nresidual = (y_true - preds).astype(\"float\")\ngrad = -4*residual**3\nhess = 12*residual**2\nreturn grad, hess\n</code></pre>\n\n<p>`def custom_asymmetric_valid(preds, train_data):</p>\n\n<pre><code>y_true = train_data.get_label()\nresidual = (y_true - preds).astype(\"float\")\nloss =residual**4\nreturn \"custom_asymmetric_eval\", np.mean(loss), False\n</code></pre>",
          "rawMarkdown": "You can use the following format:\ndef custom_asymmetric_train(preds, train_data):\n\n    y_true = train_data.get_label()\n    residual = (y_true - preds).astype(\"float\")\n    grad = -4*residual**3\n    hess = 12*residual**2\n    return grad, hess\n\n`def custom_asymmetric_valid(preds, train_data):\n\n    y_true = train_data.get_label()\n    residual = (y_true - preds).astype(\"float\")\n    loss =residual**4\n    return \"custom_asymmetric_eval\", np.mean(loss), False",
          "votes": 4
        },
        {
          "id": 464336,
          "postDate": "2019-01-31T16:32:26.707Z",
          "content": "<p>Harshit, much appreciated. It works now. </p>",
          "rawMarkdown": "Harshit, much appreciated. It works now. ",
          "votes": 1
        }
      ]
    },
    {
      "id": 460768,
      "postDate": "2019-01-24T11:40:27.340Z",
      "content": "<p>You can try measuring how much of your regression model is being influenced by that outlier. I wouldn't recommend just erasing it (some people do that)</p>",
      "rawMarkdown": "You can try measuring how much of your regression model is being influenced by that outlier. I wouldn't recommend just erasing it (some people do that)",
      "votes": 1,
      "replies": [
        {
          "id": 461010,
          "postDate": "2019-01-25T01:26:27.193Z",
          "content": "<p>yes, we can't just simply remove it.</p>",
          "rawMarkdown": "yes, we can't just simply remove it."
        }
      ]
    },
    {
      "id": 462323,
      "postDate": "2019-01-28T05:32:51.300Z",
      "content": "<p>Hi,\n    Did you get this solved? I tried power of 5, but the LGB never improved since the first round. Could you share your solution? Thank you!</p>",
      "rawMarkdown": "Hi,\n    Did you get this solved? I tried power of 5, but the LGB never improved since the first round. Could you share your solution? Thank you!",
      "replies": [
        {
          "id": 463213,
          "postDate": "2019-01-29T16:15:56.033Z",
          "content": "<p>I would try power of 4 or power of 6. It should be even number. </p>",
          "rawMarkdown": "I would try power of 4 or power of 6. It should be even number. ",
          "votes": 1
        }
      ]
    },
    {
      "id": 460877,
      "postDate": "2019-01-24T15:32:14.463Z",
      "content": "<p>I did a split onto two models\n1. LGB model Trained with a binary goal (outlier or not).\n2. LGB Is trained on the dataset without outliers (target&lt;=-33) with all parameters set to the same values.\nResults are joined with. If the model 1 says it should be an outlier, then the predicted score set to -33. Otherwise the score is taken from model 2.\nBut it gave me very bad final score.\nMay be I had to optimize the first model better. Now it predicts correctly only 2-3 outliers out of hundreds we have.</p>",
      "rawMarkdown": "I did a split onto two models\n1. LGB model Trained with a binary goal (outlier or not).\n2. LGB Is trained on the dataset without outliers (target&lt;=-33) with all parameters set to the same values.\nResults are joined with. If the model 1 says it should be an outlier, then the predicted score set to -33. Otherwise the score is taken from model 2.\nBut it gave me very bad final score.\nMay be I had to optimize the first model better. Now it predicts correctly only 2-3 outliers out of hundreds we have.",
      "replies": [
        {
          "id": 461012,
          "postDate": "2019-01-25T01:29:11.047Z",
          "content": "<p>yes, outlier classification is highly imbalanced. It's hard to predict them accurately. But It's still a good try.</p>",
          "rawMarkdown": "yes, outlier classification is highly imbalanced. It's hard to predict them accurately. But It's still a good try."
        },
        {
          "id": 461141,
          "postDate": "2019-01-25T10:44:55.973Z",
          "content": "<p>@Costa.Medvedev\nUse three model instead. Model with outliers , model without outliers, and model for outliers prediction. Check this kernel :<a href=\"https://www.kaggle.com/waitingli/combining-your-model-with-a-model-without-outlier\">https://www.kaggle.com/waitingli/combining-your-model-with-a-model-without-outlier</a></p>",
          "rawMarkdown": "@Costa.Medvedev\nUse three model instead. Model with outliers , model without outliers, and model for outliers prediction. Check this kernel :https://www.kaggle.com/waitingli/combining-your-model-with-a-model-without-outlier",
          "votes": 2
        },
        {
          "id": 461537,
          "postDate": "2019-01-26T09:38:57.687Z",
          "content": "<p><a href=\"/salamatburj\">@salamatburj</a> I tried that, but cannot understand why it works. It is using a more general model for the (predicted) outliers than for the non-outliers, meaning that the general model is overly affected by the outlier values for predicting most of the (non-outlying) data. But why would a gbm behave this way? Thanks.</p>",
          "rawMarkdown": "@salamatburj I tried that, but cannot understand why it works. It is using a more general model for the (predicted) outliers than for the non-outliers, meaning that the general model is overly affected by the outlier values for predicting most of the (non-outlying) data. But why would a gbm behave this way? Thanks."
        },
        {
          "id": 461866,
          "postDate": "2019-01-27T07:43:45Z",
          "content": "<p>@GideonTeo Yes, outliers are affecting rmse error a lot. I think the key is the outliers prediction. You might have different features which are more important to outliers and less for regression. Outliers prediction provides extra insight to the data. </p>",
          "rawMarkdown": "@GideonTeo Yes, outliers are affecting rmse error a lot. I think the key is the outliers prediction. You might have different features which are more important to outliers and less for regression. Outliers prediction provides extra insight to the data. ",
          "votes": 1
        },
        {
          "id": 463296,
          "postDate": "2019-01-29T18:56:33.733Z",
          "content": "<p><a href=\"/salamatburj\">@salamatburj</a>   3 is a good number )))\nI will try.</p>",
          "rawMarkdown": "@salamatburj   3 is a good number )))\nI will try."
        }
      ]
    },
    {
      "id": 461407,
      "postDate": "2019-01-25T23:37:08.283Z",
      "rawMarkdown": "",
      "isDeleted": true
    }
  ],
  "comments": [
    {
      "id": 460843,
      "author_name": "CoreyJamesLevinson",
      "author_url": "",
      "post_date": "2019-01-24T14:28:43.567000",
      "content": "<ol>\n<li><p>If you want to fit more closely to outliers: Change the metric you use for minimizing the sum of the residuals. That is, instead of minimizing the sum of the squared residuals, maybe minimize for the sum of the residuals to the power of 5. </p></li>\n<li><p>If you want to fit less closely to outliers: Remove the outliers from your sample, or change the the optimization from minimizing the sum of the squared residuals, to minimizing the sum of the L1 residuals maybe. Or minimizing the sum of the Square Root Residuals</p></li>\n</ol>\n\n<p>I think you can also set weights for each point if these don't work. So, you can specify all non-outlier points have a weight of 1, but the outlier points have a weight of 10.</p>",
      "votes": 16,
      "replies": [
        {
          "id": 461008,
          "author_name": "Zhuang Jia",
          "author_url": "",
          "post_date": "2019-01-25T01:25:11.040000",
          "content": "<p>Thanks, very helpful! I'v tried weight for outlier and non-outlier just as you said.</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 461238,
          "author_name": "",
          "author_url": "",
          "post_date": "2019-01-25T15:42:27.517000",
          "content": "",
          "votes": 0,
          "replies": []
        },
        {
          "id": 461535,
          "author_name": "HyperSeedOptimized",
          "author_url": "",
          "post_date": "2019-01-26T09:31:25.850000",
          "content": "<p><a href=\"/jiazhuang\">@jiazhuang</a> May I know what worked and did not work for you so far with handling outliers?</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 461573,
          "author_name": "DeepInvolution",
          "author_url": "",
          "post_date": "2019-01-26T12:17:03.163000",
          "content": "<p>@CoreyLevinson I tried to use the loss function of minimizing for the sum of the residuals to the power of 5 as follows:</p>\n\n<pre><code>def custom_asymmetric_train(y_true, y_pred):\n    residual = (y_true - y_pred).astype(\"float\")\n    grad = -5*residual**4\n    hess = 20.0*residual**3\n    return grad, hess\n\ndef custom_asymmetric_valid(y_true, y_pred):\n    residual = (y_true - y_pred).astype(\"float\")\n    loss = residual**5\n    return \"custom_asymmetric_eval\", np.mean(loss), False\n\nmodel = LGBMClassifier(boosting_type=\"gbdt\", objective=custom_asymmetric_train）\n\nmodel.fit( X_train, y_train, eval_set=eval_set, eval_metric=custom_asymmetric_valid）\n</code></pre>\n\n<p>However, the loss does not change for each CV. Any help on this?</p>",
          "votes": 4,
          "replies": []
        },
        {
          "id": 461637,
          "author_name": "CoreyJamesLevinson",
          "author_url": "",
          "post_date": "2019-01-26T16:05:50.050000",
          "content": "<ol>\n<li>Try multiplying the learning rate by 100, or dividing the learning rate by 100 to verify if the loss actually does not change.</li>\n<li>I know that the model improves by travelling in the negative gradient direction, but maybe from the function <code>custom_asymmetric_train</code> it is not expecting you to already negate it.</li>\n<li><p>Try this, I know in previous competition my custom stuff did not work unless I specified parameters to 'None':</p>\n\n<p>import lightgbm as lgb</p>\n\n<pre><code>params = {\n    'boosting_type': 'gbdt',\n    'objective': 'None',\n    'metric': 'None',\n}\n\nmodel = lgb.train(params,\n                lgb_train, # a LGBM Dataset\n                num_boost_round=10,\n                fobj=custom_asymmetric_train,\n                feval=custom_asymmetric_valid,\n                valid_sets=eval_set # Also should be a LGBM Dataset I think\n)\n</code></pre></li>\n</ol>",
          "votes": 4,
          "replies": []
        },
        {
          "id": 462275,
          "author_name": "DeepInvolution",
          "author_url": "",
          "post_date": "2019-01-28T02:53:15.273000",
          "content": "<p>@CoreyLevinson Thanks! Let me try it.</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 463359,
          "author_name": "",
          "author_url": "",
          "post_date": "2019-01-29T21:21:43.247000",
          "content": "",
          "votes": 0,
          "replies": []
        },
        {
          "id": 463844,
          "author_name": "Costa.Medvedev",
          "author_url": "",
          "post_date": "2019-01-30T17:52:43.940000",
          "content": "<p><a href=\"/xiaojiu1414\">@xiaojiu1414</a>, @CoreyLevinson\nI tried to use the function above but it throws exception </p>\n\n<p>TypeError: unsupported operand type(s) for -: 'float' and 'Dataset'</p>\n\n<p>Print type() shows that the first parameter (y_true) is a numpy array while the second (y_pred) is a lightGBM dataset.\nAny idea how to convert it to numpy? I found .get_data() function but it does not work either.</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 464013,
          "author_name": "HarshitMehta",
          "author_url": "",
          "post_date": "2019-01-31T04:01:17.770000",
          "content": "<p>That is happening because you are using lightgbm instead of lightgbm scikt learn API</p>",
          "votes": 2,
          "replies": []
        },
        {
          "id": 464014,
          "author_name": "HarshitMehta",
          "author_url": "",
          "post_date": "2019-01-31T04:02:55.673000",
          "content": "<p>You can use the following format:\ndef custom_asymmetric_train(preds, train_data):</p>\n\n<pre><code>y_true = train_data.get_label()\nresidual = (y_true - preds).astype(\"float\")\ngrad = -4*residual**3\nhess = 12*residual**2\nreturn grad, hess\n</code></pre>\n\n<p>`def custom_asymmetric_valid(preds, train_data):</p>\n\n<pre><code>y_true = train_data.get_label()\nresidual = (y_true - preds).astype(\"float\")\nloss =residual**4\nreturn \"custom_asymmetric_eval\", np.mean(loss), False\n</code></pre>",
          "votes": 4,
          "replies": []
        },
        {
          "id": 464336,
          "author_name": "Costa.Medvedev",
          "author_url": "",
          "post_date": "2019-01-31T16:32:26.707000",
          "content": "<p>Harshit, much appreciated. It works now. </p>",
          "votes": 1,
          "replies": []
        }
      ]
    },
    {
      "id": 460768,
      "author_name": "rafael chaves",
      "author_url": "",
      "post_date": "2019-01-24T11:40:27.340000",
      "content": "<p>You can try measuring how much of your regression model is being influenced by that outlier. I wouldn't recommend just erasing it (some people do that)</p>",
      "votes": 1,
      "replies": [
        {
          "id": 461010,
          "author_name": "Zhuang Jia",
          "author_url": "",
          "post_date": "2019-01-25T01:26:27.193000",
          "content": "<p>yes, we can't just simply remove it.</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 462323,
      "author_name": "",
      "author_url": "",
      "post_date": "2019-01-28T05:32:51.300000",
      "content": "<p>Hi,\n    Did you get this solved? I tried power of 5, but the LGB never improved since the first round. Could you share your solution? Thank you!</p>",
      "votes": 0,
      "replies": [
        {
          "id": 463213,
          "author_name": "Martin",
          "author_url": "",
          "post_date": "2019-01-29T16:15:56.033000",
          "content": "<p>I would try power of 4 or power of 6. It should be even number. </p>",
          "votes": 1,
          "replies": []
        }
      ]
    },
    {
      "id": 460877,
      "author_name": "Costa.Medvedev",
      "author_url": "",
      "post_date": "2019-01-24T15:32:14.463000",
      "content": "<p>I did a split onto two models\n1. LGB model Trained with a binary goal (outlier or not).\n2. LGB Is trained on the dataset without outliers (target&lt;=-33) with all parameters set to the same values.\nResults are joined with. If the model 1 says it should be an outlier, then the predicted score set to -33. Otherwise the score is taken from model 2.\nBut it gave me very bad final score.\nMay be I had to optimize the first model better. Now it predicts correctly only 2-3 outliers out of hundreds we have.</p>",
      "votes": 0,
      "replies": [
        {
          "id": 461012,
          "author_name": "Zhuang Jia",
          "author_url": "",
          "post_date": "2019-01-25T01:29:11.047000",
          "content": "<p>yes, outlier classification is highly imbalanced. It's hard to predict them accurately. But It's still a good try.</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 461141,
          "author_name": "Salamat",
          "author_url": "",
          "post_date": "2019-01-25T10:44:55.973000",
          "content": "<p>@Costa.Medvedev\nUse three model instead. Model with outliers , model without outliers, and model for outliers prediction. Check this kernel :<a href=\"https://www.kaggle.com/waitingli/combining-your-model-with-a-model-without-outlier\">https://www.kaggle.com/waitingli/combining-your-model-with-a-model-without-outlier</a></p>",
          "votes": 2,
          "replies": []
        },
        {
          "id": 461537,
          "author_name": "HyperSeedOptimized",
          "author_url": "",
          "post_date": "2019-01-26T09:38:57.687000",
          "content": "<p><a href=\"/salamatburj\">@salamatburj</a> I tried that, but cannot understand why it works. It is using a more general model for the (predicted) outliers than for the non-outliers, meaning that the general model is overly affected by the outlier values for predicting most of the (non-outlying) data. But why would a gbm behave this way? Thanks.</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 461866,
          "author_name": "Salamat",
          "author_url": "",
          "post_date": "2019-01-27T07:43:45",
          "content": "<p>@GideonTeo Yes, outliers are affecting rmse error a lot. I think the key is the outliers prediction. You might have different features which are more important to outliers and less for regression. Outliers prediction provides extra insight to the data. </p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 463296,
          "author_name": "Costa.Medvedev",
          "author_url": "",
          "post_date": "2019-01-29T18:56:33.733000",
          "content": "<p><a href=\"/salamatburj\">@salamatburj</a>   3 is a good number )))\nI will try.</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 461407,
      "author_name": "",
      "author_url": "",
      "post_date": "2019-01-25T23:37:08.283000",
      "content": "",
      "votes": 0,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "460680": "Do we have some strategies to handle outliers when doing regression, if the outliers is important to us?",
    "460843": "1. If you want to fit more closely to outliers: Change the metric you use for minimizing the sum of the residuals. That is, instead of minimizing the sum of the squared residuals, maybe minimize for the sum of the residuals to the power of 5. \n\n2. If you want to fit less closely to outliers: Remove the outliers from your sample, or change the the optimization from minimizing the sum of the squared residuals, to minimizing the sum of the L1 residuals maybe. Or minimizing the sum of the Square Root Residuals\n\nI think you can also set weights for each point if these don't work. So, you can specify all non-outlier points have a weight of 1, but the outlier points have a weight of 10.",
    "460768": "You can try measuring how much of your regression model is being influenced by that outlier. I wouldn't recommend just erasing it (some people do that)",
    "462323": "Hi,\n    Did you get this solved? I tried power of 5, but the LGB never improved since the first round. Could you share your solution? Thank you!",
    "460877": "I did a split onto two models\n1. LGB model Trained with a binary goal (outlier or not).\n2. LGB Is trained on the dataset without outliers (target&lt;=-33) with all parameters set to the same values.\nResults are joined with. If the model 1 says it should be an outlier, then the predicted score set to -33. Otherwise the score is taken from model 2.\nBut it gave me very bad final score.\nMay be I had to optimize the first model better. Now it predicts correctly only 2-3 outliers out of hundreds we have.",
    "461407": ""
  }
}