I'm a little confused on how to manage my data set with WEKA (for data mining).

I have a Dat set including 11377 record classified as follows:

  • 11111 records have class YES
  • 266 records have class NO

This is an unbalanced class, and if I start the classification process with WEKA, the results will be poor.

I want to use the Cross-validation with 10 fold for the classification of data with J48 tree algorithm, but first I need to oversample my minority class? How can I prevent overfitting of data?


2 Answers 2


Start by making sure that you are performing the oversampling in the correct portion of your analysis. First you create a validation set that is not at all involved in the training by randomly pulling out some percentage of your data. Make sure that randomly sampled data has the correct proportion of YES and NO. Then you use the remaining data [only] (do NOT use the data in the validation set) to perform your oversampling and analysis.

Your randomly selected validation set is then used to determine the performance of your model. Check the selectivity and specificity of your results. If you want to get a general idea of how much overfitting there is you can see how the model performs against the training set and then compare that to how it performs against the validation set. The validation set will give your anticipated real world performance.

Essentially...I'm saying that you can check for overfitting by keeping a validation set separate and comparing against your training set. In order to actually prevent the overfitting you'll have to review your data and do feature selection carefully.

  • $\begingroup$ Thank you for the answer, but i have some questions 1)Sorry but I can't understand when and where i need to oversample my data (validation or training) 2) In Cross-validation Validation set is like test set for Holdout method? $\endgroup$
    – IvanComp
    Commented Jan 4, 2018 at 15:59
  • $\begingroup$ I believe WEKA automatically does everything I've mentioned, but you can check in the help files to make sure. Also: this video seems to explain it well - youtube.com/watch?v=V0eL6MWxY-w $\endgroup$ Commented Jan 4, 2018 at 20:00

For this dataset, I think you should first randomly select, for instance, 20% of your dataset as the test set. Then for the remaining 80% of your dataset, you do the oversampling(SMOTE, etc) first and apply 10 fold cross-validation Fine tune each classifier on this balanced dataset. And use the remaining 20% of your dataset to compare the results from all of your classifiers.

You could check this link for more information: Do we need a test set when using k-fold cross-validation?


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.