{
  "id": 17454,
  "title": "FAQ Thread",
  "url": "/competitions/face-verification2/discussion/17454",
  "author_name": "",
  "post_date": "2015-11-17T16:05:39.207Z",
  "votes": null,
  "comment_count": 1,
  "views": 530,
  "content": "<p>There have been a few questions about the competition. I try to answer them all in this thread so that everyone is at the same level.</p>\n\n<p>Q: How can I use the training data in practice?</p>\n\n<p>A: You need to generate pairs of matching and non-matching images. The absolute differences of the feature vectors can be the input for the classifier.</p>\n\n<p>Q: If I sample training data at random, I get hugely unbalanced data (less than 1% matches and over 99% non-matches). Is this a problem?</p>\n\n<p>A: This will most likely result in a dummy classifier that always predicts a non-match (and be 99% accurate). Solutions to this is to develop some procedure for sampling about 50% of both. Alternatively, your classifier may support class-specific weights. Then you can set the match-class weights 100 times larger, for example.</p>\n\n<p>Q: I train an SVM but the result is worse than the sample solution.</p>\n\n<p>A: Your classifier probably overfits to the training set. Either try to generate more data (see previous question, though), or regularize your solution. For example, <a href=\"http://se.mathworks.com/help/stats/fitcsvm.html#namevaluepairarguments\">Matlab's</a> fitcsvm function has the parameter BoxConstraint, which should improve generalization and thus the accuracy as well. For Python's <a href=\"http://scikit-learn.org/stable/modules/svm.html\">sklearn</a> package, the corresponding regularizer is called C. Also <a href=\"https://www.csie.ntu.edu.tw/~cjlin/libsvm/\">LibSVM</a> has the parameter -c for regularization.</p>",
  "messages": [
    {
      "id": "98979",
      "postDate": "11/17/2015 16:05:39",
      "content": "<p>There have been a few questions about the competition. I try to answer them all in this thread so that everyone is at the same level.</p>\n\n<p>Q: How can I use the training data in practice?</p>\n\n<p>A: You need to generate pairs of matching and non-matching images. The absolute differences of the feature vectors can be the input for the classifier.</p>\n\n<p>Q: If I sample training data at random, I get hugely unbalanced data (less than 1% matches and over 99% non-matches). Is this a problem?</p>\n\n<p>A: This will most likely result in a dummy classifier that always predicts a non-match (and be 99% accurate). Solutions to this is to develop some procedure for sampling about 50% of both. Alternatively, your classifier may support class-specific weights. Then you can set the match-class weights 100 times larger, for example.</p>\n\n<p>Q: I train an SVM but the result is worse than the sample solution.</p>\n\n<p>A: Your classifier probably overfits to the training set. Either try to generate more data (see previous question, though), or regularize your solution. For example, <a href=\"http://se.mathworks.com/help/stats/fitcsvm.html#namevaluepairarguments\">Matlab's</a> fitcsvm function has the parameter BoxConstraint, which should improve generalization and thus the accuracy as well. For Python's <a href=\"http://scikit-learn.org/stable/modules/svm.html\">sklearn</a> package, the corresponding regularizer is called C. Also <a href=\"https://www.csie.ntu.edu.tw/~cjlin/libsvm/\">LibSVM</a> has the parameter -c for regularization.</p>",
      "rawMarkdown": "There have been a few questions about the competition. I try to answer them all in this thread so that everyone is at the same level.\r\n\r\nQ: How can I use the training data in practice?\r\n\r\nA: You need to generate pairs of matching and non-matching images. The absolute differences of the feature vectors can be the input for the classifier.\r\n\r\nQ: If I sample training data at random, I get hugely unbalanced data (less than 1% matches and over 99% non-matches). Is this a problem?\r\n\r\nA: This will most likely result in a dummy classifier that always predicts a non-match (and be 99% accurate). Solutions to this is to develop some procedure for sampling about 50% of both. Alternatively, your classifier may support class-specific weights. Then you can set the match-class weights 100 times larger, for example.\r\n\r\nQ: I train an SVM but the result is worse than the sample solution.\r\n\r\nA: Your classifier probably overfits to the training set. Either try to generate more data (see previous question, though), or regularize your solution. For example, [Matlab's][1] fitcsvm function has the parameter BoxConstraint, which should improve generalization and thus the accuracy as well. For Python's [sklearn][2] package, the corresponding regularizer is called C. Also [LibSVM][3] has the parameter -c for regularization.\r\n\r\n\r\n  [1]: http://se.mathworks.com/help/stats/fitcsvm.html#namevaluepairarguments\r\n  [2]: http://scikit-learn.org/stable/modules/svm.html\r\n  [3]: https://www.csie.ntu.edu.tw/~cjlin/libsvm/",
      "votes": null
    },
    {
      "id": "99023",
      "postDate": "11/18/2015 11:56:45",
      "content": "<p>More Q&amp;A:</p>\n\n<p>Q: SVM gives me only -1 and 1, not probabilities?</p>\n\n<p>A: In Matlab, you can get probability estimates with <a href=\"http://se.mathworks.com/help/stats/classificationsvm.fitposterior.html\">fitPosterior</a>. With LibSVM, use the -b switch (documented at <a href=\"https://www.csie.ntu.edu.tw/~cjlin/libsvm/\">LibSVM website</a>). In sklearn, initialize with <code>probability</code> switch: <code>clf = SVC(probability = True)</code>. Alternatively, you can look into Logistic Regression classifier, which returns probabilities by default. Implementations include <a href=\"http://se.mathworks.com/help/stats/lassoglm.html\">lassoglm</a>, <a href=\"https://www.csie.ntu.edu.tw/~cjlin/liblinear/\">liblinear</a> or <a href=\"http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html\">sklearn</a>.</p>\n\n<p>Q: Which values to use for the regularization parameter (BoxConstraint or C)?</p>\n\n<p>A: Use a geometric range, such as <code>10 .^ (-5 : 5)</code> instead of e.g., <code>0.1 : 0.001 : 1</code>.</p>\n\n<p>Q: How do I compare different C values?</p>\n\n<p>A: Split your training data to training and testing, and check how well different versions work with the test part when trained with the train part. More advanced approaches involve cross validation. See e.g., <a href=\"http://se.mathworks.com/help/stats/support-vector-machines-svm.html#bsr5o1q\">Matlab example</a> and <a href=\"http://scikit-learn.org/stable/modules/cross_validation.html\">Python example</a>.</p>\n\n<p>Q: Python seems so much nicer than Matlab :) How to get hold of it?</p>\n\n<p>A: <a href=\"https://www.continuum.io/\">Anaconda distribution</a> is probably the easiest starting point and includes sklearn package by default. At TUT, everything is readily installed at classroom TC407. Just go there and run <code>python deepfeatures_distance_prediction.py</code> of the other thread after setting up all data. My <a href=\"http://www.cs.tut.fi/~hehu/MMLP.pdf\">slides</a> from last summer may help you to get started.</p>",
      "rawMarkdown": "More Q&A:\r\n\r\nQ: SVM gives me only -1 and 1, not probabilities?\r\n\r\nA: In Matlab, you can get probability estimates with [fitPosterior][1]. With LibSVM, use the -b switch (documented at [LibSVM website][2]). In sklearn, initialize with `probability` switch: `clf = SVC(probability = True)`. Alternatively, you can look into Logistic Regression classifier, which returns probabilities by default. Implementations include [lassoglm][3], [liblinear][4] or [sklearn][5].\r\n\r\nQ: Which values to use for the regularization parameter (BoxConstraint or C)?\r\n\r\nA: Use a geometric range, such as `10 .^ (-5 : 5)` instead of e.g., `0.1 : 0.001 : 1`.\r\n\r\nQ: How do I compare different C values?\r\n\r\nA: Split your training data to training and testing, and check how well different versions work with the test part when trained with the train part. More advanced approaches involve cross validation. See e.g., [Matlab example][6] and [Python example][7].\r\n\r\nQ: Python seems so much nicer than Matlab :) How to get hold of it?\r\n\r\nA: [Anaconda distribution][8] is probably the easiest starting point and includes sklearn package by default. At TUT, everything is readily installed at classroom TC407. Just go there and run `python deepfeatures_distance_prediction.py` of the other thread after setting up all data. My [slides][9] from last summer may help you to get started.\r\n\r\n\r\n  [1]: http://se.mathworks.com/help/stats/classificationsvm.fitposterior.html\r\n  [2]: https://www.csie.ntu.edu.tw/~cjlin/libsvm/\r\n  [3]: http://se.mathworks.com/help/stats/lassoglm.html\r\n  [4]: https://www.csie.ntu.edu.tw/~cjlin/liblinear/\r\n  [5]: http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html\r\n  [6]: http://se.mathworks.com/help/stats/support-vector-machines-svm.html#bsr5o1q\r\n  [7]: http://scikit-learn.org/stable/modules/cross_validation.html\r\n  [8]: https://www.continuum.io/\r\n  [9]: http://www.cs.tut.fi/~hehu/MMLP.pdf",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 99023,
      "author_name": "mahehu",
      "author_url": "",
      "post_date": "11/18/2015 11:56:45",
      "content": "<p>More Q&amp;A:</p>\n\n<p>Q: SVM gives me only -1 and 1, not probabilities?</p>\n\n<p>A: In Matlab, you can get probability estimates with <a href=\"http://se.mathworks.com/help/stats/classificationsvm.fitposterior.html\">fitPosterior</a>. With LibSVM, use the -b switch (documented at <a href=\"https://www.csie.ntu.edu.tw/~cjlin/libsvm/\">LibSVM website</a>). In sklearn, initialize with <code>probability</code> switch: <code>clf = SVC(probability = True)</code>. Alternatively, you can look into Logistic Regression classifier, which returns probabilities by default. Implementations include <a href=\"http://se.mathworks.com/help/stats/lassoglm.html\">lassoglm</a>, <a href=\"https://www.csie.ntu.edu.tw/~cjlin/liblinear/\">liblinear</a> or <a href=\"http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html\">sklearn</a>.</p>\n\n<p>Q: Which values to use for the regularization parameter (BoxConstraint or C)?</p>\n\n<p>A: Use a geometric range, such as <code>10 .^ (-5 : 5)</code> instead of e.g., <code>0.1 : 0.001 : 1</code>.</p>\n\n<p>Q: How do I compare different C values?</p>\n\n<p>A: Split your training data to training and testing, and check how well different versions work with the test part when trained with the train part. More advanced approaches involve cross validation. See e.g., <a href=\"http://se.mathworks.com/help/stats/support-vector-machines-svm.html#bsr5o1q\">Matlab example</a> and <a href=\"http://scikit-learn.org/stable/modules/cross_validation.html\">Python example</a>.</p>\n\n<p>Q: Python seems so much nicer than Matlab :) How to get hold of it?</p>\n\n<p>A: <a href=\"https://www.continuum.io/\">Anaconda distribution</a> is probably the easiest starting point and includes sklearn package by default. At TUT, everything is readily installed at classroom TC407. Just go there and run <code>python deepfeatures_distance_prediction.py</code> of the other thread after setting up all data. My <a href=\"http://www.cs.tut.fi/~hehu/MMLP.pdf\">slides</a> from last summer may help you to get started.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "98979": "There have been a few questions about the competition. I try to answer them all in this thread so that everyone is at the same level.\r\n\r\nQ: How can I use the training data in practice?\r\n\r\nA: You need to generate pairs of matching and non-matching images. The absolute differences of the feature vectors can be the input for the classifier.\r\n\r\nQ: If I sample training data at random, I get hugely unbalanced data (less than 1% matches and over 99% non-matches). Is this a problem?\r\n\r\nA: This will most likely result in a dummy classifier that always predicts a non-match (and be 99% accurate). Solutions to this is to develop some procedure for sampling about 50% of both. Alternatively, your classifier may support class-specific weights. Then you can set the match-class weights 100 times larger, for example.\r\n\r\nQ: I train an SVM but the result is worse than the sample solution.\r\n\r\nA: Your classifier probably overfits to the training set. Either try to generate more data (see previous question, though), or regularize your solution. For example, [Matlab's][1] fitcsvm function has the parameter BoxConstraint, which should improve generalization and thus the accuracy as well. For Python's [sklearn][2] package, the corresponding regularizer is called C. Also [LibSVM][3] has the parameter -c for regularization.\r\n\r\n\r\n  [1]: http://se.mathworks.com/help/stats/fitcsvm.html#namevaluepairarguments\r\n  [2]: http://scikit-learn.org/stable/modules/svm.html\r\n  [3]: https://www.csie.ntu.edu.tw/~cjlin/libsvm/",
    "99023": "More Q&A:\r\n\r\nQ: SVM gives me only -1 and 1, not probabilities?\r\n\r\nA: In Matlab, you can get probability estimates with [fitPosterior][1]. With LibSVM, use the -b switch (documented at [LibSVM website][2]). In sklearn, initialize with `probability` switch: `clf = SVC(probability = True)`. Alternatively, you can look into Logistic Regression classifier, which returns probabilities by default. Implementations include [lassoglm][3], [liblinear][4] or [sklearn][5].\r\n\r\nQ: Which values to use for the regularization parameter (BoxConstraint or C)?\r\n\r\nA: Use a geometric range, such as `10 .^ (-5 : 5)` instead of e.g., `0.1 : 0.001 : 1`.\r\n\r\nQ: How do I compare different C values?\r\n\r\nA: Split your training data to training and testing, and check how well different versions work with the test part when trained with the train part. More advanced approaches involve cross validation. See e.g., [Matlab example][6] and [Python example][7].\r\n\r\nQ: Python seems so much nicer than Matlab :) How to get hold of it?\r\n\r\nA: [Anaconda distribution][8] is probably the easiest starting point and includes sklearn package by default. At TUT, everything is readily installed at classroom TC407. Just go there and run `python deepfeatures_distance_prediction.py` of the other thread after setting up all data. My [slides][9] from last summer may help you to get started.\r\n\r\n\r\n  [1]: http://se.mathworks.com/help/stats/classificationsvm.fitposterior.html\r\n  [2]: https://www.csie.ntu.edu.tw/~cjlin/libsvm/\r\n  [3]: http://se.mathworks.com/help/stats/lassoglm.html\r\n  [4]: https://www.csie.ntu.edu.tw/~cjlin/liblinear/\r\n  [5]: http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html\r\n  [6]: http://se.mathworks.com/help/stats/support-vector-machines-svm.html#bsr5o1q\r\n  [7]: http://scikit-learn.org/stable/modules/cross_validation.html\r\n  [8]: https://www.continuum.io/\r\n  [9]: http://www.cs.tut.fi/~hehu/MMLP.pdf"
  },
  "source": "meta"
}