osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why am a getting wrong prediction when combining two list of samples, which individually gives correct prediction?


So I am coding in Python. I have to set of samples. Set1 contains samples of class A and the other set, Set2 contains samples of class B. When I am predicting set1 and set2 individually, the classification is perfect. Now when I am merging the two sets for prediction into one set, the prediction gives the wrong result for the samples in Set2, i.e., predicting the samples of set 2 to be in class A. However, samples belonging to Set1 are predicted to be in class A in the merged set. Why is this happening?

model.add(Dense(newshape[1]+1, activation='relu', input_shape=(newshape[1],)))
model.add(Dropout(0.5))
model.add(Dense(500, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(250, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(100, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(50, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(1, activation='sigmoid'))
model.compile(loss='binary_crossentropy',
          optimizer='adam',
          metrics=['binary_accuracy'])
model.fit(X_train, y_train,validation_data=(X_test, y_test),validation_split=0.2, epochs=500, batch_size=25, verbose=0)