Subset argument while chosing a subset in a Dataframe

https://www.codecademy.com/paths/data-science/tracks/dspath-supervised/modules/dspath-bayes/projects/naive-bayes-project

While working on the Naive Bayes, I came across the subset argument, and don’t understand what it does.
For example-

train_emails = fetch_20newsgroups(categories = ['comp.sys.ibm.pc.hardware','rec.sport.hockey'], subset = 'train')

What does the subset=‘train’ bit do? How will my code be affected if I do not use it?

Sorry about replying with just a link but the quickest route would be to check the docs- https://scikit-learn.org/stable/modules/generated/sklearn.datasets.fetch_20newsgroups.html

Relevant section:
subset ‘train’ or ‘test’, ‘all’, optional
Select the dataset to load: ‘train’ for the training set, ‘test’ for the test set, ‘all’ for both, with shuffled ordering.

1 Like