Machine Learning Midterm 2

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

1/70

encourage image

There's no tags or description

Looks like no tags are added yet.

71 Terms

1
New cards

Neural Networks Big Picture

Flexible Approximators

  • nonlinear mapping from input vectors to targets

High-Dimensional Power

  • state of the art accuracy for complex data like images, language, sensors


2
New cards

Neural Networks Architecture

Weighted Sum

  • computes bias plus weighted input sum

Activation Function

  • introduces non-linearity via ReLU, sigmoid, tanh

Parallel Layers

  • Stacked units composing hierarchical feature representations


3
New cards

Neural Network Output Layers

Regression

  • linear output for continuous target variables

Binary Classification

  • Sigmoid output predicting probability

Multiclass

  • Softmax output distribution across multiple classes


4
New cards

Forward Pass

Data flows forward through linear combinations and activations to generate predictions

5
New cards

Gradient Descent

Minimizes loss functions by nudging weights downhill via chain rule

6
New cards

Neural Network Overfitting Measures

Weight Decay

  • penalize large weights for smoother functions

Dropout

  • Randomly drop units during training

Early Stopping

  • halt training when validation loss plateaus


7
New cards

Neural Network Pros and Cons

Pros

  • High accuracy for nonlinear data

  • flexible feature interactions

  • supports regression and classification

Cons

  • minimal interpretability

  • computationally intensive training

  • prone to overfitting without tuning


8
New cards

Why Cross Validation

Training Error Bias

  • training error underestimates true out of sample error

External Benchmark

  • Independent test sets are rare, resampling techniques simulate true out of sample evaluation

Model Evaluation

  • reliably compare hyperparameters and architectures without overfitting and training data


9
New cards

Bias-Variance Tradeoff

Bias and Variance are inversely related

You have to try and find the point that jointly minimizes the two

10
New cards

CV Resampling Tools

  • Validation Split

  • K-Fold CV

  • Repeated K-Fold



11
New cards

Validation Split

Random train/validation split set by the computer

  • Pros

    • fastest and simplest method

  • Cons

    • High variance estimate


12
New cards

K-Fold CV

Partitions the data into K number of folds. The standard is a 5- or 10-fold model

This is the optimal bias-variance tradeoff

13
New cards

Repeated K-Fold

Run K-fold multiple times with different partitions

Reduces the estimate variability

14
New cards

Stratified K-fold

Preserves class proportions across every fold

Vital for imbalanced data and prevents empty positive classes in folds

15
New cards

Group-Aware CV

Keeps entity groups in single folds (patients, customers)

Prevents data leakage from correlated rows

16
New cards

Time-Series CV

Respects temporal order: train on past, validate on future

17
New cards

Spatiotemporal CV

Validation folds defined by geographic blocks

18
New cards

Grid Search Problem Solving

Optimistic Bias

  • Training error is optimistic: a single validation split is noisy and unreliable

Variance Reduction

  • K-fold CV averages across folds while grid search ensures systematic comparison


19
New cards

End-to-End Tuning Process of Grid Search

Define Metric

  • align metric with real business objectives

Choose CV

  • match scheme to data-generating process

Specify Grid

  • select meaningful log spaced parameter values

Evaluate

  • run CV, rank models, and test on holdout data


20
New cards

Choosing CV Design

Standard K-Fold

  • 5 or 10 are robust defaults, repeated CV stabilizes small datasets

Stratified CV

  • Preserves class proportions; keeps rare classes present and reduces variance

Group and Time Series

  • Group K-fold prevents leakage; time-series validates future on past


21
New cards

Grid Metrics

knowt flashcard image
22
New cards

Avoiding Optimistic Bias

Using the same CV scores for choosing hyperparameters and final performance introduces mild selection bias

23
New cards

Real-World ML Sequential Processing

Multi-Stage Workflows

  • Models rarely work directly on raw data, there often has to be some sort of transformation

Data Leakage Defense

  • Preprocessing before validation leaks test fold statistics, producing overly optimistic results

Unified Parameter Tuning

  • GridSearchCV can simultaneously optimize preprocessing steps and model hyperparameters


24
New cards

pipe.fit(x,y)

Calls fit.transform() sequentially through intermediate steps, passing modified data forward

25
New cards

pipe.predict()

Transforms test data using fitted transformers before executing predictions with the final estimator

26
New cards

Double Underscores

