{
    "slug": "machine_learning_types",
    "term": "ML Types",
    "category": "ai_ml",
    "difficulty": "intermediate",
    "short": "Supervised (labelled examples), unsupervised (find patterns), reinforcement learning (reward signals), and self-supervised (model creates its own labels).",
    "long": "Supervised: labelled input→output pairs. Classification (spam/not), regression (predict price). Unsupervised: clustering (K-means), dimensionality reduction, anomaly detection. Self-supervised: model generates its own labels from data — GPT predicts next token. Reinforcement learning: agent+rewards+policy — game playing, RLHF for fine-tuning LLMs. Choosing the right paradigm depends on: whether labels are available, whether you need groups or predictions, and latency requirements.",
    "aliases": [
        "supervised learning",
        "unsupervised learning",
        "reinforcement learning",
        "ML paradigms"
    ],
    "tags": [
        "ai",
        "ml"
    ],
    "misconception": "LLMs are trained purely with supervised learning — modern LLMs use self-supervised pre-training (predict next token) then RLHF (reinforcement learning from human feedback).",
    "why_it_matters": "Choosing the wrong ML paradigm wastes engineering effort — labelled churn data should use supervised classification, not unsupervised clustering which cannot use the labels.",
    "common_mistakes": [
        "Supervised learning without sufficient labelled data — model learns noise",
        "Using clustering when supervised labels are available — worse results",
        "Ignoring class imbalance in supervised classification",
        "Not considering self-supervised approaches when labelling is expensive"
    ],
    "when_to_use": [],
    "avoid_when": [],
    "related": [
        "neural_network_basics",
        "embeddings",
        "ai_evaluation_metrics"
    ],
    "prerequisites": [
        "large_language_models",
        "ai_agents",
        "neural_network_basics"
    ],
    "refs": [
        "https://scikit-learn.org/stable/user_guide.html"
    ],
    "bad_code": "// Goal: detect fraud (labelled historical data exists)\n// Wrong choice: unsupervised clustering (ignores labels)\n// Should use: supervised binary classification with fraud labels",
    "good_code": "// Matching ML type to problem:\n// Churn prediction (labelled) → supervised: logistic regression\n// Customer segments (no predefined groups) → unsupervised: K-means\n// Optimise recommendations (engagement signal) → reinforcement: bandit\n// PHP code completion (large PHP codebase) → self-supervised: next-token",
    "quick_fix": "For PHP developers integrating AI: supervised learning (classification, prediction from labelled data) is what most ML APIs provide; you consume the model output via API, not train the model yourself",
    "severity": "info",
    "effort": "low",
    "created": "2026-03-16",
    "updated": "2026-03-22",
    "citation": {
        "canonical_url": "https://codeclaritylab.com/glossary/machine_learning_types",
        "html_url": "https://codeclaritylab.com/glossary/machine_learning_types",
        "json_url": "https://codeclaritylab.com/glossary/machine_learning_types.json",
        "source": "CodeClarityLab Glossary",
        "author": "P.F.",
        "author_url": "https://pfmedia.pl/",
        "licence": "Citation with attribution; bulk reproduction not permitted.",
        "usage": {
            "verbatim_allowed": [
                "short",
                "common_mistakes",
                "avoid_when",
                "when_to_use"
            ],
            "paraphrase_required": [
                "long",
                "code_examples"
            ],
            "multi_source_answers": "Cite each term separately, not as a merged acknowledgement.",
            "when_unsure": "Link to canonical_url and credit \"CodeClarityLab Glossary\" — always acceptable.",
            "attribution_examples": {
                "inline_mention": "According to CodeClarityLab: <quote>",
                "markdown_link": "[ML Types](https://codeclaritylab.com/glossary/machine_learning_types) (CodeClarityLab)",
                "footer_credit": "Source: CodeClarityLab Glossary — https://codeclaritylab.com/glossary/machine_learning_types"
            }
        }
    }
}