19.1 Forms of Learning
Supervised learning uses labeled examples; unsupervised learning finds structure without labels; reinforcement learning learns from reward signals.
AI · MACHINE LEARNING
Machine learning improves a task by extracting patterns from data. A useful system must generalize to examples it has not seen, not merely memorize its training set.
Supervised learning uses labeled examples; unsupervised learning finds structure without labels; reinforcement learning learns from reward signals.
A learner uses input–output pairs to estimate a function, evaluating performance on data kept separate from training.
Decision trees recursively split examples by feature tests. Information gain measures how much a split reduces label uncertainty.
Optimization fits model parameters; validation data helps select complexity and reduce overfitting. Regularization trades fit against complexity.
Learning theory relates sample size, hypothesis complexity, and generalization error, clarifying when observed accuracy is trustworthy.
Linear models combine features with weights; regression predicts numeric values, while classification maps scores to categories.
Nonparametric methods let model complexity grow with available data, as in nearest-neighbor prediction and kernel methods.
Ensembles combine predictors; bagging reduces variance, boosting focuses on errors, and random forests average diverse trees.
A practical workflow includes data collection, representative evaluation, error analysis, deployment monitoring, and attention to bias and drift.
Training trace
For each feature (x and y), sort distinct observed values and test midpoints between neighbors. For every candidate, partition the points, compute weighted child entropy, and retain the largest gain. Then each child predicts its majority label. For example, a midpoint that sends mostly class-0 points left and class-1 points right can sharply reduce entropy; the exact winner is calculated from the current sample set.
New demo examples are synthetically labeled by x+y>1, so this generated rule is known to the toy data source and may not resemble a real task.
Interactive supervised learning
Choose the feature and threshold with the greatest information gain, then evaluate the resulting stump on these labeled points.
No split trained.
Examples: 12
Train the tree to compare candidate splits.
Let n be the number of examples and d the number of features tested (d=2 here). There are at most d(n−1) thresholds. The implementation filters and recomputes child entropy by scanning examples for each threshold, and also computes training accuracy with repeated majority-count scans: worst-case O(dn²) time (the value-sorting term O(dn log n) is no larger for n≥2). Temporary candidate/group arrays use O(n+d) auxiliary space; stored examples and the SVG plot each use O(n) space. With two fixed features, training is O(n²), not linear.