Use stepname__parameter syntax to assign parameters to specific pipeline steps

<p>Use stepname__parameter syntax to assign parameters to specific pipeline steps</p>
27
New cards

make_pipeline utility

Automatically generates step names based on lowercased class names

28
New cards

Duplicate Step Classes

Appends numbers sequentially when class types repeat

29
New cards

named_steps

Dictionary mapping of stepnames to fitted estimator objects

30
New cards

best_estimator

Returns the full optimal pipeline instance from GridSearch

31
New cards

What is Unsupervised Learning

Extracting structural patterns and hidden representations directly from features, without relying on target labels

32
New cards

4 Primary Unsupervised Task Families

Clustering

Dimensionality Reduction

Density and Anomalies

Association Rules

33
New cards

Clustering Quality Metrics

Within Cluster SSE

  • measures internal cluster compactness

  • Monotonically decreases as k grows

  • use elbow method to select optimal k

Silhouette Coefficient

  • a_i = Mean distance to same cluster instances

  • b_i mean distance to nearest neighbor cluster

  • Range [-1,1] = Higher values signal well-separated bounds


34
New cards

Dimensionality and Association Metrics

PCA Explained Variance

  • 90%+ is the target threshold

Association Lift

  • >1 indicates positive feature dependence, it means we have increased the value

  • =1 indicates there is a random chance of cooccurrence


35
New cards

Unsupervised Learning Workflow

Scale Features

Handle Outliers

Encode

Deduplicate

36
New cards

Validation/Robustness Checks for Unsupervised Learning

Seed Stability

  • rerun models across initializations, structure should remain persistent

Sensitivity Analysis

  • test sensitivity to metric selection

Downstream Utility

  • verify downstream performance gains when feeding supervised pipelines


37
New cards

Unsupervised Learning Pitfalls

Over-Interpretation

  • Clusters are hypotheses, not ground truth

Curse of Dimensionality

  • Distance metrics lose contrast in high-dimensional spaces

  • reduce dimensionality prior to clustering

Pipeline Data Leakage

  • fit unsupervised transformers on training splits only before transformation


38
New cards

What is Principal Component Analysis (PCA)

Data compression via rotation. Re-express high dimensional data into new, orgothonal, uncorrelated axes ordered by total variance explained

  • PC1 - Direction of maximum variance

  • PC2 - Maximizes remaining variance subject to zero correlation with PC1



39
New cards

Key Benefits of PCA

Dimensionality Reduction

  • Faster model training and lower computational overhead

Multicollinearity Relief

  • Removes correlation between colinear predictors completely

Noise Reduction

  • Drops trailing components capturing high-frequency noise

Data Visualization

  • Projects complex data on 2D/3D maps to spot clusters


40
New cards

PCA Fitting Process

Standardize and Center

  • Subtract mean and scale to unit variance before decomposition

Find Directions

  • Eigen decomposition of covariance matrix of SVD of data matrix

Project Data

  • Project centered data onto top K directions to get Z scores


41
New cards

PCA Formula

knowt flashcard image
42
New cards

Choosing Number of Components for PCA

Cumulative Explained Variance

  • Target 90% of the variance as your threshold and choose the smallest K that achieves it

Scree / Elbow Plot

  • Plot explained variance v component index. Find the point the slope decreases sharply

Cross Validation

  • Treat k as a hyperparameter, optimize k directly against downstream task metric


43
New cards

K-Means Clustering

Core Objective

  • partitions observations into k distinct clusters by minimizing within cluster squared distance to learned centroids


44
New cards

K-Means Clustering Optimal Applications

Compact spherical grouping, behavioral segmentation, vector quantization, and automated feature engineering

45
New cards

K-Means Clustering Limitations

Fails on non-spherical clusters, varying density, and non-numeric categorical data lacking distance metrics

46
New cards

Lloyd’s Optimization Method

Initialization

  • Select k initial centroids randomly or via k-means seeding scheme

Assignment

  • assign each observation to its closest centroid

Update Step

  • recompute centroid as the arithmetic mean of assigned points

Convergence

  • Repeat steps 2-3 until assignments freeze or J drops below tolerance


47
New cards

K-Means Clustering Data Prep

Feature Scaling

  • variables with large variance distort distance metrics, must standardize data

Outlier Handling

  • Extreme observations drag centroids away from dense regions

