title: One class SVM, got all -1
body: <p>I am doing a <strong>binary classification</strong> that only returns "yes" or "no" for the <strong>image</strong>. As I only got an image of <strong>one class</strong>, so I wanna classify between "Target" and " Outlier". </p>
  
  <p>For example, I am classifying the fireman. 
  <a href="https://i.stack.imgur.com/Xj4dx.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Xj4dx.jpg" alt="enter image description here"></a></p>
  
  <p>I am using Scikit Learn <code>svm.OneClassSVM()</code>. However, after training the model, I got  "-1" every time, even for predicting the training data.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>X_train = []
  for subdir, dirs, files in os.walk("training"):
      for imagePath in files:
          print ("path = ", imagePath)
          img = Image.open(os.path.join(subdir, imagePath))
          img = img.resize(sample_size, PIL.Image.ANTIALIAS)
          img = np.array(img)
          img = img[:,:,0]
          img = img.reshape(1, img.shape[0]* img.shape[1])
          X_train.append(img[0])
  
  clf = svm.OneClassSVM(nu=0.1, kernel="rbf", gamma=0.1)
  clf.fit(X_train)
  </code></pre>
  
  <hr>
  
  <p>And then I predict the result of "training data"</p>
  
  <pre><code>print clf.predict (X_train)
  </code></pre>
  
  <p>However, I still get all "-1". Can anyone tell me what's wrong?</p>