{
  "id": 8188,
  "title": "Problem with features with SVM and Linear Regression",
  "url": "/competitions/acquire-valued-shoppers-challenge/discussion/8188",
  "author_name": "",
  "post_date": "2014-05-17T11:16:38.063Z",
  "votes": null,
  "comment_count": 7,
  "views": 2890,
  "content": "<p>I have been trying to use some features similar to those described by Triskelion<a href=\"http://www.kaggle.com/c/acquire-valued-shoppers-challenge/forums/t/7688/feature-engineering-and-beat-the-benchmark-0-59347\"> here</a> but nothing works.</p>\n<p>I have tried using SVM and Logistic Regression (edit: not Linear Regression as I put on the title) from SciKit but the result is really poor.</p>\n<p>My features have a lot of zeros since the customer might have purchased something e.g. in the category of the offer but not in the brand or company etc.</p>\n<p>Do you think that this might be causing the problem? Does anyone else use SVM or Linear Regression for the problem?</p>",
  "messages": [
    {
      "id": "44717",
      "postDate": "05/17/2014 11:16:38",
      "content": "<p>I have been trying to use some features similar to those described by Triskelion<a href=\"http://www.kaggle.com/c/acquire-valued-shoppers-challenge/forums/t/7688/feature-engineering-and-beat-the-benchmark-0-59347\"> here</a> but nothing works.</p>\n<p>I have tried using SVM and Logistic Regression (edit: not Linear Regression as I put on the title) from SciKit but the result is really poor.</p>\n<p>My features have a lot of zeros since the customer might have purchased something e.g. in the category of the offer but not in the brand or company etc.</p>\n<p>Do you think that this might be causing the problem? Does anyone else use SVM or Linear Regression for the problem?</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "44749",
      "postDate": "05/17/2014 18:28:02",
      "content": "<p>Too high dimensional data can be a problem with certain algo's. You can try <a href=\"http://scikit-learn.org/stable/modules/decomposition.html\">Decomposition</a>&nbsp;to lower dimensionality.&nbsp;</p>\n<p>Logistic Regression benefits from a little regularization (tweak <em>C</em> and <em>intercept_scaling</em>).</p>\n<p>For SVM, note that:</p>\n<p><em>Support Vector Machine algorithms are not scale invariant, so it is highly recommended to scale your data. For example, scale each attribute on the input vector X to [0,1] or [-1,+1], or standardize it to have mean 0 and variance 1. Note that the same scaling must be applied to the test vector to obtain meaningful results. See section Preprocessing data for more details on scaling and normalization. (<a href=\"http://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.MinMaxScaler.html\">preprocessing.MinMaxScaler</a>)</em></p>\n<p>For both algo's, run it a few time with <a href=\"http://scikit-learn.org/stable/modules/generated/sklearn.cross_validation.cross_val_score.html\">cross_val_score</a>&nbsp;scoring=roc_auc so you know which parameters attribute to a higher score. Good luck!</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "44797",
      "postDate": "05/18/2014 23:32:45",
      "content": "<p>Thank you for your reply!</p>\n<p>I found out a mistake in my code that fixed the problem.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "44799",
      "postDate": "05/18/2014 23:53:48",
      "content": "<p>@Konstantina</p>\n<p>how long is SVM taking to train? I wanted to give it a try, but optimizing the hyper-parameters with grid search seemed a bit prohibitive.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "44857",
      "postDate": "05/20/2014 00:08:33",
      "content": "<p>With the size of data that you have maybe SVM run so slow because need so much time for split the information.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "44870",
      "postDate": "05/20/2014 00:40:55",
      "content": "<p>@ fernando nogueira</p>\n<p>The LinearSVC of scikit learn runs quite fast (&lt; 1 minute) but if you want to use another kernel it takes long. I actually did not have the patience to wait for the output.</p>\n<p>For the moment my best score is found with Vowpal Wabbit.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "45987",
      "postDate": "05/21/2014 13:19:42",
      "content": "<p><em><strong>My features have a lot of zeros since the customer might have purchased something e.g. in the category of the offer but not in the brand or company etc.</strong></em></p>\n<p>As you mentioned you have lots of zeros in the features does it mean you have created variables like trxn_count_C1,&nbsp;trxn_count_C2,trxn_count_C3,trxn_count_C4 so on...</p>\n<p>eg. trxn_count_C1 = total transactions of the customer with company 1 in 1 year</p>\n<p>Similarly you have created variables for Brand and category? i.e lets say if there are 100 companies in the data you will create 100 such variables for transaction counts.</p>\n<p>Your reply will be really helpful for me. Thanks!</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "46153",
      "postDate": "05/23/2014 23:22:24",
      "content": "<p>@Decipher,</p>\n<p>I did not create features for each company but for the company of the offer received by the client.</p>\n<p>For each client you find out what is the offer that he got in the offers file. Then you compute features for the specific company, brand and category of the offer NOT for every company, brand and category because you cannot relate them to the offer.</p>\n<p>I hope this clarifies things..</p>",
      "rawMarkdown": "",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 44749,
      "author_name": "triskelion",
      "author_url": "",
      "post_date": "05/17/2014 18:28:02",
      "content": "<p>Too high dimensional data can be a problem with certain algo's. You can try <a href=\"http://scikit-learn.org/stable/modules/decomposition.html\">Decomposition</a>&nbsp;to lower dimensionality.&nbsp;</p>\n<p>Logistic Regression benefits from a little regularization (tweak <em>C</em> and <em>intercept_scaling</em>).</p>\n<p>For SVM, note that:</p>\n<p><em>Support Vector Machine algorithms are not scale invariant, so it is highly recommended to scale your data. For example, scale each attribute on the input vector X to [0,1] or [-1,+1], or standardize it to have mean 0 and variance 1. Note that the same scaling must be applied to the test vector to obtain meaningful results. See section Preprocessing data for more details on scaling and normalization. (<a href=\"http://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.MinMaxScaler.html\">preprocessing.MinMaxScaler</a>)</em></p>\n<p>For both algo's, run it a few time with <a href=\"http://scikit-learn.org/stable/modules/generated/sklearn.cross_validation.cross_val_score.html\">cross_val_score</a>&nbsp;scoring=roc_auc so you know which parameters attribute to a higher score. Good luck!</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 44797,
      "author_name": "kontoudi",
      "author_url": "",
      "post_date": "05/18/2014 23:32:45",
      "content": "<p>Thank you for your reply!</p>\n<p>I found out a mistake in my code that fixed the problem.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 44799,
      "author_name": "fnogueira",
      "author_url": "",
      "post_date": "05/18/2014 23:53:48",
      "content": "<p>@Konstantina</p>\n<p>how long is SVM taking to train? I wanted to give it a try, but optimizing the hyper-parameters with grid search seemed a bit prohibitive.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 44857,
      "author_name": "pablolecce",
      "author_url": "",
      "post_date": "05/20/2014 00:08:33",
      "content": "<p>With the size of data that you have maybe SVM run so slow because need so much time for split the information.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 44870,
      "author_name": "kontoudi",
      "author_url": "",
      "post_date": "05/20/2014 00:40:55",
      "content": "<p>@ fernando nogueira</p>\n<p>The LinearSVC of scikit learn runs quite fast (&lt; 1 minute) but if you want to use another kernel it takes long. I actually did not have the patience to wait for the output.</p>\n<p>For the moment my best score is found with Vowpal Wabbit.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 45987,
      "author_name": "decipher",
      "author_url": "",
      "post_date": "05/21/2014 13:19:42",
      "content": "<p><em><strong>My features have a lot of zeros since the customer might have purchased something e.g. in the category of the offer but not in the brand or company etc.</strong></em></p>\n<p>As you mentioned you have lots of zeros in the features does it mean you have created variables like trxn_count_C1,&nbsp;trxn_count_C2,trxn_count_C3,trxn_count_C4 so on...</p>\n<p>eg. trxn_count_C1 = total transactions of the customer with company 1 in 1 year</p>\n<p>Similarly you have created variables for Brand and category? i.e lets say if there are 100 companies in the data you will create 100 such variables for transaction counts.</p>\n<p>Your reply will be really helpful for me. Thanks!</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 46153,
      "author_name": "kontoudi",
      "author_url": "",
      "post_date": "05/23/2014 23:22:24",
      "content": "<p>@Decipher,</p>\n<p>I did not create features for each company but for the company of the offer received by the client.</p>\n<p>For each client you find out what is the offer that he got in the offers file. Then you compute features for the specific company, brand and category of the offer NOT for every company, brand and category because you cannot relate them to the offer.</p>\n<p>I hope this clarifies things..</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "44717": "",
    "44749": "",
    "44797": "",
    "44799": "",
    "44857": "",
    "44870": "",
    "45987": "",
    "46153": ""
  },
  "source": "meta"
}