title: Machine learning for finding even/odd number getting incorrect/correct output for two different classifiers
body: <p>I tried a Machine Learning algorithm on a hypothetical problem :-</p>
  
  <p>I made a fake feature vector and a fake result data set by the following python code :-</p>
  
  <pre><code>x=[]
  y=[]
  for i in range(0,100000):
      mylist=[]
      mylist.append(i)
      mylist.append(i)
      x.append(mylist)
      if(i%2)==0:
          y.append(0)
      else:
          y.append(1)
  </code></pre>
  
  <p>The above code gives me 2 python lists, namely, 
  x = [[0,0],[1,1],[2,2]....and so on] #this list contains the fake feature vector, with 2 same numbers</p>
  
  <p>y = [0,1,0..... and so on] #this has the fake test labels, 0 for even, 1 for odd</p>
  
  <p>I think the test data is good enough for a ML algorithm to learn. I use the following python code to train a couple of different machine learning models.</p>
  
  <p>Approach 1 : Gaussian Naive Bayes</p>
  
  <pre><code>from sklearn.naive_bayes import GaussianNB
  gnb = GaussianNB()
  gnb.fit(x,y)
  x_pred = [[1,1],[2,2],[3,3],[4,4],[5,5],[6,6],[7,7],[8,8],[9,9],[10,10],[11,11],[12,12],[13,13],[14,14],[15,15],[16,16]]
  y_pred=gnb.predict(x_pred)
  print y_pred
  </code></pre>
  
  <p>I get the following incorrect output, the classifier fails to predict :- </p>
  
  <pre><code>[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
  </code></pre>
  
  <p>Approach 2 : Support Vector Machines</p>
  
  <pre><code>from sklearn import svm
  clf = svm.SVC()
  clf.fit(x, y)
  x_pred = [[1,1],[2,2],[3,3],[4,4],[5,5],[6,6],[7,7],[8,8],[9,9],[10,10],[11,11],[12,12],[13,13],[14,14],[15,15],[16,16]]
  y_pred=clf.predict(x_pred)
  print y_pred
  </code></pre>
  
  <p>I get the following correct output, the classifier fails to predict :- </p>
  
  <pre><code>[1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0]
  </code></pre>
  
  <p>Can someone put light on this and explain why one approach had 50% accuracy and the other one had 100% accuracy.</p>
  
  <p>Let me know if this question is tagged with a wrong category.</p>