Machine Learning

0.0(0)
Studied by 1 person
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/152

encourage image

There's no tags or description

Looks like no tags are added yet.

153 Terms

1
New cards

Machine learning (definition)

The science of programming computers so they learn from data instead of following hand-written rules.

2
New cards

Arthur Samuel's definition of ML (1959)

A field of study that gives computers the ability to learn without being explicitly programmed.

3
New cards

Herbert Simon's definition of learning (1983)

Any change in a system that lets it perform better the second time on the same task, or on another task from the same population.

4
New cards

Tom Mitchell's definition of ML (1997)

A program learns from experience E with respect to tasks T and performance measure P if its performance on T, measured by P, improves with E.

5
New cards

Mitchell's E, T, P for a spam filter

E = labeled emails; T = flag spam; P = fraction of emails correctly classified.

6
New cards

AI vs. ML vs. deep learning

AI (machines mimicking human intelligence) contains ML (learning from data), which contains deep learning (many-layer neural networks).

7
New cards

Traditional programming vs. ML

Traditional: data + program → output. ML: data + output → program.

8
New cards

4 reasons to use ML

1) Problems needing long rule lists or constant fine-tuning; 2) fluctuating environments (retrain on new data); 3) insight into complex problems and big data; 4) problems with no good traditional solution.

9
New cards

Classic ML tasks

Pattern recognition (faces, speech, handwriting), pattern generation (image synthesis), anomaly detection (fraud), prediction (stocks, ECG, weather).

10
New cards

Collaborative vs. content-based recommender

Collaborative: recommends what similar users liked. Content-based: recommends items similar to what this user liked.

11
New cards

Forms of knowledge a learner acquires

Facts, patterns, concepts (generalized classes), rules (P → Q), models (abstract representations like v = d/t), skills.

12
New cards

Why ML is 'ill-posed'

We only see a limited sample of the world, so many models fit the data; the goal is one that generalizes beyond the dataset and ignores noise.

13
New cards

Occam's razor vs. Einstein (model simplicity)

Occam: the simplest explanation tends to be right (upper bound on complexity). Einstein: as simple as possible, but not simpler (lower bound).

14
New cards

Underfitting

Model too simple; high bias; misses patterns; does poorly on both training and test data. (The student who doesn't pay attention.)

15
New cards

Overfitting

Model too complex; high variance; memorizes noise; great on training data, poor on new data. (The student who memorizes: ~98% quiz, fails new exam questions.)

16
New cards

Best fit

Model that learns the real pattern and generalizes: good on training and test data. (The student who learns the concepts.)

17
New cards

Inductive bias

The set of assumptions an algorithm uses to choose a model; without it a learner could only memorize the training set.

18
New cards

Restriction bias

Inductive bias that limits which models the algorithm will consider at all.

19
New cards

Preference bias

Inductive bias that makes the algorithm prefer some models over others.

20
New cards

3 criteria for classifying ML systems

1) Type of supervision; 2) online vs. batch (can it learn incrementally?); 3) instance-based vs. model-based. The criteria are not exclusive.

21
New cards

Instance-based vs. model-based learning

Instance-based: compares new points to stored known points. Model-based: detects patterns and builds a predictive model.

22
New cards

Instance

One row (one example) in a dataset.

23
New cards

Features / feature vector

The input attributes (columns) used to make a prediction.

24
New cards

Label / class

The output value the model predicts in supervised learning.

25
New cards

Supervised learning

Learning a function f: X → Y from labeled training data (the learning process is called training).

26
New cards

Regression

