














Studia grazie alle numerose risorse presenti su Docsity
Guadagna punti aiutando altri studenti oppure acquistali con un piano Premium
Questa pagina non è visibile nell’anteprima
Non perderti parti importanti!















Author Marc'Antonio Lopez AI & Data Analytics student at Polytechnic University of Turin
This document provides a comprehensive overview of the fundamental concepts, typical tasks, and different learning paradigms within the fields of Machine Learning (ML) and Pattern Recognition (PR).
Pattern Recognition (PR) is the automated process of identifying meaningful patterns and structures within data using various algorithms. Its core objective is to leverage these identified patterns to make informed decisions or initiate specific actions. PR is most commonly applied to tasks such as data classification.
Machine Learning (ML) is a field dedicated to equipping computer systems with the ability to learn from data. A widely cited definition by T. M. Mitchell provides a clear understanding of what it means for a computer program to "learn":
A computer program is said to learn from experience ( ) with respect to some class of tasks ( ) and performance measure ( ), if its performance at tasks in , as measured by , improves with experience.
The relationship between Pattern Recognition and Machine Learning is foundational: Pattern Recognition is a primary application area of Machine Learning. Machine Learning provides the powerful algorithms and techniques that enable the identification of patterns and the execution of PR tasks such as classification and prediction. In essence, ML is the engine that drives PR.
Defining Models for Learning
To uncover complex patterns and structures hidden within data, the models we use must be adaptive. Unlike systems based on rigid, predefined rules, Machine Learning models are designed to:
Adjust Internal Settings: They modify their internal parameters or structure. Use Observed Data (Experience ): This adjustment is driven by the data they observe and process. Improve Performance ( ): The ultimate goal is to enhance their effectiveness. On Specific Tasks ( ): This improvement is measured against clearly defined tasks.
This adaptability allows ML models to learn from examples rather than being explicitly programmed for every possible scenario.
Common Machine Learning Tasks
Machine Learning encompasses several fundamental tasks, each designed to solve different types of problems:
Classification
Definition: Classification is the task of assigning a given data sample to one of several predefined, discrete categories or classes.
Input: The model receives an input vector (also known as a feature vector ), typically denoted as. This vector contains numerical representations of the attributes or characteristics of the data sample. Output: The model produces a discrete class label , denoted as. This label is chosen from a finite set of possible categories, for example,. Goal: The objective is to learn a mapping function, , that transforms the input vector into an accurate predicted class label. This function can be represented as:
. The function should generalize well to correctly classify unseen inputs. Applications: Image recognition: Classifying an image as containing a "cat" or a "dog." Face identification: Determining if a face belongs to a known individual. Spam detection: Labeling an email as "spam" or "not spam." Medical diagnosis: Classifying a patient's condition based on symptoms and test results. Example of Classification: A classic example is classifying different species of Iris flowers (e.g., Setosa, Versicolor, Virginica) based on their petal and sepal measurements.
1D data) or contours (for 2D data) that encapsulate the data points.
Supervised vs. Unsupervised Learning: Learning
Paradigms
Machine Learning algorithms are broadly categorized into different learning paradigms based on the nature of the training data they receive, or more precisely, the "experience" ( ) they learn from.
Supervised Learning
Definition: Supervised learning algorithms are trained on datasets that consist of input-output pairs. For each input data sample , there is a corresponding known, desired output , which acts as a "label" or "target." Goal: The primary goal is to learn a function that can accurately map new, unseen inputs to their correct outputs. The emphasis is on the model's ability to generalize from the training examples to make correct predictions on new data. Common Tasks: The most common tasks addressed by supervised learning are Classification (where the output is discrete) and Regression (where the output is continuous). Analogy: This paradigm is often compared to a student learning with a "teacher" who provides correct answers or feedback for every practice problem.
Compare
Feedback/Error
Input Data (x) Supervised Model Correct Labels (y)
Predicted Output (y_hat)
Explanation of Supervised Learning Diagram:
Unsupervised Learning
Definition: Unsupervised learning algorithms are provided only with input data , without any corresponding output labels or "correct answers." The model must find patterns on its own. Goal: The primary goal is to discover intrinsic structures, hidden patterns, underlying relationships, or meaningful representations directly within the input data. The model tries to make sense of the data without explicit guidance. Common Tasks: Clustering: Grouping similar data points together. Density Estimation: Modeling the probability distribution of the data. Dimensionality Reduction: Reducing the number of features while retaining important information (e.g., Principal Component Analysis - PCA). Feature Learning: Automatically discovering useful transformations of the raw data. Analogy: This paradigm is like learning by pure observation, where a student tries to categorize or understand concepts without any explicit teaching or labels.
Input Data (x) Unsupervised Model (^) Structure/Pattern/RepresentationDiscovered
Explanation of Unsupervised Learning Diagram:
Relationship Between Learning Paradigms
Preprocessing Role: Unsupervised learning methods (such as dimensionality reduction or feature extraction) are frequently used to preprocess data. This prepared data is then fed into supervised learning algorithms, which can enhance the performance of classifiers or regressors by reducing noise, handling high dimensionality, or extracting more relevant features. Bridging Paradigms: Some techniques, like density estimation , inherently bridge both paradigms. For example, in supervised generative classifiers , we often model the class- conditional density (which is a form of density estimation, an unsupervised task performed within each class) to enable supervised classification.
Closed-Set vs. Open-Set Classification
Another important distinction in classification is whether the set of possible classes is exhaustive or not:
Closed-Set Classification: Assumption: In closed-set classification, it is explicitly assumed that all incoming test samples must belong to one of the classes the model was trained on. There is no option for an "unknown" or novel class. Application: Suitable for problems where all possible categories are known and exhaustively covered in the training data (e.g., recognizing specific people from a known group of employees). Open-Set Classification: Assumption: Conversely, open-set classification acknowledges that test samples might originate from classes not observed during training. Therefore, the classifier must be capable of outputting an "unknown" or "none of the above" category. Application: This is crucial for real-world scenarios requiring novelty detection (identifying something new or unexpected) or out-of-distribution detection (identifying data that does not fit any of the known patterns).
Classification Types Open-Set Classification
Test Sample
Classifier
Known Class 1 Known Class 2 Known Class K Unknown/Reject
Closed-Set Classification
Test Sample
Classifier
Known Class 1 Known Class 2 Known Class K
Explanation of Closed-Set vs. Open-Set Classification Diagram: The diagram illustrates two classifier scenarios. In Closed-Set Classification , a "Test Sample" is expected to be assigned to one of the "Known Classes" (Class 1, Class 2, ..., Class K) the classifier was trained on, with no other options. Conversely, in Open-Set Classification , a "Test Sample" can still be assigned to a "Known Class," but an additional "Unknown / Reject" output option exists for samples that do not sufficiently match any of the trained classes.
Note: End-to-End DeepLearning
Feature Vector (n-dim)
Yes Reduced Vector (m-dim) No Feature Vector (n-dim)
(Image, Text, Audio)^ Raw Input^ Direct Learning^ Learns Features &Classifies
Feature Extraction
Dimensionality Reduction?
Reduce Dimensions (e.g., PCA, LDA) Classification Model
Deep Learning Model^ Predicted Class Label
Explanation of Classification Stages Diagram: The diagram illustrates the typical flow. "Raw Input" first undergoes "Feature Extraction" to produce an "n-dimensional Feature Vector." This vector may optionally pass through "Dimensionality Reduction" to become an "m-dimensional Reduced Vector." Both the original or reduced vector then feed into a "Classification Model," which outputs the "Predicted Class Label." A special note highlights that "Deep Learning Models" can often perform "Feature Extraction" and "Classification" in a single, integrated "End-to-End" process.
Feature Extraction Examples
Resulting Feature Vector (1D array): [116, 133, 149, 186, 107, 126]
Example of Bag-of-Words (Term Frequency): Document Example: "the cat sat on the mat" Assumed Vocabulary: ["cat", "dog", "mat", "on", "sat", "the"]
Corresponding Term Frequency (TF) Vector: [1.0, 0.0, 1.0, 1.0, 1.0, 2.0] (Interpretation: The word "cat" appears 1 time, "dog" 0 times, "mat" 1 time, "on" 1 time, "
Dimensionality Reduction Revisited
Purpose Summary: To reiterate, dimensionality reduction serves multiple crucial purposes in machine learning: Compressing data to save storage and computational resources. Removing noise and redundant information from features. Simplifying complex models, making them easier to train and interpret. Combating overfitting, a common problem in high-dimensional spaces. Aiding visualization of high-dimensional data by projecting it into 2D or 3D. Key Challenges Addressed by Dimensionality Reduction: Curse of Dimensionality: This phenomenon refers to the various problems that arise when dealing with data in very high-dimensional spaces. Specifically, as the number of features (dimensions) increases: Data points become extremely sparse, making it difficult to find meaningful patterns or neighbors. Distances between data points (which many ML algorithms rely on) tend to become less meaningful or distinguishable. The amount of data required to effectively generalize (i.e., fill the space sufficiently) grows exponentially with the number of dimensions. Overfitting: This occurs when a machine learning model becomes excessively complex and learns the training data (including its noise and specific quirks) too precisely. While this leads to excellent performance on the training data, the model fails to generalize to new, unseen data, resulting in poor performance in real-world deployment.
Visualizing the Model Complexity Trade-off:
Model Complexity
Training Error
Test (Generalization) Error
Typical Behavior
Low (Too Simple)
High High Underfitting: The model is too simple to capture the underlying patterns in the data,
Decision Functions and Model Types
At the heart of the classification stage is the decision function (or the classification model itself). This component takes the processed feature vector ( or ) as input and outputs a predicted class label.
Machine learning models used for classification can be broadly categorized by how they arrive at this prediction:
Examples: Naive Bayes, Gaussian Mixture Models (GMMs), Hidden Markov Models (HMMs).
Generalization Error
A fundamental objective in machine learning is to achieve good generalization. This means designing models that can make accurate predictions not only on the data they were trained on but, more importantly, on new, previously unseen data.
Underfitting: Occurs when a model is too simplistic or has not been trained sufficiently. It fails to capture the underlying patterns in the training data, leading to high errors on both the training and unseen data. Overfitting: Occurs when a model is excessively complex and learns the training data, including its noise and idiosyncrasies, too precisely. While it performs very well on the training data, it fails to generalize to new data, resulting in poor real-world performance.
Achieving good generalization requires finding the appropriate model complexity. This is often controlled through techniques like hyperparameter tuning or regularization methods.
Training and Inference Phases
Machine Learning models typically operate through two distinct and crucial phases:
Training (Learning) Phase
Goal: The primary goal of this phase is for the model to learn its parameters or internal structure from a labeled dataset. This dataset is called the training set , typically represented as , where is an input and is its corresponding known label. Parametric Models: These models assume a fixed, predefined structure (e.g., a linear equation or a neural network architecture) entirely defined by a set of adjustable parameters ( ). Training involves finding the optimal values for these parameters (e.g., the best weights in logistic regression or neural networks) that best fit the training data. Non-Parametric Models: In contrast, the complexity of non-parametric models (e.g., k-Nearest Neighbors or kernel density estimators) grows with the size of the data. They don't have a fixed
The denominator, , is a normalizing constant (often called "evidence" or "marginal likelihood") that sums/integrates over all possible parameter values and ensures the posterior is a valid probability distribution.
Pros of Bayesian Approach: Naturally quantifies uncertainty in predictions and parameters. Can often perform better than frequentist methods, especially with smaller datasets, by leveraging prior knowledge. Provides full predictive distributions, not just point estimates. Cons of Bayesian Approach: Can be computationally intensive , as the integral required for calculating the posterior and predictions often does not have a closed-form solution and requires complex approximation methods (e.g., Markov Chain Monte Carlo (MCMC) or Variational Inference). Scope: Due to its computational complexity, a detailed treatment of the Bayesian approach is not included in this course.
Model Evaluation: Assessing Performance
After a machine learning model is trained, it's crucial to rigorously assess its performance, particularly its ability to generalize to new, unseen data. This requires dedicated datasets and appropriate evaluation metrics.
Test Set
Purpose: The test set is used solely to evaluate the final trained model on data it has never seen before during any part of the training or tuning process. This simulates real-world
deployment scenarios. Requirement: It must be kept strictly separate and untouched from all training and validation procedures until the very end of the model development cycle. Benefit: Provides an unbiased and realistic estimate of the model's true generalization performance on new data. If the test set is "leaked" into earlier stages, the performance estimate will be artificially optimistic. Characteristics: The test set should ideally mirror the distribution of data that the model is expected to encounter in actual use.
Validation Set
Purpose: The validation set serves a distinct purpose. It is used during the model development phase for critical tasks: Hyperparameter Tuning: Selecting the optimal values for hyperparameters—parameters that are not learned directly from the data but are set before training (e.g., the learning rate in neural networks, the number of neighbors k in k-NN, or the regularization strength). Model Selection: Choosing between different types of models (e.g., deciding whether an SVM or a Logistic Regression model is better for a specific problem) or between different feature sets. Early Stopping: Monitoring the model's performance on the validation set during training and stopping the training process early if performance starts to degrade (indicating overfitting) to prevent further overfitting. Creation: The validation set is created by splitting a portion from the original training dataset. It is not part of the data used for parameter learning itself. Importance: Using a separate validation set prevents "information leak" from the test set into the development process. This ensures that the final evaluation on the test set remains unbiased and truly indicative of the model's generalization capabilities.
Final Performance Metric
Report Generalization Performance
Explanation of Data Splitting and Evaluation Diagram:
Cross-Validation (When Data is Limited)
When the amount of labeled data is limited, performing a single, separate validation split might leave too little data for effective training or make the validation performance estimate unstable. In such cases, cross-validation is a more efficient and robust technique for using data for both training and validation.
K-Fold Cross-Validation:
more stable and less biased estimate of the model's performance on unseen data.
Common K Values: Typically, is set to 5 or 10.
Leave-One-Out Cross-Validation (LOOCV):
Special Case: LOOCV is a special case of K-Fold Cross-Validation where is set equal to , the total number of samples in the training dataset. Process: In each iteration, the model is trained on samples, and then validated on the single left-out sample. This process is repeated times, once for each sample being the validation set. Cost vs. Bias: While LOOCV provides a nearly unbiased estimate of generalization performance, it is computationally very expensive , making it impractical for large datasets ( ).
Aggregate Results
... Iteration 2 Iteration K
Iteration 1
Fold 1
Folds 2,3,4,
Fold 2
... Folds 1,3,4,
Fold K
Folds 1..K-
Original Training Data
Split into K Folds (e.g., K=5)
Validation Fold
Training Folds
Train Model 1
Performance 1
Validation Fold
Training Folds
Train Model 2
Performance 2
...
Validation Fold
Training Folds
Train Model K
Performance K
Average Performance Across K Folds
Explanation of K-Fold Cross-Validation Diagram: The "Original Training Data" is first split into "K Folds." The diagram shows this process for "Iteration 1" (Fold 1 as Validation, others as Training), "Iteration 2" (Fold 2 as Validation, others as Training), and eventually "Iteration K." In each iteration, a model is "Train[ed]" on the designated training folds, then