I used VGG16 as feature extractor on a dataset with 9 classes and trained the Random Forest Classifier on the feature vector. I tried to make prediction on the test feature vector but the prediction is an array of zeroes. What am i doing wrong ?

All zero prediction Notebook Link

  • $\begingroup$ What is the accuracy of your model? It might simply be that your current model doesn't fit the data very well and therefore always predict zero. $\endgroup$
    – Oxbowerce
    Commented Jan 4, 2023 at 11:34
  • $\begingroup$ @Oxbowerce The accuracy is 0. I tried fitting the RandomForestClassifier on test_feature_vector and tried to predict it on part of train_feature_vector and still got all zero array. $\endgroup$
    – gray
    Commented Jan 4, 2023 at 11:40
  • $\begingroup$ Then it simply means that your model is unable to fit the data well. This can be caused by the fact that your model is too simple or your features are simply not predictive. Try changing the hyperparameters of your model to see if it improves the performance. $\endgroup$
    – Oxbowerce
    Commented Jan 4, 2023 at 11:42
  • $\begingroup$ I looked at the notebook. You are using VGG models, which were built for detecting objects like car etc. Using that as a feature extraction layer for cancer detection is not going to work well. You can try other feature extraction methods or fit custom layers! $\endgroup$
    – hssay
    Commented Jan 4, 2023 at 13:11
  • 1
    $\begingroup$ @hssay Im trying to recreate the architecture from this paper igi-global.com/gateway/article/full-text-html/… $\endgroup$
    – gray
    Commented Jan 4, 2023 at 13:56

1 Answer 1


Your model is not learning. The result is constant predictions on the test dataset.

There could be many reasons for not learning. A couple of the most common reasons:

  • Not enough data
  • Not expressive enough machine learning algorithm
  • Incorrect hyperparameter choices
  • Not training long enough

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.