[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?

On Wed, 12 Jun 2019 04:12:34 -0700 (PDT), Rishika Sen wrote:

> 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)

This is really a question about some model-fitting package that you're
using, not about Python.  And you don't even tell us which model-fitting
package it is.  Please share more information.

Are you expecting that any model-fitting process that works individually
on Set1 and Set2 must work on the union of the two sets?  'Cause I don't
think it works that way.

To email me, substitute nowhere->runbox, invalid->com.