0
$\begingroup$

Sorry for maybe a stupid question, but I can't seem to find any explanation of it online. If supervised machine learning only works on labeled datasets - you can't use it to predict a value of unlabelled data after the model is already trained?

And if that is true, how could you possibly use those models in real life scenarios? For example you write and train a classifier to predict the age group of the user, can you in any way use that created model for actual prediction of an unlabelled entry? And if not, what is the point of building this kind of model?

Thank you!

$\endgroup$
1
  • $\begingroup$ Will you give an example of something your trying to predict that does not have a label? labels become feature columns in pandas then they are fed into the classifier as features. If I collect data from devices as a log, each transaction becomes a row in pandas with columns as features. I then must associate the features with an unknown outcome then use that outcome as a prediction. $\endgroup$ Sep 21, 2022 at 15:11

1 Answer 1

1
$\begingroup$

Supervised means that the training stage is supervised and requires labels. It does not mean that you need labels during inference.

Here is small example using a Random Forest classifier with scikit learn (source):

>>> from sklearn.ensemble import RandomForestClassifier
>>> from sklearn.datasets import make_classification
>>> X, y = make_classification(n_samples=1000, n_features=4,
...                            n_informative=2, n_redundant=0,
...                            random_state=0, shuffle=False)
>>> clf = RandomForestClassifier(max_depth=2, random_state=0)
>>> clf.fit(X, y)
RandomForestClassifier(...)
>>> print(clf.predict([[0, 0, 0, 0]]))
[1]

As you can see, training the model takes in labels (clf.fit(X, y) where y are the labels) but during inference the model runs the prediction for an unseen datapoint with no label (print(clf.predict([[0, 0, 0, 0]])) where [[0, 0, 0, 0]] is a a new datapoint which is classified as belonging to class 1).

In contrast, unsupervised ML does not require labels during training. This blog post provides some further explanations and examples.

$\endgroup$

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.