Supervised task predicting a continuous value (e.g., tomorrow's temperature = 85°F); find the best-fit function.

27
New cards

Classification

Supervised task predicting a discrete category (e.g., hot or cold); find the decision boundary that separates the classes.

28
New cards

Multi-class classification

Many possible classes, but each instance belongs to exactly one.

29
New cards

Multi-label classification

Each instance can have several non-exclusive labels at once (e.g., Dog = True, Cat = True, Bird = False).

30
New cards

Discretization (binning)

Converting numerical values to categories: equal-width intervals, equal-frequency intervals, or custom thresholds.

31
New cards

Equal-width vs. equal-frequency binning

Equal-width: every bin covers the same range of values. Equal-frequency: every bin holds roughly the same number of items.

32
New cards

Unsupervised learning

Learning from unlabeled data: clustering, association rule mining, feature selection. If labels exist, supervised learning is better.

33
New cards

Clustering

Unsupervised grouping of instances with similar properties (partitional, hierarchical, density-based, model-based).

34
New cards

Outlier analysis

Unsupervised task looking for points that don't fit any cluster (e.g., fraud detection).

35
New cards

Association rule mining

Finding rules X → Y that predict an item from other items in a transaction (e.g., {Bread, Milk} → {Diaper}); algorithms: Apriori, FP-growth.

36
New cards

Support (association rules)

Fraction of all transactions that contain X ∪ Y. Example: {Bread, Milk, Diaper} in 2 of 5 transactions → 0.4.

37
New cards

Confidence (association rules)

count(X ∪ Y) / count(X): how often Y appears when X does. Example: {Bread, Milk} → {Diaper} = 2/3 = 0.67.

38
New cards

Feature selection

Choosing the most useful input attributes; methods: correlation/covariance matrix, information gain, Fisher's LDA, PCA.

39
New cards

Semi-supervised learning (weak supervision)

Uses a small labeled set plus a large unlabeled set, because labels are expensive and unlabeled data is cheap.

40
New cards

Requirement for semi-supervised learning

The unlabeled data must be relevant to the task: p(x) must carry information about p(y|x).

41
New cards

Self-training (pseudo-labeling)

Train on labeled data → label the unlabeled data with that model → add the most confident pseudo-labels → retrain.

42
New cards

Unsupervised pre-processing (semi-supervised)

Learn a representation from unlabeled data (often with an autoencoder); the final model trains only on the human-labeled points.

43
New cards

Cluster-then-label

Semi-supervised method: an unlabeled point gets the majority label of its cluster.

44
New cards

Active learning

A transductive method that picks which unlabeled samples would be most useful to label by hand.

45
New cards

Self-supervised learning

Generates its own labels from unlabeled data using a pretext task; no human labels needed.

46
New cards

Pretext task

A task built from the data itself to learn representations, e.g., predict a masked word, image completion, rotation prediction, jigsaw puzzles, colorization.

47
New cards

Self-supervised vs. semi-supervised

Semi-supervised uses a small human-labeled set plus unlabeled data; self-supervised creates its supervision from unlabeled data alone.

48
New cards

Self-supervised vs. unsupervised

Both use unlabeled data; unsupervised discovers structure, self-supervised sets up a specific prediction task.

49
New cards

Reinforcement learning

An agent takes actions, receives rewards, and learns a policy that maximizes long-term reward. Training data is optional.

50
New cards

Exploration vs. exploitation

Exploration: trying new actions. Exploitation: favoring actions that have paid off. RL balances both.

51
New cards

Model-based vs. model-free RL

Model-based: dynamic programming on the Bellman equations (policy iteration, value iteration). Model-free: Monte Carlo, temporal difference, SARSA, Q-learning, DQN.

52
New cards

Is RL supervised or unsupervised?

Neither, but both: rewards guide it like supervision, but no explicit goals or labels are given (learned by trial and error).

53
New cards

Deep learning

A technique (many-layer neural networks), NOT a learning paradigm; it can be used inside supervised, unsupervised or RL.

54
New cards

Deep learning vs. traditional ML

DL learns features automatically but needs more data and compute (GPUs) and is harder to interpret; traditional ML often needs manual feature engineering but works with less data.

55
New cards

Transfer learning

Adapting a model trained on one task to a related task (e.g., VGG, ResNet, BERT, GPT). It's about where the model starts.

56
New cards

Batch vs. online learning

Batch: trains once on the whole dataset. Online: updates incrementally as data arrives (big or streaming data). It's about how the model updates.

57
New cards

Is transfer learning a type of online learning?

No. Transfer is about the starting point; online is about updating. A transfer-learning model can use batch or online learning.

58
New cards

Ensemble learning

Combining multiple models for better predictions (e.g., random forests, Bayes optimal classifier); costs: model compatibility and computing resources.

59
New cards

Typical ML project steps

Big picture → get data → explore & visualize → prepare data → select & train model → fine-tune → present → launch, monitor, maintain.

60
New cards

Big-picture questions

What is the objective (it decides the performance measure; the model isn't the goal)? What does the current solution look like (the baseline)?

61
New cards

pandas Series vs. DataFrame

Series: one column. DataFrame: a 2-D table made of Series.

62
New cards

Exploratory data analysis (EDA)

Data-driven, visual first look at the data: univariate (1 variable), bivariate (2), multivariate (3+).

63
New cards

Why do EDA only on the training set?

To avoid data snooping bias: looking at test data leaks information into your modeling choices.

64
New cards

Handling missing values

Count NA/nulls (watch for fake values like 0 or −1), then drop rows/columns or impute (mean or median).

65
New cards

Numerical vs. categorical variables

Numerical: natural order, can average (continuous/discrete). Categorical: no natural order, can't average (nominal/ordinal).

66
New cards

Ordinal (label) encoding

Assign one integer per category (Green = 1, Red = 2, Black = 3). Implies an order, so it suits ordinal data like class standing.

67
New cards

One-hot encoding

One new 0/1 column per category. No false order, but creates a sparse matrix with many columns.

68
New cards

Encode Standing = Freshman, Junior, Freshman, Senior

Ordinal (natural order): 0, 2, 0, 3. One-hot: Freshman [1,0,1,0], Junior [0,1,0,0], Senior [0,0,0,1].

69
New cards

Why feature scaling?

Features on very different scales (age 18–80 vs. income $20k–$200k) bias models toward large-unit features; SVMs and gradient descent are especially sensitive.

70
New cards

Min-max scaling (normalization)

x' = (x − min) / (max − min), mapping to [0, 1]. Highly sensitive to outliers.

71
New cards

Min-max scaling to any range [a, b]

x_norm = (x − x_min) / (x_max − x_min) × (b − a) + a; e.g., [−1, 1] with MinMaxScaler(feature_range=(-1, 1)).

72
New cards

Standardization (z-score)

z = (x − μ) / σ: mean 0, standard deviation 1. Range is unbounded; less affected by outliers. StandardScaler().

73
New cards

Custom transformers

Apply a function such as log or sqrt (FunctionTransformer(np.log)) or combine features, e.g., rooms_per_house = total_rooms / households.

74
New cards

Typical train/test split

80% training, 20% testing. Training set as large as possible; test set representative.

75
New cards

Danger of using the first 80% of rows for training

If the data is sorted, the test set won't look like the training set.

76
New cards

Random sampling

Every row has an equal chance of selection; doesn't guarantee the test set keeps the full data's proportions. train_test_split(data, test_size=0.2, random_state=42).

77
New cards

Stratified sampling

Divide into homogeneous subgroups (strata) first so the test set keeps the same proportions of an important column. stratify=data['col'].

78
New cards

k-fold cross-validation

Split training data into k folds; train on k−1 and validate on the remaining one, rotating k times and averaging. cross_val_score(model, X, y, cv=5).

79
New cards

Validation set

Split data into train / validation / test: tune hyperparameters on validation, retrain the best model on all training data, then use the test set once.

80
New cards

Hyperparameter

A setting of the training algorithm or preprocessing that the model does not learn itself (e.g., C, α, learning rate, polynomial degree).

81
New cards

Why evaluate models?

To compare models quantitatively on the same data and to find good hyperparameter values.

82
New cards

True/False and Positive/Negative in a confusion matrix

True/False: did the prediction match the truth? Positive/Negative: what did the model predict?

83
New cards

Confusion matrix

Table of actual vs. predicted: TP, FN (actual positives), FP, TN (actual negatives). Also called a contingency table.

84
New cards

False positive (FP)

Actually negative, predicted positive: a false alarm.

85
New cards

False negative (FN)

Actually positive, predicted negative: a miss.

86
New cards

Accuracy

(TP + TN) / All: the fraction classified correctly.

87
New cards

Error rate

(FP + FN) / All = 1 − accuracy.

88
New cards

Class imbalance problem

When one class is rare, accuracy is misleading: if 5% are positive, always predicting negative is 95% accurate and useless.

89
New cards

Precision

TP / (TP + FP). Exactness: of everything predicted positive, how much really is positive?

90
New cards

Recall

TP / (TP + FN) = TP / P. Completeness: of all actual positives, how many did the model catch? Same as sensitivity and TPR.

91
New cards

Sensitivity

True positive rate = TP / (TP + FN). The same thing as recall.

92
New cards

Specificity

True negative rate = TN / (TN + FP) = TN / N: of all actual negatives, how many were correctly identified?

93
New cards

False positive rate (FPR)

FP / (FP + TN) = 1 − specificity: the fraction of negatives wrongly flagged as positive.

94
New cards

F1 score

2 × precision × recall / (precision + recall): the harmonic mean; high only when both are high. Use when FP and FN both matter.

95
New cards

Precision/recall trade-off

Raising the decision threshold increases precision and lowers recall; lowering it does the opposite.

96
New cards

Precision-recall curve

Plots precision and recall against the decision threshold.

97
New cards

ROC curve

Plots true positive rate (recall) against false positive rate across thresholds. Good classifiers hug the upper-left; random ones lie on the diagonal.

98
New cards

AUC

Area under the ROC curve: 1.0 = perfect, 0.5 = random guessing. Used to compare classifiers.

99
New cards

One-versus-All (OvA / One-vs-Rest)

Multiclass strategy: one binary classifier per class, each class vs. all others. N classes → N classifiers.

100
New cards

One-versus-One (OvO)

Multiclass strategy: one classifier per pair of classes. N classes → N(N−1)/2 classifiers.