I duplicated my training data for the random forest classifier (Sklearn) and the accuracy of the prediction increased by about 3%. Why?

closed as too broad by Kiritee Gak, TBSRounder, Stephen Rauch, OmG, oW_ Dec 10 at 19:50

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Hello, welcome to the site. Can you please provide some extra details on your problem? We could use some information, like what kind of problem you're trying to solve (binary or multi-class classification, regression?), the options set in the constructor and for the fit method, how you duplicated the data and got the accuracy scores. Do not hesitate to provide samples of code! – Romain Reboulleau Dec 6 at 12:40

Without further details, my guess is that your dataset is unbalanced (not the same number of samples in both classes), so that duplicating the data increases the # samples in the most represented class. Depending on how you configured the Random Forest, it may aim at predicting correctly the most represented class and have less concern about the under represented one. In this case, by duplicating the dataset, you put even more pressure on predicting the most represented class and that's what it does, thus increasing accuracy.

As a note, I believe this would not happen if you were training on a dataset and testing on a different one (samples of the test set, on which you assess performance, should be different from the ones in the train set).

  • Classification is slightly unbalanced, about 52:48, yes. But I am training/testing on two different datasets, basically I split them beforehand. Thanks for the answer. – Franc Weser Dec 7 at 3:53
  • You may also want to check that you don't have duplicates between your train / test sets, that is the same data contained in both datasets, which could also explain this phenomenon. Also, if you want to have repeatable results, I encourage you to explicitly declare the random_seed you use in your algorithm, otherwise running the same training phase twice may result in different results – seiseman Dec 7 at 9:49

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