Skip to content

    Supervised vs Unsupervised Learning

    Machine Learning · Beginner

    Definition

    Supervised learning learns from labeled examples; unsupervised learning finds structure in unlabeled data.

    Choosing the right type is the first decision in any ML project.

    Diagram

    Supervised: X + yUnsupervised: X only

    Flowchart

    Check if labels existLabels → classification/regressionNo labels → clustering/reductionFew labels → semi-supervised

    Example: Label check

    data = [{'x': 1, 'y': 0}, {'x': 2}]
    print(['supervised' if 'y' in d else 'unsupervised' for d in data])

    Output: ['supervised', 'unsupervised']

    Key points

    • Classification predicts classes
    • Regression predicts numbers
    • Clustering groups similar points

    Interview questions

    Spam detection is which type?

    Supervised classification, because emails are labeled spam or not.

    More Machine Learning topics