PCA Pre-Processing

  • High dimensions dilute dimensions

  • retain 90% variance via PCA before clustering


48
New cards

K-Means++

Seeds centroid distance from each other using probability distribution proportional to squared distance

49
New cards

Mini-Batch K-Means

Uses random subsamples per iteration

Significantly accelerates convergence on massive datasets with minimal metric loss

50
New cards

Spherical K-Means

Normalizes feature vectors to unit length and replaces Euclidean distance with cosine similarity

Tailored for text vectors

51
New cards

K-Means Metrics

Inertia

  • Internal variance sum, the lower the better

Calinski-Harabasz Index

  • Ration of between to within dispersion, the higher the better

Davies-Bouldin Index

  • Average similarity between clusters, the lower the better


52
New cards

K-Means Clustering Pitfalls

Spherical Assumption

Complex Shape failure

Outlier Sensitivity

Fixed k Required

53
New cards

Agglomerative Hierarchical Clustering

Bottom Up Merge

  • start with every observation as its own cluster

Iterative Pair Linkage

  • Recursively merge the two closest clusters based on distance metric

Dendrogram Cut

  • Slice the tree horizontally at desired height to yield target cluster count


54
New cards

Types of Linkage Criteria

Single

  • Minimum distance

  • Good for elongated shapes, prone to chaining

Complete

  • Maximum Distance

  • Yields compact, equal sized clusters

Average

  • Mean Pairwise

  • Balances single and complete

Ward’s

  • Minimum SSE

  • Minimizes withing cluster variance growth, similar output to k-means


55
New cards

DBSCAN Core Concept

Eps Neighborhood

  • Maximum neighborhood search distance around any given data point

Core Point Condition

  • Minimum points required within eps radius to form a dense region


56
New cards

Core Point

Has minimum number of samples inside its eps neighborhood

57
New cards

Border Point

Within epsilon of a core point, but lacks enough neighbors itself

58
New cards

Noise Point

Does not meet any criteria, explicitly filtered out as an outlier

59
New cards

min_samples rule of thumb

set it equal to Dimensionality +1

Use larger values for noisy data or high dimensions to enforce higher core density

60
New cards

Unsupervised Method Comparison to Remember

knowt flashcard image
61
New cards

What is Text Mining

Core Transformation

  • Unstructured text to Structured representations for algorithms

Scalable Reading

  • Automates document reading to detect emerging patterns, risks, and sentiment at scale

Business Impact

  • Powers intelligent routing, risk scoring, QA automation, and product designs


62
New cards

Text Mining Workflow

Collect Text

Preprocess

Represent

Analyze

Evaluate

63
New cards

Text Mining Preprocessing

Normalization

  • Lowercasing, stripping URLs, emojis, and boilerplate text

  • the purpose is to make it all look the same

Tokenization

  • Splitting raw text into terms or character n-grams

Stopwords

  • Reducing word variants to dictionary root forms

  • ex) Running to run

Guardrail

  • Avoid over-cleaning that destroys critical signals


64
New cards

Feature Engineering Choices

Term-Based (TBM)

  • Simple word counts and TF-IDF weighting

Phrase-Based (PBM)

  • Multiword n-grams for localized text

Concept-Based (CBM)

  • Linguistic POS tags and domain ontologies

Pattern Taxonomy (PTM)

  • Frequent sequential rules and hierarchical trees


65
New cards

Core Text Analysis Tasks Chart to remember

knowt flashcard image
66
New cards

Information Extraction (IE)

The goal is to convert raw text into structures schema records

Extracts: entities, attributes, relations

Use Cases: Contract analytics, KYC, clinical notes

Evaluations: Precision, recall, entity-level F1

67
New cards

Information Retrieval (IR)


The goal is to retrieve matching documents for user intent

The model ranks: corpus documents based on relevance metrics

Use Cases: Search bars, knowledge bases, help desks

Evaluations: Precision at k, MAP, nDCG

68
New cards

Supervised Categorization

Assigns predefined labels

Logistic regression and linear SVM

Handles high sparsity and dimensionality well

69
New cards

Unsupervised Clustering

Discovers latent themes without existing labels

Uses algorithms: K-Means, Agglomerative, DBSCAN, LDA

Key Metrics: Silhouette Score, cluster stability

70
New cards

Feature Engineering Trade Offs

knowt flashcard image
71
New cards

Text Method Selection Examples


<p></p>