I duplicated my training data for the random forest classifier (Sklearn) and the accuracy of the prediction increased by about 3%. Why?
-
$\begingroup$ 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! $\endgroup$– Romain ReboulleauDec 6, 2018 at 12:40
1 Answer
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).
-
$\begingroup$ 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. $\endgroup$ Dec 7, 2018 at 3:53
-
$\begingroup$ 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 $\endgroup$– seisemanDec 7, 2018 at 9:49