<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>PatternRecognition | Portfolio</title><link>https://ansangah.github.io/en/tags/patternrecognition/</link><atom:link href="https://ansangah.github.io/en/tags/patternrecognition/index.xml" rel="self" type="application/rss+xml"/><description>PatternRecognition</description><generator>Hugo Blox Builder (https://hugoblox.com)</generator><language>en</language><lastBuildDate>Mon, 20 Oct 2025 00:00:00 +0000</lastBuildDate><image><url>https://ansangah.github.io/media/sharing.png</url><title>PatternRecognition</title><link>https://ansangah.github.io/en/tags/patternrecognition/</link></image><item><title>Machine Learning</title><link>https://ansangah.github.io/en/blog/subjects/ml/</link><pubDate>Mon, 20 Oct 2025 00:00:00 +0000</pubDate><guid>https://ansangah.github.io/en/blog/subjects/ml/</guid><description>&lt;h2 id="1-introduction"&gt;1. Introduction&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Machine learning automatically learns patterns from data to make predictions or decisions.&lt;/li&gt;
&lt;li&gt;Main paradigms: supervised (classification/regression), unsupervised (clustering/dimensionality reduction), reinforcement learning.&lt;/li&gt;
&lt;li&gt;Key challenges: generalisation, data quality, computational efficiency, interpretability.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="2-formalising-inductive-machine-learning"&gt;2. Formalising Inductive Machine Learning&lt;/h2&gt;
&lt;h3 id="21-problem-setup"&gt;2.1 Problem Setup&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Assume input space $\mathcal{X}$, output space $\mathcal{Y}$, and an unknown data distribution $\mathcal{D}$.&lt;/li&gt;
&lt;li&gt;Training set $S={(x_i, y_i)}_{i=1}^{n}$ is drawn i.i.d. from $\mathcal{D}$.&lt;/li&gt;
&lt;li&gt;Goal: pick a hypothesis $h \in \mathcal{H}$ that minimises the &lt;strong&gt;risk&lt;/strong&gt;
$$R(h) = \mathbb{E}_{(x,y)\sim\mathcal{D}}[\ell(h(x), y)]$$
Since $\mathcal{D}$ is unknown, we minimise the &lt;strong&gt;empirical risk&lt;/strong&gt;
$$\hat{R}&lt;em&gt;S(h) = \frac{1}{n}\sum&lt;/em&gt;{i=1}^{n} \ell(h(x_i), y_i)$$
possibly with regularisation (RERM).&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="22-inductive-bias"&gt;2.2 Inductive Bias&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;The No Free Lunch theorem states no learner dominates across all distributions.&lt;/li&gt;
&lt;li&gt;We encode prior knowledge as &lt;strong&gt;bias&lt;/strong&gt; and learn the &lt;strong&gt;weights&lt;/strong&gt; from data.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="3-limits-of-learning-and-generalisation"&gt;3. Limits of Learning and Generalisation&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;VC dimension:&lt;/strong&gt; Measures expressive power of $\mathcal{H}$ and bounds generalisation error.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Bias–variance trade-off:&lt;/strong&gt; Complex models have high variance; simple models incur high bias.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Overfitting:&lt;/strong&gt; Low training error but poor unseen performance. Mitigate with regularisation, early stopping, cross-validation.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;PAC learning:&lt;/strong&gt; Describes when a concept class is learnable—Probably Approximately Correct.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="4-geometry-and-nearest-neighbours"&gt;4. Geometry and Nearest Neighbours&lt;/h2&gt;
&lt;h3 id="41-distance-based-learning"&gt;4.1 Distance-Based Learning&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Represent data points as vectors in high-dimensional space and use a &lt;strong&gt;metric&lt;/strong&gt; to measure similarity.&lt;/li&gt;
&lt;li&gt;$k$-NN classification: majority vote among the $k$ closest labelled neighbours.&lt;/li&gt;
&lt;li&gt;$k$-NN regression: predict the (possibly weighted) average of the neighbours’ targets.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="42-properties"&gt;4.2 Properties&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Virtually zero training cost—just store the data—while inference is heavy.&lt;/li&gt;
&lt;li&gt;Distance metric choice matters: Euclidean, Manhattan, cosine, etc.&lt;/li&gt;
&lt;li&gt;Curse of dimensionality: distances become less informative; use dimensionality reduction or distance weighting.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="43-kernels-and-manifolds"&gt;4.3 Kernels and Manifolds&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Define nonlinear similarities with kernel functions to capture local structure.&lt;/li&gt;
&lt;li&gt;Manifold assumption: high-dimensional data may live on lower-dimensional surfaces—neighbourhood information remains meaningful.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="5-decision-tree-learning"&gt;5. Decision Tree Learning&lt;/h2&gt;
&lt;h3 id="51-structure"&gt;5.1 Structure&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Recursively split the feature space with questions. Leaves output predictions.&lt;/li&gt;
&lt;li&gt;Splitting criteria: information gain, Gini index, chi-squared tests.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="52-training-id3c45cart"&gt;5.2 Training (ID3/C4.5/CART)&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Choose the best attribute to split on.&lt;/li&gt;
&lt;li&gt;Recurse on child nodes.&lt;/li&gt;
&lt;li&gt;Stop when leaves are pure or the sample count hits thresholds.&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;Continuous features use threshold-based binary splits.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="53-pruning"&gt;5.3 Pruning&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Pre-pruning: depth limits, minimum samples per node, etc.&lt;/li&gt;
&lt;li&gt;Post-pruning: build the full tree, then remove branches that raise validation error (e.g., reduced error pruning).&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="54-pros-and-cons"&gt;5.4 Pros and Cons&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Interpretable, no need for feature scaling, handles nonlinearity.&lt;/li&gt;
&lt;li&gt;Sensitive to data splits and prone to overfitting → use ensembles (Random Forest, Gradient Boosting) for robustness.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="6-perceptron"&gt;6. Perceptron&lt;/h2&gt;
&lt;h3 id="61-linear-separator"&gt;6.1 Linear Separator&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Learns weights $w$ and bias $b$ to classify via $\text{sign}(w^\top x + b)$.&lt;/li&gt;
&lt;li&gt;Update rule for misclassified sample $(x,y)$:&lt;br&gt;
$w \leftarrow w + \eta y x$, $b \leftarrow b + \eta y$.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Perceptron convergence theorem:&lt;/strong&gt; If data is linearly separable, convergence occurs in finite steps.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="62-limitations"&gt;6.2 Limitations&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Cannot solve nonlinearly separable problems (e.g., XOR) without kernels or multilayer networks.&lt;/li&gt;
&lt;li&gt;Sensitive to learning rate $\eta$ and sample order.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="7-practical-considerations"&gt;7. Practical Considerations&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Preprocessing:&lt;/strong&gt; Handle missing values and outliers, apply scaling, encode categorical features.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Evaluation:&lt;/strong&gt; Maintain train/validation/test splits; use k-fold CV or time-series CV as appropriate.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Regularisation:&lt;/strong&gt; L1 encourages sparsity; L2 stabilises weights. Dropout, batch normalisation, etc., regulate neural nets.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Hyperparameter search:&lt;/strong&gt; Grid, random, or Bayesian optimisation.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Interpretability:&lt;/strong&gt; SHAP, LIME, and feature importance expose model behaviour.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="8-beyond-binary-classification"&gt;8. Beyond Binary Classification&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Multiclass:&lt;/strong&gt; One-vs-rest, one-vs-one, softmax regression.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Multi-label:&lt;/strong&gt; A sample may belong to multiple classes—use binary relevance, classifier chains, sigmoid outputs.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Regression:&lt;/strong&gt; Predict continuous targets using linear regression, regression trees, Gaussian processes.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Imbalanced data:&lt;/strong&gt; Apply class weighting, SMOTE, or cost-sensitive losses.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Structured outputs:&lt;/strong&gt; Sequence labelling with HMM/CRF, image segmentation with U-Net, etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="9-linear-models"&gt;9. Linear Models&lt;/h2&gt;
&lt;h3 id="91-linear-regression"&gt;9.1 Linear Regression&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Fits $y \approx w^\top x + b$ via ordinary least squares.&lt;/li&gt;
&lt;li&gt;Regularisation: Ridge (L2), Lasso (L1), Elastic Net.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="92-logistic-regression"&gt;9.2 Logistic Regression&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Models binary probability with the sigmoid:
$$P(y=1|x) = \sigma(w^\top x + b) = \frac{1}{1 + e^{-(w^\top x + b)}}$$&lt;/li&gt;
&lt;li&gt;Train by maximising log-likelihood or minimising cross-entropy.&lt;/li&gt;
&lt;li&gt;Decision boundary is linear—extend with kernels or polynomial features for nonlinearity.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="93-softmax-regression"&gt;9.3 Softmax Regression&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;For $K$ classes,&lt;br&gt;
$\mathrm{softmax}(z)_k = \frac{e^{z_k}}{\sum_j e^{z_j}}$.&lt;/li&gt;
&lt;li&gt;Optimise with cross-entropy; works well with stochastic gradient descent.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="94-pros-and-cons"&gt;9.4 Pros and Cons&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Pros: explainable, fast to train, strong with high-dimensional sparse data.&lt;/li&gt;
&lt;li&gt;Cons: limited expressiveness for complex nonlinear relationships—upgrade with kernels or deep networks.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="10-suggested-learning-workflow"&gt;10. Suggested Learning Workflow&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Define the problem and capture domain knowledge.&lt;/li&gt;
&lt;li&gt;Clean and explore the data; engineer informative features.&lt;/li&gt;
&lt;li&gt;Establish baselines with simple models (linear, tree, k-NN).&lt;/li&gt;
&lt;li&gt;Decide on validation strategy and tune hyperparameters.&lt;/li&gt;
&lt;li&gt;Compare models on performance, interpretability, and operational cost.&lt;/li&gt;
&lt;li&gt;Deploy, monitor for drift, and retrain periodically.&lt;/li&gt;
&lt;/ol&gt;</description></item></channel></rss>