title: how to improve neural network prediction, classification
body: <p>I am trying to learn some neural networks for fun. I decided to try to classify some pokemon legendary cards, from a data set from kaggle. I read up on documentations and followed machine learning mastery guides, while reading up on medium to try to understand the process. </p>
  
  <p>My problem/ question  : i tried predicting and everything is predicting "0". i assume that is false. is my 92% false accuracy? i read something about false accuracy online. </p>
  
  <p>please help!</p>
  
  <p>Some background information : the dataset has 800 rows, 12 columns. i am predicting the last column ( true/false). I am using attributes of the data that has numerical and categorical. i label encoded the numerical categories. 92% of these cards are False. 8% are true.</p>
  
  <p>i sampled and ran a neural network on 200 cards, and got 91% accuracy... i also reset everything and got a 92% accuracy on all 800 cards. am i overfitting? </p>
  
  <p>thank you for help in advance</p>
  
  <pre><code>dataFrame = dataFrame.fillna(value='NaN')
  
  labelencoder = LabelEncoder()
  
  numpy_dataframe = dataFrame.as_matrix()
  numpy_dataframe[:, 0] = labelencoder.fit_transform(numpy_dataframe[:, 0])
  numpy_dataframe[:, 1] = labelencoder.fit_transform(numpy_dataframe[:, 1])
  
  numpy_dataframe
  X = numpy_dataframe[:,0:10]
  Y = numpy_dataframe[:,10]
  model = Sequential()
  model.add(Dense(12, input_dim=10, activation='relu'))
  model.add(Dense(8, activation='relu'))
  model.add(Dense(1, activation='sigmoid'))
  model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
  model.fit(X, Y, epochs=150, batch_size=10)
  scores = model.evaluate(X, Y)
  print("\n%s: %.2f%%" % (model.metrics_names[1], scores[1]*100))
  
  #this shows that we have 91.88% accuracy with the whole dataframe
  
  
  dataFrame200False = dataFrame 
  dataFrame200False['Legendary'] = dataFrame200False['Legendary'].astype(str)
  dataFrame200False= dataFrame200False[dataFrame200False['Legendary'].str.contains("False")]
  
  dataFrame65True = dataFrame
  
  dataFrame65True['Legendary'] = dataFrame65True['Legendary'].astype(str)
  dataFrame65True= dataFrame65True[dataFrame65True['Legendary'].str.contains("True")]
  
  DataFrameFalseSample = dataFrame200False.sample(200)
  DataFrameFalseSample
  
  dataFrameSampledTrueFalse = dataFrame65True.append(DataFrameFalseSample, ignore_index=True)
  dataFrameSampledTrueFalse
  
  #label encoding the files
  labelencoder = LabelEncoder()
  
  numpy_dataSample = dataFrameSampledTrueFalse.as_matrix()
  numpy_dataSample[:, 0] = labelencoder.fit_transform(numpy_dataSample[:, 0])
  numpy_dataSample[:, 1] = labelencoder.fit_transform(numpy_dataSample[:, 1])
  
  numpy_dataSample
  a = numpy_dataframe[:,0:10]
  b = numpy_dataframe[:,10]
  
  model = Sequential()
  model.add(Dense(12, input_dim=10, activation='relu'))
  model.add(Dense(8, activation='relu'))
  model.add(Dense(1, activation='sigmoid'))
  model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
  model.fit(a, b, epochs=1000, batch_size=10)
  
  scoresSample = model.evaluate(a, b)
  print("\n%s: %.2f%%" % (model.metrics_names[1], scoresSample[1]*100))
  
  dataFramePredictSample = dataFrame.sample(500)
  labelencoder = LabelEncoder()
  
  numpy_dataframeSamples = dataFramePredictSample.as_matrix()
  numpy_dataframeSamples[:, 0] = labelencoder.fit_transform(numpy_dataframeSamples[:, 0])
  numpy_dataframeSamples[:, 1] = labelencoder.fit_transform(numpy_dataframeSamples[:, 1])
  
  Xnew = numpy_dataframeSamples[:,0:10]
  Ynew = numpy_dataframeSamples[:,10]
  
  
  # make a prediction
  Y = model.predict_classes(Xnew)
  # show the inputs and predicted outputs
  for i in range(len(Xnew)):
      print("X=%s, Predicted=%s" % (Xnew[i], Y[i]))
  </code></pre>