{
  "id": 21010,
  "title": "Applying PCA",
  "url": "/competitions/state-farm-distracted-driver-detection/discussion/21010",
  "author_name": "vivek yadav",
  "post_date": "2016-05-17T03:47:02.707000",
  "votes": 0,
  "comment_count": 0,
  "views": 321,
  "content": "<p>Hello, </p>\n\n<p>Here are the steps I followed, \n1- Changed image to grayscale and resized to 84 X 112\n2- Applied PCA to extract 100 best features on training set (I split given data set into train and test set).\n3- Projected training data on components calculated using PCA\n4- Fitted an SVC model and made predictions\n5- I get precision and recall below, and confusion matrix below too. </p>\n\n<p>The results seem ok. However, I got log loss of 1.75. Also, to improve more I applied PCA on data and reconverted data to image space using inverse tranform. I got image of lines instead of actual image. Any idea why this may be happening? In the attached image, top - left is the actual image, top - right is the grayscale image, bottom  are the image approximations with PCA. Any idea why this may be happening? Am i making a mistake or this is common? </p>\n\n<p>precision    recall  f1-score   support</p>\n\n<pre><code>     c0       0.98      0.99      0.99       997\n     c1       0.99      1.00      0.99       906\n     c2       1.00      0.99      1.00       923\n     c3       1.00      1.00      1.00       939\n     c4       1.00      0.99      0.99       933\n     c5       1.00      0.99      1.00       922\n     c6       0.99      1.00      0.99       930\n     c7       1.00      1.00      1.00       802\n     c8       0.98      0.97      0.98       765\n     c9       0.99      0.98      0.99       849\n</code></pre>\n\n<p>avg / total       0.99      0.99      0.99      8966</p>\n\n<p>[[989   2   0   2   0   1   0   0   3   0]</p>\n\n<p>[  0 902   2   0   0   0   0   0   0   2]</p>\n\n<p>[  0   1 918   0   0   0   0   1   3   0]</p>\n\n<p>[  0   0   1 936   2   0   0   0   0   0]</p>\n\n<p>[  4   0   0   1 923   0   4   0   1   0]</p>\n\n<p>[  2   0   0   1   0 917   1   0   0   1]</p>\n\n<p>[  0   1   0   0   1   0 928   0   0   0]</p>\n\n<p>[  0   0   1   0   1   0   2 798   0   0]</p>\n\n<p>[  8   3   0   0   0   0   3   2 743   6]</p>\n\n<p>[  2   1   0   0   0   0   1   1   8 836]]</p>",
  "messages": [
    {
      "id": 120287,
      "postDate": "2016-05-17T03:47:02.707Z",
      "content": "<p>Hello, </p>\n\n<p>Here are the steps I followed, \n1- Changed image to grayscale and resized to 84 X 112\n2- Applied PCA to extract 100 best features on training set (I split given data set into train and test set).\n3- Projected training data on components calculated using PCA\n4- Fitted an SVC model and made predictions\n5- I get precision and recall below, and confusion matrix below too. </p>\n\n<p>The results seem ok. However, I got log loss of 1.75. Also, to improve more I applied PCA on data and reconverted data to image space using inverse tranform. I got image of lines instead of actual image. Any idea why this may be happening? In the attached image, top - left is the actual image, top - right is the grayscale image, bottom  are the image approximations with PCA. Any idea why this may be happening? Am i making a mistake or this is common? </p>\n\n<p>precision    recall  f1-score   support</p>\n\n<pre><code>     c0       0.98      0.99      0.99       997\n     c1       0.99      1.00      0.99       906\n     c2       1.00      0.99      1.00       923\n     c3       1.00      1.00      1.00       939\n     c4       1.00      0.99      0.99       933\n     c5       1.00      0.99      1.00       922\n     c6       0.99      1.00      0.99       930\n     c7       1.00      1.00      1.00       802\n     c8       0.98      0.97      0.98       765\n     c9       0.99      0.98      0.99       849\n</code></pre>\n\n<p>avg / total       0.99      0.99      0.99      8966</p>\n\n<p>[[989   2   0   2   0   1   0   0   3   0]</p>\n\n<p>[  0 902   2   0   0   0   0   0   0   2]</p>\n\n<p>[  0   1 918   0   0   0   0   1   3   0]</p>\n\n<p>[  0   0   1 936   2   0   0   0   0   0]</p>\n\n<p>[  4   0   0   1 923   0   4   0   1   0]</p>\n\n<p>[  2   0   0   1   0 917   1   0   0   1]</p>\n\n<p>[  0   1   0   0   1   0 928   0   0   0]</p>\n\n<p>[  0   0   1   0   1   0   2 798   0   0]</p>\n\n<p>[  8   3   0   0   0   0   3   2 743   6]</p>\n\n<p>[  2   1   0   0   0   0   1   1   8 836]]</p>",
      "rawMarkdown": "Hello, \r\n\r\nHere are the steps I followed, \r\n1- Changed image to grayscale and resized to 84 X 112\r\n2- Applied PCA to extract 100 best features on training set (I split given data set into train and test set).\r\n3- Projected training data on components calculated using PCA\r\n4- Fitted an SVC model and made predictions\r\n5- I get precision and recall below, and confusion matrix below too. \r\n\r\nThe results seem ok. However, I got log loss of 1.75. Also, to improve more I applied PCA on data and reconverted data to image space using inverse tranform. I got image of lines instead of actual image. Any idea why this may be happening? In the attached image, top - left is the actual image, top - right is the grayscale image, bottom  are the image approximations with PCA. Any idea why this may be happening? Am i making a mistake or this is common? \r\n\r\n\r\n\r\nprecision    recall  f1-score   support\r\n\r\n         c0       0.98      0.99      0.99       997\r\n         c1       0.99      1.00      0.99       906\r\n         c2       1.00      0.99      1.00       923\r\n         c3       1.00      1.00      1.00       939\r\n         c4       1.00      0.99      0.99       933\r\n         c5       1.00      0.99      1.00       922\r\n         c6       0.99      1.00      0.99       930\r\n         c7       1.00      1.00      1.00       802\r\n         c8       0.98      0.97      0.98       765\r\n         c9       0.99      0.98      0.99       849\r\n\r\navg / total       0.99      0.99      0.99      8966\r\n\r\n[[989   2   0   2   0   1   0   0   3   0]\r\n\r\n [  0 902   2   0   0   0   0   0   0   2]\r\n\r\n [  0   1 918   0   0   0   0   1   3   0]\r\n\r\n [  0   0   1 936   2   0   0   0   0   0]\r\n\r\n [  4   0   0   1 923   0   4   0   1   0]\r\n\r\n [  2   0   0   1   0 917   1   0   0   1]\r\n\r\n [  0   1   0   0   1   0 928   0   0   0]\r\n\r\n [  0   0   1   0   1   0   2 798   0   0]\r\n\r\n [  8   3   0   0   0   0   3   2 743   6]\r\n\r\n [  2   1   0   0   0   0   1   1   8 836]]"
    }
  ],
  "comments": [],
  "raw_markdown_by_id": {
    "120287": "Hello, \r\n\r\nHere are the steps I followed, \r\n1- Changed image to grayscale and resized to 84 X 112\r\n2- Applied PCA to extract 100 best features on training set (I split given data set into train and test set).\r\n3- Projected training data on components calculated using PCA\r\n4- Fitted an SVC model and made predictions\r\n5- I get precision and recall below, and confusion matrix below too. \r\n\r\nThe results seem ok. However, I got log loss of 1.75. Also, to improve more I applied PCA on data and reconverted data to image space using inverse tranform. I got image of lines instead of actual image. Any idea why this may be happening? In the attached image, top - left is the actual image, top - right is the grayscale image, bottom  are the image approximations with PCA. Any idea why this may be happening? Am i making a mistake or this is common? \r\n\r\n\r\n\r\nprecision    recall  f1-score   support\r\n\r\n         c0       0.98      0.99      0.99       997\r\n         c1       0.99      1.00      0.99       906\r\n         c2       1.00      0.99      1.00       923\r\n         c3       1.00      1.00      1.00       939\r\n         c4       1.00      0.99      0.99       933\r\n         c5       1.00      0.99      1.00       922\r\n         c6       0.99      1.00      0.99       930\r\n         c7       1.00      1.00      1.00       802\r\n         c8       0.98      0.97      0.98       765\r\n         c9       0.99      0.98      0.99       849\r\n\r\navg / total       0.99      0.99      0.99      8966\r\n\r\n[[989   2   0   2   0   1   0   0   3   0]\r\n\r\n [  0 902   2   0   0   0   0   0   0   2]\r\n\r\n [  0   1 918   0   0   0   0   1   3   0]\r\n\r\n [  0   0   1 936   2   0   0   0   0   0]\r\n\r\n [  4   0   0   1 923   0   4   0   1   0]\r\n\r\n [  2   0   0   1   0 917   1   0   0   1]\r\n\r\n [  0   1   0   0   1   0 928   0   0   0]\r\n\r\n [  0   0   1   0   1   0   2 798   0   0]\r\n\r\n [  8   3   0   0   0   0   3   2 743   6]\r\n\r\n [  2   1   0   0   0   0   1   1   8 836]]"
  }
}