Source
Adapted from my own handwritten and hand-typed notes from Year 1 to Year 3 of my EEE degree
Machine learning asks: what hints does the data give, can we learn from them, and can we test how well we learned?
Two Families
| Supervised learning | Unsupervised learning | |
|---|---|---|
| Data | each training point has a known label (answer) | no labels |
| Goal | learn a mapping from variables to the label, then predict for new points | find structure hidden in the data |
| Tasks | regression (numeric label), classification (class label) | clustering, anomaly detection |
| Pokemon example | predict Total from HP; predict Legendary from Total | group Pokemon by stats; find Pokemon unlike the rest |
Supervised Workflow
Three steps:
- given: some Pokemon with known labels to train on
- learn: the model, e.g. or
- predict: estimate the label for other Pokemon
Unsupervised Workflow
Three steps for clustering:
- given: a distance between all Pokemon
- find: the optimal groups in the data
- justify: an interpretation of what each group means
Train and Test Split
To check how well a model generalises, the data is split. The model only sees the train set, and its quality is judged on the unseen test set.
from sklearn.model_selection import train_test_split
X = pd.DataFrame(pkmndata['HP'])
y = pd.DataFrame(pkmndata['Total'])
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25)
# 600 train rows, 200 test rowsThe simplest supervised model is Univariate Linear Regression.