{
  "id": 6803,
  "title": "Beating the Benchmark",
  "url": "/competitions/galaxy-zoo-the-galaxy-challenge/discussion/6803",
  "author_name": "",
  "post_date": "2014-01-10T15:45:26.303Z",
  "votes": 15,
  "comment_count": 29,
  "views": 12583,
  "content": "<p>Since, I've been ridiculed previously for the beating the benchmark posts, this time I wont post the code, but a method which would enable you to beat the central pixel benchmark and would take only 20mins.</p>\n<p>&nbsp;</p>\n<p>Step 1 : for all images in train and test, resize to 50x50, and vectorize to 1-D array.</p>\n<p>Step 2: Run the RandomForestRegression from scikit-learn on the train and test set with 10 estimators.</p>\n<p>Step 3: Submit Results</p>\n<p>Step 4: You have beaten the benchmark</p>\n<p>Step 5: Click thanks if this post helped you ;)</p>",
  "messages": [
    {
      "id": "37233",
      "postDate": "01/10/2014 15:45:26",
      "content": "<p>Since, I've been ridiculed previously for the beating the benchmark posts, this time I wont post the code, but a method which would enable you to beat the central pixel benchmark and would take only 20mins.</p>\n<p>&nbsp;</p>\n<p>Step 1 : for all images in train and test, resize to 50x50, and vectorize to 1-D array.</p>\n<p>Step 2: Run the RandomForestRegression from scikit-learn on the train and test set with 10 estimators.</p>\n<p>Step 3: Submit Results</p>\n<p>Step 4: You have beaten the benchmark</p>\n<p>Step 5: Click thanks if this post helped you ;)</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "37245",
      "postDate": "01/10/2014 18:35:54",
      "content": "<p>[quote=Abhishek;37233]</p>\n<p>Since, I've been ridiculed previously for the beating the benchmark posts,&nbsp;</p>\n<p>[/quote]</p>\n<p>LOL.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "37258",
      "postDate": "01/10/2014 21:28:08",
      "content": "<p>aint that true :P&nbsp;</p>\n<p>[quote=Giulio;37245]</p>\n<p>[quote=Abhishek;37233]</p>\n<p>Since, I've been ridiculed previously for the beating the benchmark posts,&nbsp;</p>\n<p>[/quote]</p>\n<p>LOL.</p>\n<p>[/quote]</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "37259",
      "postDate": "01/10/2014 21:35:20",
      "content": "<p>[quote=Abhishek;37258]</p>\n<p>aint that true :P&nbsp;</p>\n<p>[quote=Giulio;37245]</p>\n<p>[quote=Abhishek;37233]</p>\n<p>Since, I've been ridiculed previously for the beating the benchmark posts,&nbsp;</p>\n<p>[/quote]</p>\n<p>LOL.</p>\n<p>[/quote]</p>\n<p>[/quote]</p>\n<p>C'mon! You ended up with more fans than haters :-)</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "37269",
      "postDate": "01/11/2014 04:28:06",
      "content": "<p>I've never done image processing before. Would it be possible to post a sample code on how to resize and vectorize it to 1-D array?&nbsp;</p>\n<p>&nbsp;</p>\n<p>Thanks.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "37275",
      "postDate": "01/11/2014 09:36:20",
      "content": "<p><code>import numpy as np<br>import pandas as pd</code><code><code>import cv2</code></code></p>\n<p><code>images = []<br> image_files = sorted(os.listdir('images_training'))<br>image_files = [&quot;{}/{}&quot;.format(name, f) for f in image_files]</code><code>for imgf in image_files:</code><code><br>&nbsp; &nbsp; img = cv2.imread(imgf, 0)<br></code><code>&nbsp; &nbsp; img = cv2.resize(img, (128, 128), interpolation=cv2.INTER_CUBIC)<br></code><code>&nbsp; &nbsp; length = np.prod(img.shape)<br>&nbsp; &nbsp; img = np.reshape(img, length)<br>&nbsp; &nbsp; images.append(img)</code></p>\n<p><code>images = np.vstack(images)</code></p>\n<p>Now<strong>&nbsp;images&nbsp;</strong>is feature matrix which you can use with scikit learn algorithms.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "37320",
      "postDate": "01/12/2014 17:57:18",
      "content": "<p>Thanks Michal, but I can't find the cv2 module. I tried to install via conda and pip, but it didn't work.&nbsp;</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "37321",
      "postDate": "01/12/2014 18:48:11",
      "content": "<p>What OS do you use? If it is Mac - there seems to be lot of challenges in making it work. Linux has been the most straight forward.&nbsp;</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "37322",
      "postDate": "01/12/2014 18:49:03",
      "content": "<p>Meanwhile - a good resource for processing images using Python</p>\n<p>http://programmingcomputervision.com/</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "37323",
      "postDate": "01/12/2014 19:17:05",
      "content": "<p>[quote=Frank Schilder;37320]</p>\n<p>Thanks Michal, but I can't find the cv2 module. I tried to install via conda and pip, but it didn't work.&nbsp;</p>\n<p>[/quote]</p>\n<p>cv2 refers to python module as provided by OpenCV. (http://opencv.org/)</p>\n<p>Installations steps for Windows are documented here:</p>\n<p>http://docs.opencv.org/trunk/doc/py_tutorials/py_setup/py_setup_in_windows/py_setup_in_windows.html</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "37326",
      "postDate": "01/13/2014 02:26:48",
      "content": "<p>If you're Mac, your probably best off with the macports build of OpenCV.&nbsp; Installation of the dependencies can be a bit frustrating - there's a good tutorial here:</p>\n<p>http://compphotography.wordpress.com/2013/04/08/macos-python-install-macports/</p>\n<p>&nbsp;</p>\n<p>Also, to go along with the code example, if you want to vectorize a single image as an array, you can use the ravel() method - which will combine all</p>\n<p>vector = cv2.imread('image.jpg').ravel()</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "37329",
      "postDate": "01/13/2014 05:09:17",
      "content": "<p>I was able to download and install openCV, but my machine is a mac and installing the cv2 module seemed rather painful judging by the web pages offering various solutions to this problem. I have been using PIL so far, but it takes quite a while to load the images and I was hoping cv2 would be faster.&nbsp;</p>\n<p>The question is whether it is worthwhile to invest the extra time to install cv2. OpenCV seems to offer quite a lot of useful resources for image processing though. Anybody out there who was able to run cv2/OpenCV on a Mac?</p>\n<p>[I hadn't seen the post by Raymond Klass when I wrote this, I'll try macports then, although I have been using brew and pip lately.]</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "37330",
      "postDate": "01/13/2014 05:42:26",
      "content": "<p>[quote=Frank Schilder;37329]</p>\n<p><span style=\"line-height: 1.4\">The question is whether it is worthwhile to invest the extra time to install cv2. OpenCV seems to offer quite a lot of useful resources for image processing though. Anybody out there who was able to run cv2/OpenCV on a Mac?</span></p>\n<p>[/quote]</p>\n<p>&nbsp;</p>\n<p>I work on a mac and installed opencv using homebrew.&nbsp;</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "37337",
      "postDate": "01/13/2014 09:55:53",
      "content": "<p>Abhishek - what MacOS are you using? Out of interest, have you manged to get Theano and Pylearn2 working with GPU? I had to install Anaconda Python to get Python on my Mac. I'm on Mac OS X Lion 10.7.5 (11G63) - there was a conflict with scipy (xcodes/gcc/lvcc ?&nbsp; etc) when I tried to install packages individually</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "37339",
      "postDate": "01/13/2014 10:11:17",
      "content": "<p>Im using OSX mavericks. I didnt face any conflicts with scipy and all. As I dont have a GPU on my mac, I cannot use theano/pylearn2 for convolutional neural networks. However, I can use neural networks which do not require GPU and thus, theano/pylearn2 are working fine for me. I had a hard time installing opencv, but I finally managed to install it. (https://github.com/Homebrew/homebrew-science/issues/402)</p>\n<p>[quote=Domcastro;37337]</p>\n<p>Abhishek - what MacOS are you using? Out of interest, have you manged to get Theano and Pylearn2 working with GPU? I had to install Anaconda Python to get Python on my Mac. I'm on Mac OS X Lion 10.7.5 (11G63) - there was a conflict with scipy (xcodes/gcc/lvcc ?&nbsp; etc)</p>\n<p>[/quote]</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "37340",
      "postDate": "01/13/2014 10:20:30",
      "content": "<p>I use Anaconda on Mac. And this did the trick for opencv. A bit of effort though !&nbsp;</p>\n<p>https://gist.github.com/welch/6468594</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "37342",
      "postDate": "01/13/2014 11:15:38",
      "content": "<p>@domcastro, did you install an external GPU for your Mac?&nbsp;</p>\n<p>[quote=Domcastro;37337]</p>\n<p>Abhishek - what MacOS are you using? Out of interest, have you manged to get Theano and Pylearn2 working with GPU? I had to install Anaconda Python to get Python on my Mac. I'm on Mac OS X Lion 10.7.5 (11G63) - there was a conflict with scipy (xcodes/gcc/lvcc ?&nbsp; etc) when I tried to install packages individually</p>\n<p>[/quote]</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "37347",
      "postDate": "01/13/2014 13:32:42",
      "content": "<p>ah no- I have set up Theano and Pylearn2 on the Mac but uses CPU.&nbsp; I have a 64 bit windows machine too so bought a GEforce graphics card and installed that. Having trouble getting theano to work on winows though</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "37483",
      "postDate": "01/17/2014 00:01:04",
      "content": "<p>Check out&nbsp;http://scikit-image.org/ . It has got easy to use functional API in Python that work with bare Numpy arrays. To start, check out their Examples section :&nbsp;http://scikit-image.org/docs/dev/auto_examples/<a href=\"http://scikit-image.org/docs/dev/auto_examples/\"><br></a></p>\n<p>Github :&nbsp;https://github.com/scikit-image/scikit-image</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "37524",
      "postDate": "01/17/2014 19:07:29",
      "content": "<p>Hi there, any sample code using R?</p>\n<p>Thanks a lot,</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "37648",
      "postDate": "01/20/2014 20:24:00",
      "content": "<p>Did you use the values directly from the 'training_solutions.csv' file as the target label vector in sklearn?&nbsp;</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "37925",
      "postDate": "01/25/2014 17:11:55",
      "content": "<p>Very helpful, thanks. I'm familiar with the idea behind random forests, but it seems like training them is very slow in scikit-learn. Is that normal? I'm using 56x56 greyscale samples. I've been setting max_depth to around 5, max_features to sqrt, min_samples_split to 20 and that helps. But if I want to have say 80 trees it can take a minute or two.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "37930",
      "postDate": "01/25/2014 23:47:28",
      "content": "<p>I also had a lot of trouble getting opencv and related tools to work on my Mac. I was finally able to do it quiet painlessly by using Macports.&nbsp;</p>\n<p>If you suspect you have a foobared version of macports installed, or an install thats really old and hasn't been updated in a while you might think about removing it using the procedure in the following page http://guide.macports.org/chunked/installing.macports.uninstalling.html.</p>\n<p>Install the latest version of Macports and then run the following on the command line (I found it also helps if you are running Mavericks):</p>\n<p>sudo port install python27</p>\n<p>sudo port select --set python python27</p>\n<p>sudo port install qt4</p>\n<p>sudo port install py27-matplotlib&nbsp;py27-pil&nbsp;py27-scipy py27-pyside py27-numpy</p>\n<p><em>#To get matplotlib to work properly you will want to change its configuration to use QT.</em></p>\n<p><em># Do this by&nbsp;going to (your home dir)/.matplotlib/matplotlibrc and change the backend parameter to QT4Agg.&nbsp;</em><em>Then change the backend.qt4 parameter to PySide. You might need to run python and import matplotlib to get the .matplotlib directory to pop up.</em></p>\n<p>sudo port install opencv +python27</p>\n<p><em>#At this point test your opencv install by opening the python prompt and import cv2.</em></p>\n<p><em>--- Additional helpful tools ---</em></p>\n<p><em>sudo port install py27-setuptools</em></p>\n<p><em>#you will want to go to the /opt/local/bin (where macports stores all the executables) directory and ln -s easy_install-2.7 easy_install</em></p>\n<p><em>sudo port install py27-ipython</em></p>\n<p><em>#look into using&nbsp;</em><em>python notebook ;) you will need to install additional packages to get this to work.</em></p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "38459",
      "postDate": "02/06/2014 22:26:58",
      "content": "<p>Hello!</p>\n<p>Thanks for the tip of using RandomForestRegressor!</p>\n<p>I'm also using Mac OS X Mavericks and Scikit-learn.</p>\n<p>But I think I have some optimization problems... how much time do you spend fitting the training data??</p>\n<p>&nbsp;</p>\n<p>Regards!</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "38479",
      "postDate": "02/07/2014 15:29:30",
      "content": "<p>Building a model over here takes two or three days. I guess we are all on the same boat.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "38618",
      "postDate": "02/11/2014 07:45:44",
      "content": "<p><span style=\"line-height: 1.4\">How can you use a 1D vector to predict the output which is also a vector?</span></p>\n<p>We have these images x in X, and we have the target output which is a vector y in Y. &nbsp;The target vectors in Y look like &lt;prediction for class 1.1, prediction for class 1.2, ...&gt;, and you've converted each image x in X to be 1D vectors as well.</p>\n<p>You say you used Random Forest Regression to make a predictive model from X to Y. &nbsp;But with Random Forest, you need the Y to be either a real number for regression or a class for classification -- it can't be a vector.</p>\n<p>So when you build your model, are you actually building a new forest to classify every <em>entry</em> of the y vector in other words, growing a new forest for every class and subclass? &nbsp;Or are you focussing your efforts on a classification of just class 1 and zeroing everything else?</p>\n<p>Thanks a lot, Abhishek.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "38666",
      "postDate": "02/12/2014 04:25:43",
      "content": "<p>[quote=Richard Craib;38618]</p>\n<p><span style=\"line-height: 1.4\"><span style=\"line-height: 1.4\">So when you build your model, are you actually building a new forest to classify every </span><em style=\"line-height: 1.4\">entry</em><span style=\"line-height: 1.4\"> of the y vector in other words, growing a new forest for every class and subclass? &nbsp;Or are you focussing your efforts on a classification of just class 1 and zeroing everything else?</span></span></p>\n<p><span style=\"line-height: 1.4\">[/quote]</span></p>\n<p><span style=\"line-height: 1.4\">It's training a different random forest for each output. &nbsp;If you're using scikit-learn then most (all?) of the regression and classification algorithms will handle it automatically. &nbsp;They check the shape of the ndarray and behave differently for one output (1-dim) vs multiple outputs (2-dim).</span></p>\n<p>&nbsp;</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "38704",
      "postDate": "02/13/2014 00:29:35",
      "content": "<p>[quote=Keith Trnka;38666]</p>\n<p>[quote=Richard Craib;38618]</p>\n<p><span style=\"line-height: 1.4\"><span style=\"line-height: 1.4\">So when you build your model, are you actually building a new forest to classify every </span><em style=\"line-height: 1.4\">entry</em><span style=\"line-height: 1.4\"> of the y vector in other words, growing a new forest for every class and subclass? &nbsp;Or are you focussing your efforts on a classification of just class 1 and zeroing everything else?</span></span></p>\n<p><span style=\"line-height: 1.4\">[/quote]</span></p>\n<p><span style=\"line-height: 1.4\">It's training a different random forest for each output. &nbsp;If you're using scikit-learn then most (all?) of the regression and classification algorithms will handle it automatically. &nbsp;They check the shape of the ndarray and behave differently for one output (1-dim) vs multiple outputs (2-dim).</span></p>\n<p>&nbsp;</p>\n<p>[/quote]</p>\n<p>I have only found ensemble methods like RandomForestRegressor and ExtraTreesRegressor are able to automagically give multiple regression outputs. Are there other options in scikit-learn? I suspect if you want to use other learning algorithms you will need to stitch them together manually.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "38714",
      "postDate": "02/13/2014 05:01:06",
      "content": "<p>[quote=Jeremy;38704]</p>\n<p>I have only found ensemble methods like RandomForestRegressor and ExtraTreesRegressor are able to automagically give multiple regression outputs. Are there other options in scikit-learn? I suspect if you want to use other learning algorithms you will need to stitch them together manually.</p>\n<p>[/quote]</p>\n<p>I'm pretty new to scikit-learn, but&nbsp;linear_model.Ridge will automatically work for multiple regression outputs. &nbsp;The other classes in the linear package probably do too.</p>\n<p>I've tried logistic regression but it doesn't support multiple binary classifications automatically. &nbsp;It looks like&nbsp;sklearn.multiclass.OneVsRestClassifier might be the an option but if you're already dealing with a set of binary classifications you'd need to convert to a single multiple-class output first.</p>\n<p>You can check classes individually by reading the doc on the fit function, but I wish there were a high-level table that showed it.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "38868",
      "postDate": "02/15/2014 19:55:25",
      "content": "<p>Thanks for the tip. I was able to beat the benchmark using only least squares and a single pixel image matrix, which made the computation time much faster.</p>\n<p>&nbsp;</p>",
      "rawMarkdown": "",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 37245,
      "author_name": "adjgiulio",
      "author_url": "",
      "post_date": "01/10/2014 18:35:54",
      "content": "<p>[quote=Abhishek;37233]</p>\n<p>Since, I've been ridiculed previously for the beating the benchmark posts,&nbsp;</p>\n<p>[/quote]</p>\n<p>LOL.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 37258,
      "author_name": "abhishek",
      "author_url": "",
      "post_date": "01/10/2014 21:28:08",
      "content": "<p>aint that true :P&nbsp;</p>\n<p>[quote=Giulio;37245]</p>\n<p>[quote=Abhishek;37233]</p>\n<p>Since, I've been ridiculed previously for the beating the benchmark posts,&nbsp;</p>\n<p>[/quote]</p>\n<p>LOL.</p>\n<p>[/quote]</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 37259,
      "author_name": "adjgiulio",
      "author_url": "",
      "post_date": "01/10/2014 21:35:20",
      "content": "<p>[quote=Abhishek;37258]</p>\n<p>aint that true :P&nbsp;</p>\n<p>[quote=Giulio;37245]</p>\n<p>[quote=Abhishek;37233]</p>\n<p>Since, I've been ridiculed previously for the beating the benchmark posts,&nbsp;</p>\n<p>[/quote]</p>\n<p>LOL.</p>\n<p>[/quote]</p>\n<p>[/quote]</p>\n<p>C'mon! You ended up with more fans than haters :-)</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 37269,
      "author_name": "rouseguy",
      "author_url": "",
      "post_date": "01/11/2014 04:28:06",
      "content": "<p>I've never done image processing before. Would it be possible to post a sample code on how to resize and vectorize it to 1-D array?&nbsp;</p>\n<p>&nbsp;</p>\n<p>Thanks.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 37275,
      "author_name": "mrnustik",
      "author_url": "",
      "post_date": "01/11/2014 09:36:20",
      "content": "<p><code>import numpy as np<br>import pandas as pd</code><code><code>import cv2</code></code></p>\n<p><code>images = []<br> image_files = sorted(os.listdir('images_training'))<br>image_files = [&quot;{}/{}&quot;.format(name, f) for f in image_files]</code><code>for imgf in image_files:</code><code><br>&nbsp; &nbsp; img = cv2.imread(imgf, 0)<br></code><code>&nbsp; &nbsp; img = cv2.resize(img, (128, 128), interpolation=cv2.INTER_CUBIC)<br></code><code>&nbsp; &nbsp; length = np.prod(img.shape)<br>&nbsp; &nbsp; img = np.reshape(img, length)<br>&nbsp; &nbsp; images.append(img)</code></p>\n<p><code>images = np.vstack(images)</code></p>\n<p>Now<strong>&nbsp;images&nbsp;</strong>is feature matrix which you can use with scikit learn algorithms.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 37320,
      "author_name": "fschilder",
      "author_url": "",
      "post_date": "01/12/2014 17:57:18",
      "content": "<p>Thanks Michal, but I can't find the cv2 module. I tried to install via conda and pip, but it didn't work.&nbsp;</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 37321,
      "author_name": "rouseguy",
      "author_url": "",
      "post_date": "01/12/2014 18:48:11",
      "content": "<p>What OS do you use? If it is Mac - there seems to be lot of challenges in making it work. Linux has been the most straight forward.&nbsp;</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 37322,
      "author_name": "rouseguy",
      "author_url": "",
      "post_date": "01/12/2014 18:49:03",
      "content": "<p>Meanwhile - a good resource for processing images using Python</p>\n<p>http://programmingcomputervision.com/</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 37323,
      "author_name": "mattvonrohr",
      "author_url": "",
      "post_date": "01/12/2014 19:17:05",
      "content": "<p>[quote=Frank Schilder;37320]</p>\n<p>Thanks Michal, but I can't find the cv2 module. I tried to install via conda and pip, but it didn't work.&nbsp;</p>\n<p>[/quote]</p>\n<p>cv2 refers to python module as provided by OpenCV. (http://opencv.org/)</p>\n<p>Installations steps for Windows are documented here:</p>\n<p>http://docs.opencv.org/trunk/doc/py_tutorials/py_setup/py_setup_in_windows/py_setup_in_windows.html</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 37326,
      "author_name": "raymondklass",
      "author_url": "",
      "post_date": "01/13/2014 02:26:48",
      "content": "<p>If you're Mac, your probably best off with the macports build of OpenCV.&nbsp; Installation of the dependencies can be a bit frustrating - there's a good tutorial here:</p>\n<p>http://compphotography.wordpress.com/2013/04/08/macos-python-install-macports/</p>\n<p>&nbsp;</p>\n<p>Also, to go along with the code example, if you want to vectorize a single image as an array, you can use the ravel() method - which will combine all</p>\n<p>vector = cv2.imread('image.jpg').ravel()</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 37329,
      "author_name": "fschilder",
      "author_url": "",
      "post_date": "01/13/2014 05:09:17",
      "content": "<p>I was able to download and install openCV, but my machine is a mac and installing the cv2 module seemed rather painful judging by the web pages offering various solutions to this problem. I have been using PIL so far, but it takes quite a while to load the images and I was hoping cv2 would be faster.&nbsp;</p>\n<p>The question is whether it is worthwhile to invest the extra time to install cv2. OpenCV seems to offer quite a lot of useful resources for image processing though. Anybody out there who was able to run cv2/OpenCV on a Mac?</p>\n<p>[I hadn't seen the post by Raymond Klass when I wrote this, I'll try macports then, although I have been using brew and pip lately.]</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 37330,
      "author_name": "abhishek",
      "author_url": "",
      "post_date": "01/13/2014 05:42:26",
      "content": "<p>[quote=Frank Schilder;37329]</p>\n<p><span style=\"line-height: 1.4\">The question is whether it is worthwhile to invest the extra time to install cv2. OpenCV seems to offer quite a lot of useful resources for image processing though. Anybody out there who was able to run cv2/OpenCV on a Mac?</span></p>\n<p>[/quote]</p>\n<p>&nbsp;</p>\n<p>I work on a mac and installed opencv using homebrew.&nbsp;</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 37337,
      "author_name": "domcastro",
      "author_url": "",
      "post_date": "01/13/2014 09:55:53",
      "content": "<p>Abhishek - what MacOS are you using? Out of interest, have you manged to get Theano and Pylearn2 working with GPU? I had to install Anaconda Python to get Python on my Mac. I'm on Mac OS X Lion 10.7.5 (11G63) - there was a conflict with scipy (xcodes/gcc/lvcc ?&nbsp; etc) when I tried to install packages individually</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 37339,
      "author_name": "abhishek",
      "author_url": "",
      "post_date": "01/13/2014 10:11:17",
      "content": "<p>Im using OSX mavericks. I didnt face any conflicts with scipy and all. As I dont have a GPU on my mac, I cannot use theano/pylearn2 for convolutional neural networks. However, I can use neural networks which do not require GPU and thus, theano/pylearn2 are working fine for me. I had a hard time installing opencv, but I finally managed to install it. (https://github.com/Homebrew/homebrew-science/issues/402)</p>\n<p>[quote=Domcastro;37337]</p>\n<p>Abhishek - what MacOS are you using? Out of interest, have you manged to get Theano and Pylearn2 working with GPU? I had to install Anaconda Python to get Python on my Mac. I'm on Mac OS X Lion 10.7.5 (11G63) - there was a conflict with scipy (xcodes/gcc/lvcc ?&nbsp; etc)</p>\n<p>[/quote]</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 37340,
      "author_name": "rouseguy",
      "author_url": "",
      "post_date": "01/13/2014 10:20:30",
      "content": "<p>I use Anaconda on Mac. And this did the trick for opencv. A bit of effort though !&nbsp;</p>\n<p>https://gist.github.com/welch/6468594</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 37342,
      "author_name": "abhishek",
      "author_url": "",
      "post_date": "01/13/2014 11:15:38",
      "content": "<p>@domcastro, did you install an external GPU for your Mac?&nbsp;</p>\n<p>[quote=Domcastro;37337]</p>\n<p>Abhishek - what MacOS are you using? Out of interest, have you manged to get Theano and Pylearn2 working with GPU? I had to install Anaconda Python to get Python on my Mac. I'm on Mac OS X Lion 10.7.5 (11G63) - there was a conflict with scipy (xcodes/gcc/lvcc ?&nbsp; etc) when I tried to install packages individually</p>\n<p>[/quote]</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 37347,
      "author_name": "domcastro",
      "author_url": "",
      "post_date": "01/13/2014 13:32:42",
      "content": "<p>ah no- I have set up Theano and Pylearn2 on the Mac but uses CPU.&nbsp; I have a 64 bit windows machine too so bought a GEforce graphics card and installed that. Having trouble getting theano to work on winows though</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 37483,
      "author_name": "ankitagrawal2",
      "author_url": "",
      "post_date": "01/17/2014 00:01:04",
      "content": "<p>Check out&nbsp;http://scikit-image.org/ . It has got easy to use functional API in Python that work with bare Numpy arrays. To start, check out their Examples section :&nbsp;http://scikit-image.org/docs/dev/auto_examples/<a href=\"http://scikit-image.org/docs/dev/auto_examples/\"><br></a></p>\n<p>Github :&nbsp;https://github.com/scikit-image/scikit-image</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 37524,
      "author_name": "vcomas",
      "author_url": "",
      "post_date": "01/17/2014 19:07:29",
      "content": "<p>Hi there, any sample code using R?</p>\n<p>Thanks a lot,</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 37648,
      "author_name": "gallamine",
      "author_url": "",
      "post_date": "01/20/2014 20:24:00",
      "content": "<p>Did you use the values directly from the 'training_solutions.csv' file as the target label vector in sklearn?&nbsp;</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 37925,
      "author_name": "keithtrnka",
      "author_url": "",
      "post_date": "01/25/2014 17:11:55",
      "content": "<p>Very helpful, thanks. I'm familiar with the idea behind random forests, but it seems like training them is very slow in scikit-learn. Is that normal? I'm using 56x56 greyscale samples. I've been setting max_depth to around 5, max_features to sqrt, min_samples_split to 20 and that helps. But if I want to have say 80 trees it can take a minute or two.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 37930,
      "author_name": "ronlaren",
      "author_url": "",
      "post_date": "01/25/2014 23:47:28",
      "content": "<p>I also had a lot of trouble getting opencv and related tools to work on my Mac. I was finally able to do it quiet painlessly by using Macports.&nbsp;</p>\n<p>If you suspect you have a foobared version of macports installed, or an install thats really old and hasn't been updated in a while you might think about removing it using the procedure in the following page http://guide.macports.org/chunked/installing.macports.uninstalling.html.</p>\n<p>Install the latest version of Macports and then run the following on the command line (I found it also helps if you are running Mavericks):</p>\n<p>sudo port install python27</p>\n<p>sudo port select --set python python27</p>\n<p>sudo port install qt4</p>\n<p>sudo port install py27-matplotlib&nbsp;py27-pil&nbsp;py27-scipy py27-pyside py27-numpy</p>\n<p><em>#To get matplotlib to work properly you will want to change its configuration to use QT.</em></p>\n<p><em># Do this by&nbsp;going to (your home dir)/.matplotlib/matplotlibrc and change the backend parameter to QT4Agg.&nbsp;</em><em>Then change the backend.qt4 parameter to PySide. You might need to run python and import matplotlib to get the .matplotlib directory to pop up.</em></p>\n<p>sudo port install opencv +python27</p>\n<p><em>#At this point test your opencv install by opening the python prompt and import cv2.</em></p>\n<p><em>--- Additional helpful tools ---</em></p>\n<p><em>sudo port install py27-setuptools</em></p>\n<p><em>#you will want to go to the /opt/local/bin (where macports stores all the executables) directory and ln -s easy_install-2.7 easy_install</em></p>\n<p><em>sudo port install py27-ipython</em></p>\n<p><em>#look into using&nbsp;</em><em>python notebook ;) you will need to install additional packages to get this to work.</em></p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 38459,
      "author_name": "leopiney",
      "author_url": "",
      "post_date": "02/06/2014 22:26:58",
      "content": "<p>Hello!</p>\n<p>Thanks for the tip of using RandomForestRegressor!</p>\n<p>I'm also using Mac OS X Mavericks and Scikit-learn.</p>\n<p>But I think I have some optimization problems... how much time do you spend fitting the training data??</p>\n<p>&nbsp;</p>\n<p>Regards!</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 38479,
      "author_name": "delcacho",
      "author_url": "",
      "post_date": "02/07/2014 15:29:30",
      "content": "<p>Building a model over here takes two or three days. I guess we are all on the same boat.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 38618,
      "author_name": "richardcraib",
      "author_url": "",
      "post_date": "02/11/2014 07:45:44",
      "content": "<p><span style=\"line-height: 1.4\">How can you use a 1D vector to predict the output which is also a vector?</span></p>\n<p>We have these images x in X, and we have the target output which is a vector y in Y. &nbsp;The target vectors in Y look like &lt;prediction for class 1.1, prediction for class 1.2, ...&gt;, and you've converted each image x in X to be 1D vectors as well.</p>\n<p>You say you used Random Forest Regression to make a predictive model from X to Y. &nbsp;But with Random Forest, you need the Y to be either a real number for regression or a class for classification -- it can't be a vector.</p>\n<p>So when you build your model, are you actually building a new forest to classify every <em>entry</em> of the y vector in other words, growing a new forest for every class and subclass? &nbsp;Or are you focussing your efforts on a classification of just class 1 and zeroing everything else?</p>\n<p>Thanks a lot, Abhishek.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 38666,
      "author_name": "keithtrnka",
      "author_url": "",
      "post_date": "02/12/2014 04:25:43",
      "content": "<p>[quote=Richard Craib;38618]</p>\n<p><span style=\"line-height: 1.4\"><span style=\"line-height: 1.4\">So when you build your model, are you actually building a new forest to classify every </span><em style=\"line-height: 1.4\">entry</em><span style=\"line-height: 1.4\"> of the y vector in other words, growing a new forest for every class and subclass? &nbsp;Or are you focussing your efforts on a classification of just class 1 and zeroing everything else?</span></span></p>\n<p><span style=\"line-height: 1.4\">[/quote]</span></p>\n<p><span style=\"line-height: 1.4\">It's training a different random forest for each output. &nbsp;If you're using scikit-learn then most (all?) of the regression and classification algorithms will handle it automatically. &nbsp;They check the shape of the ndarray and behave differently for one output (1-dim) vs multiple outputs (2-dim).</span></p>\n<p>&nbsp;</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 38704,
      "author_name": "jeremyk",
      "author_url": "",
      "post_date": "02/13/2014 00:29:35",
      "content": "<p>[quote=Keith Trnka;38666]</p>\n<p>[quote=Richard Craib;38618]</p>\n<p><span style=\"line-height: 1.4\"><span style=\"line-height: 1.4\">So when you build your model, are you actually building a new forest to classify every </span><em style=\"line-height: 1.4\">entry</em><span style=\"line-height: 1.4\"> of the y vector in other words, growing a new forest for every class and subclass? &nbsp;Or are you focussing your efforts on a classification of just class 1 and zeroing everything else?</span></span></p>\n<p><span style=\"line-height: 1.4\">[/quote]</span></p>\n<p><span style=\"line-height: 1.4\">It's training a different random forest for each output. &nbsp;If you're using scikit-learn then most (all?) of the regression and classification algorithms will handle it automatically. &nbsp;They check the shape of the ndarray and behave differently for one output (1-dim) vs multiple outputs (2-dim).</span></p>\n<p>&nbsp;</p>\n<p>[/quote]</p>\n<p>I have only found ensemble methods like RandomForestRegressor and ExtraTreesRegressor are able to automagically give multiple regression outputs. Are there other options in scikit-learn? I suspect if you want to use other learning algorithms you will need to stitch them together manually.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 38714,
      "author_name": "keithtrnka",
      "author_url": "",
      "post_date": "02/13/2014 05:01:06",
      "content": "<p>[quote=Jeremy;38704]</p>\n<p>I have only found ensemble methods like RandomForestRegressor and ExtraTreesRegressor are able to automagically give multiple regression outputs. Are there other options in scikit-learn? I suspect if you want to use other learning algorithms you will need to stitch them together manually.</p>\n<p>[/quote]</p>\n<p>I'm pretty new to scikit-learn, but&nbsp;linear_model.Ridge will automatically work for multiple regression outputs. &nbsp;The other classes in the linear package probably do too.</p>\n<p>I've tried logistic regression but it doesn't support multiple binary classifications automatically. &nbsp;It looks like&nbsp;sklearn.multiclass.OneVsRestClassifier might be the an option but if you're already dealing with a set of binary classifications you'd need to convert to a single multiple-class output first.</p>\n<p>You can check classes individually by reading the doc on the fit function, but I wish there were a high-level table that showed it.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 38868,
      "author_name": "mattdelhey",
      "author_url": "",
      "post_date": "02/15/2014 19:55:25",
      "content": "<p>Thanks for the tip. I was able to beat the benchmark using only least squares and a single pixel image matrix, which made the computation time much faster.</p>\n<p>&nbsp;</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "37233": "",
    "37245": "",
    "37258": "",
    "37259": "",
    "37269": "",
    "37275": "",
    "37320": "",
    "37321": "",
    "37322": "",
    "37323": "",
    "37326": "",
    "37329": "",
    "37330": "",
    "37337": "",
    "37339": "",
    "37340": "",
    "37342": "",
    "37347": "",
    "37483": "",
    "37524": "",
    "37648": "",
    "37925": "",
    "37930": "",
    "38459": "",
    "38479": "",
    "38618": "",
    "38666": "",
    "38704": "",
    "38714": "",
    "38868": ""
  },
  "source": "meta"
}