2
$\begingroup$

I am currently learning machine learning via this book "Hands-On Machine Learning with Sci-kit learn and Tensorflow" by Aurelien Geron.

In page 76 and 77, the author talks about using stratified sampling so that your test set would be more representative of the whole data. I didn't really understand the point of this since it would not affect the accuracy of your training model ? or how would selecting better test sets affect the accuracy of your training model ?

$\endgroup$

1 Answer 1

3
$\begingroup$

When the distribution of your data is balanced or you have enough samples of each class, a normal shuffle split will work well. But if your data distribution is unbalanced and one of the classes is in minority, you do stratified sampling so as to ensure that your train and test splits represent the true nature of your data. For more details take a look here.

$\endgroup$
2
  • $\begingroup$ Let's say if the minority data point isn't present in your training data, then it could cause the machine learning model to not predict similar test data as accurately as well ? Hence it is important to ensure that minority classes are represented in the training data. But why do you need them represented in test data as well if thats the case ? $\endgroup$
    – calveeen
    Feb 6, 2019 at 4:21
  • 1
    $\begingroup$ You use the test data to check the accuracy of your model. If you do not have any minority classes and if tour model predicts all the majority classes correctly you will have 100% accuracy which gives you a wrong impression of the model and may not be true. Hence, it is necessary to have the minority classes in test set also. $\endgroup$
    – bkshi
    Feb 6, 2019 at 5:23

Your Answer

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

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