Docsity
Trusted Seller

ARTIFICIAL INTELLIGENCE (English), Appunti di Tecniche Di Intelligenza Artificiale

Toggle sidebar
bg1
ARTIFICIAL INTELLIGENCE IN MEDICINE
THE INTRODUCTION
Practical examples:
• Roomba artificial intelligence based on cameras.
• Self-driving car (google) it has a lot of sensors which help it to understand around the environment and
prevent an accident as well as we do (interpreting the signs).
N.B. It is different from Tesla, which has third-rate autonomy. You can remain inside the car without hands
on the steering wheel.
• Google duplex AI assistant calls for business affair. Attention! you can’t predict the human response on
the other side of the phone. It is very impressive how it actually works.
What is artificial intelligence?
It is born in 1960 with the aim to build technologies with complex intelligence machines inside, mimicking
human behaviours.
Today, AI is present in other different contexts, for example medicine biomedical research facilities. It has a
lot of advantages: we have tones of data to work on and the use of mathematic (statistics) is a little bit limiting.
AI is rapid, automatic, and scalable (it is better than humans in solve one single vertical problem).
Attention! There are still black spaces to solve:
• translate what is investigated into mathematical terms (from a medical point of view)
• data sharing (hospitals has not sophisticated programs able to share with other) (from an engineering
point of view)
• interaction with patients (can a machine say you the report?)
One big issue in AIM is about data collection data is usually very messy (they are collected by doctors. Each
doctor has his structure, his format, his own way to collect data. They are often incomplete, in particular for
long-term exam with different check-ups) a lot of time is spent CLEANING DATA (manually) and
STANDARDIZE THEM (format, label),
Aim Today
• Electronic Health Records (EHRs)
• Disease Identification and Diagnosis
• Robotic Patient Support Tasks
• Personalized Medicine
• Medical Imaging Diagnosis
• Robotic Surgery
Machine learning
The machine learning is a discipline defined as “the ability to learn without being explicitly
programmed” [Arthur Samuel, 1959] there are no written steps to follow, and this is very
important because it is impossible to analyse all the possible cases.
Attention! Deep learning is a subsection of machine learning, based on Deep Neural Network
(the opposite is the Shallow learning).
In medicine, deep learning is used for medical imaging. Other problems, anyways, can’t be
related to deep learning (for example if we haven’t enough data).
Machine learning costs money, interactions with doctors
creates algorithms that can learn from data and
make decisions based on patterns observed in the data.
Example: there are a bunch of images collected and annotated by a human [the algorithm must learn to
recognize and classify them multiclass classification model].
Learning:
1. Supervised there are labels. Classification (categorical data) or regression (data non categorical but
numerical) ability of generalizing data that are seen before. It follows the goodness of the expert.
2. Unsupervised there isn’t the knowledge of the expert. The algorithm must divide data (if it is needed)
without the supervision of an expert.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c

Anteprima parziale del testo

Scarica ARTIFICIAL INTELLIGENCE (English) e più Appunti in PDF di Tecniche Di Intelligenza Artificiale solo su Docsity!

ARTIFICIAL INTELLIGENCE IN MEDICINE

THE INTRODUCTION

Practical examples:

  • Roomba  artificial intelligence based on cameras.
  • Self-driving car (google)  it has a lot of sensors which help it to understand around the environment and prevent an accident as well as we do (interpreting the signs). N.B. It is different from Tesla, which has third-rate autonomy. You can remain inside the car without hands on the steering wheel.
  • Google duplex  AI assistant calls for business affair. Attention! you can’t predict the human response on the other side of the phone. It is very impressive how it actually works.

What is artificial intelligence? It is born in 1960 with the aim to build technologies with complex intelligence machines inside, mimicking human behaviours. Today, AI is present in other different contexts, for example medicine  biomedical research facilities. It has a lot of advantages: we have tones of data to work on and the use of mathematic (statistics) is a little bit limiting. AI is rapid, automatic, and scalable (it is better than humans in solve one single vertical problem). Attention! There are still black spaces to solve:

  • translate what is investigated into mathematical terms (from a medical point of view)
  • data sharing (hospitals has not sophisticated programs able to share with other) (from an engineering point of view)
  • interaction with patients (can a machine say you the report?) One big issue in AIM is about data collection  data is usually very messy (they are collected by doctors. Each doctor has his structure, his format, his own way to collect data. They are often incomplete, in particular for long-term exam with different check-ups)  a lot of time is spent CLEANING DATA (manually) and STANDARDIZE THEM (format, label),

Aim Today

  • Electronic Health Records (EHRs)
  • Disease Identification and Diagnosis
  • Robotic Patient Support Tasks
  • Personalized Medicine
  • Medical Imaging Diagnosis
  • Robotic Surgery

Machine learning The machine learning is a discipline defined as “the ability to learn without being explicitly programmed” [Arthur Samuel, 1959]  there are no written steps to follow, and this is very important because it is impossible to analyse all the possible cases. Attention! Deep learning is a subsection of machine learning, based on Deep Neural Network (the opposite is the Shallow learning). In medicine, deep learning is used for medical imaging. Other problems, anyways, can’t be related to deep learning (for example if we haven’t enough data).

Machine learning costs money, interactions with doctors  creates algorithms that can learn from data and

make decisions based on patterns observed in the data. Example: there are a bunch of images collected and annotated by a human [the algorithm must learn to recognize and classify them  multiclass classification model].

Learning:

  1. Supervised  there are labels. Classification (categorical data) or regression (data non categorical but numerical)  ability of generalizing data that are seen before. It follows the goodness of the expert.
  2. Unsupervised  there isn’t the knowledge of the expert. The algorithm must divide data (if it is needed) without the supervision of an expert.

Unsupervised learning

 How to cluster them? Size, shape, colour, position (x, y)? Data exploration

What’s the best?

Supervised learning Give the image  it analyses the image and put into a category (it already has categories into which putting the images). We have a matrix. Each row of the matrix (categorical) is associated to a label (numerical or binary)

It can be: − Classification  there is the possibility to infer a separating function.      1,    2 Goal: predict the category or class to which a new input belongs. Output: The model's output is a discrete label or category. Example: Predicting whether an email is spam or not (binary classification) or identifying the type of flower based on its features (multiclass classification).

− Regression  each sample has one measure (output values which are continuous). Find a function which fits the data points. How to know if it is correct? We need prior knowledge.      1

Goal: predict a continuous numeric value. Output: The model's output is a numerical value. Example: Predicting the price of a house based on its features, like square footage, number of bedrooms, etc.

Examples in medicine:

  1. Regression Problem: Predicting Blood Pressure Goal: Predicting the numerical value of a patient's blood pressure. Features: Age, weight, cholesterol levels, and other relevant health metrics. Output: The model would provide a continuous prediction of blood pressure, which is a numeric value.
  2. Classification Problem: Diagnosing Disease Goal: Classifying whether a patient has a specific disease or not. Features: Medical test results, patient history, and other relevant information. Output: The model would output binary classes, such as "Positive" for having the disease or "Negative" for not having the disease. In cases with multiple diseases, it could be a multiclass classification task.

Each column is a variable. Based on the variables, the row is associated with an already defined label.

Bias We grow up with prototypical attributes associated with the notion of something. For example: when we see a banana, we do not describe it as yellow, because the fact that it is yellow is intrinsic to the word banana. If we see a green banana, instead, we tend to describe it as a “green banana”, because it is different from what we usually see. Another example, with a more important ethical message, is the word “surgeon”. When we think of a surgeon, we immediately think of a man. For historical reasons it is difficult to think of a surgeon as a woman, even though nowadays many surgeons are women.

Bias come from:

  • human biases in data (only yellow banana for example, and not green ones)
  • human biases in collection and annotation

Non-representative training data

  • Recognize a married couple only if they are dressed as required by a Christian wedding: she in a white dress, he in a black suit. A training set consisting only of this type of wedding cannot be representative of the concept of marriage in general, not taking into account other cults (for example Islamic or Hindu) which do not require the presence of a white dress, for example.
  • Book: Invisible women  the key idea behind the statement is that many systems and structures in society are built on data that often overlooks or underrepresents women. This data bias can lead to gender inequalities and have real-world consequences in areas such as public policy, healthcare, technology development, and more. The book aims to shed light on these issues and advocate for more inclusive and unbiased data collection and analysis to create a fairer and more equitable society.

Types of bias in medicine (if a medical diagnosis model is trained mostly on data from a specific demographic group, it may not perform well for patients from other demographics, leading to biased predictions):

  • racial bias For instance, certain skin conditions may be less accurately diagnosed in individuals with darker skin tones due to a lack of diverse training data.
  • gender bias For instance, heart attack symptoms might be based on typical male presentations, leading to delayed or misdiagnosed cases in women who may experience different symptoms.
  • Age bias Elderly individuals may be underrepresented in clinical trials, leading to a lack of understanding of how certain treatments affect this population. This can result in suboptimal care for older patients.

Biases can arise from various sources, such as biased training data, model assumptions, or the features chosen. It's crucial to be aware of and address biases, especially when the training data is not representative of the real- world population or when certain groups are underrepresented.

Attention! In unsupervised learning, while there may not be a direct target variable for prediction, the concepts of bias and generalization can still be relevant, particularly when evaluating the performance of clustering algorithms or dimensionality reduction methods. However, the terms are more commonly associated with supervised learning where there is a clear target variable and a training set with labeled examples.

UNSUPERVISED LEARNING

Goal : learning without a teacher (without the help of a supervisor providing correct answers or degree-of-error for each observation). The unsupervised learning algorithm can be further categorized into two types of problems:

  1. Clustering  Clustering is a method of grouping the objects into clusters such that objects with most similarities remains into a group and have less or no similarities with the objects of another group. Example: given a dataset of customer purchase behavior, clustering might identify groups of customers who exhibit similar purchasing patterns.
  2. Association  Association, on the other hand, focuses on discovering relationships or associations between variables in the dataset. It aims to find patterns indicating that certain events or items tend to co- occur (if X, then Y). Example: In the same customer purchase dataset, association analysis could reveal that customers who buy diapers are also likely to buy baby formula.

Association Rules Goal : find joint values of the most frequent variables in the database. “Look for prototype X-values , , …. ,  such that the probability density Pr  for each prototype is relatively large”. The objective is to identify prototype X-values (items or conditions) for which the support (frequency of occurrence) is relatively large. High support indicates that the prototype X-values occur together frequently, making the association rule more significant.

Clustering

Goal : to partition the observations into groups (“clusters”) so that the pairwise dissimilarities between those assigned to the same cluster tend to be smaller than those in different clusters. Different types of algorithms:

  1. Combinatorial algorithms (no Bayesian  no inferring process)  those that directly partition the dataset into distinct non-overlapping groups. Example: K-means  it assigns each data point to one of the predefined clusters to minimize the within- cluster sum of squares.
  2. Mixture modeling  they model the dataset as a mixture of different probability distributions or components (how many gaussians, what is the variance, mean etc). Example: Gaussian Mixture Models (GMMs)  they assume that the data points are generated from a combination of several Gaussian distributions.
  3. Mode seekers  they aim to identify the modes or peaks in the density distribution of the data, often forming clusters around these high-density regions.

Combinatorial algorithms Assign each observation (labeled by an integer ∈ {1 … }) to a group or cluster. The number of clusters <  is set as a parameter of the problem (each cluster is encoded by an integer " ∈ {1 … }). The cluster assignments can be characterized by a many to one mapping #  that assigns the $%^ observation to the "$%^ cluster: #   " (encoder). It's essentially saying that each data point is assigned to a specific cluster " by the encoder #. The notation #∗ ^ suggests a specific or optimal encoder that achieves certain objectives. In clustering, finding the optimal encoder involves assigning data points to clusters in a way that minimizes a defined loss or energy function. A loss function or energy function quantifies how well the assigned clusters match the underlying structure of the data or the desired clustering goals. The optimization process aims to minimize this function.

In mathematical terms, the optimization problem can be framed as:

#∗^  arg min,-#

Where ,-# represents the loss function associated with the encoder #, and #∗^ is the optimal encoder that minimizes this loss.

Examples:

  1. PCA  Principal Component Analysis PCA aims to transform the original features into a new set of orthogonal features, known as principal components. These components capture the maximum variance in the data, effectively reducing dimensionality.
  2. t-SNE  t-Distributed Stochastic Neighbor Embedding t-SNE is a technique for visualizing high-dimensional data in a low- dimensional space, often used for exploration and analysis. It emphasizes preserving the pairwise similarities between data points.

Example: Alzheimer’s Disease (AD) Data Collection: consider a dataset with features such as genetic markers, imaging data, and cognitive assessments collected from individuals with and without Alzheimer's disease. Feature Selection: choose relevant features that are believed to be associated with Alzheimer's disease or may contribute to the understanding of disease progression (example: composition of cerebrospinal fluid).

(Preprocessing: standardize or normalize the data to ensure that features with different scales are treated

equally in the clustering process). Application of K-means: Apply the K-means algorithm to the pre-processed data to group individuals into k clusters based on their feature similarities. Cluster Interpretation: analyze the clusters formed by K-means to interpret the characteristics of each group. For example, if k=2, there is a simple classification between patients with and without the deseas. It k>2, clusters might represent different disease subtypes, disease stages, or levels of severity.

CORRELATION ANALYSIS

Why correlation analysis? Machine learning people and medical doctors often don’t speak the same language. Most medical papers have some linear association analysis of the covariates involved. Linear models are highly interpretable.

What is correlation between a variable x and y?

Correlation is a statistical measure that expresses the extent to which two variables are linearly related (meaning they change together at a constant rate). Correlation analysis is a statistical technique used to measure the strength and direction of the linear relationship between two variables. In the context of machine learning, correlation analysis can be valuable for understanding the relationships between features and making informed decisions during the feature selection process.

We are going to talk about Pearson correlation (there are other types (e.g. Spearman) but this one is the most typical):



∑ F4< A <̅D A DE

G∑^ F4<  A <̅G∑^ F4D A DE

H ∑ F4<D  A ∑ F4 < ∑ F4D 

I? H ∑ F4 <A ∑ F4 <?? H ∑ F4 DA ∑ F4 D?

JKL

JKJL

where H → number of data points; < , D → individual data points for variable <, D; <̅, DE → means of variables <, D.

How do we reason about correlation?

Interpreting r: the value gives information about the strength, the sign about the directionality.

  • N 0 → Positive correlation (as one variable increases, the other tends to increase).
  • < 0 → Negative correlation (as one variable increases, the other tends to decrease).
  •  0 → No linear correlation. Keep in mind that Pearson's correlation coefficient specifically measures linear relationships. Non-linear relationships may not be adequately captured by r. Additionally, correlation does not imply causation; a significant correlation between two variables does not necessarily mean that one causes the other.

Computing the p-value The p-value is a statistical measure that helps assess the statistical significance of the observed correlation coefficient. It provides information about the likelihood of obtaining such a correlation by random chance alone, assuming that there is no true correlation in the population. Hypothesis Testing:

  • Null Hypothesis (O>): there is no correlation between the two variables in the population (correlation coefficient is zero)   0.
  • Alternative Hypothesis (O): there is a correlation between the two variables in the population  P 0. Calculation of p-value:

The p-value is calculated based on the observed correlation coefficient and the sample size (more samples you

have and the more even a small correlaon can be seen significant).

The first step is the calculaon of the t-stasc test:

Q 

√H A 2

√1 A 

Where → observed correlation coefficient, H A 2 → degrees of freedom. Once calculated t, the p-value is obtained from the t distribution tables. Significance Level (S): The significance level often denoted as S represents the threshold below which the p-value is considered statistically significant. Decision rule:

  • If the p-value is less than or equal to the chosen significance level (α), the null hypothesis is rejected  the observed correlation is statistically significant.
  • If the p-value is greater than the significance level, there is insufficient evidence to reject the null hypothesis  the observed correlation may have occurred by random chance.

P-value bootstrapping Bootstrapping is a resampling technique that involves repeatedly drawing samples with replacement from the observed data to estimate the sampling distribution of a statistic. When it comes to calculating p-values through bootstrapping, it's often done in the context of hypothesis testing or assessing the uncertainty of a parameter estimate.

Correlation can only be used on two variables. When you have more than two variables, the analysis becomes more complex, and you often move beyond simple bivariate relationships to explore multivariate relationships: with OLS we can adjust for them. Given two variables X and Y, OLS approximate the conditional expectation E[Y|X] by the mean of this linear relationship D  T> 5 T< 5 Y. Z[X, X, X] which becomes D  T> 5 T< 5 T< 5 T&lt; 5 Y Now the estimate T tells us if the variables are correlated conditioned on the presence of other variables. The presence of more variables or lack thereof will affect our beta estimate.

Example: Blood pressure Suppose to have a dataset of 100 individuals for which we have measured Blood Pressure (BP) and BMI and we want to understand the impact of BMI on blood pressure. Organize the data: set up your dataset with columns for Blood Pressure (dependent variable) and BMI (independent variable). Fit the OLS Regression Model: the model takes the form: ;^  T_a ∙ ;bc 5 T&gt; T_a  2.5eeOf/"f/e^2 : for each 1BMI unit we will increase our blood pressure of 2.5.

Now, we realize that we also have the age of the individuals, and blood pressure and BMI typically increase with age. So we create a bivariate OLS model: ;^  T_a ∙ ;bc 5 Tjkl ∙  5 T&gt; T_a  1.8eeOf/"f/e^2 : for each 1BMI unit we will increase our blood pressure of 1.8. Tjkl  0.2eeOf/D  : every 5 years BP increases of 1 mmHg.

Lastly, we realized that we left out the biological sex of the patients (coded as 0 for females and 1 for male), again we add it to the model: ;^  T_a ∙ ;bc 5 Tjkl ∙  5 TnlK ∙  5 T&gt; T_a  1.6eeOf/"f/e^2 : for each 1BMI unit we will increase our blood pressure of 1.6. Tjkl  0.3eeOf/D  : every 5 years BP increases of 1 mmHg.

TnlK  A5eeOf/f H0 : males have lower BP compared to female, on average 5mmHg less.

MACHINE LEARNING FOR PREDICTION: SUPERVISED LEARNING

Supervised learning is also called prediction because we have already labels.

How to use machine learning to predict models able to predict themselves? What we do from centuries is to start from a hypothesis and collect data for verifying that hypothesis. The quality of prediction depends on the quality of data we have. Goal: Infer usable information (define knowledge) What is changed nowadays is that some of the statistics born in the field of Fisher’s world (there are samples, and there are two parametric distributions  understand to which distribution data belong) can’t be applied since data is super high dimensional. Problem : we have too much data. ML ingredients (recap): We have data already labeled (each data point x is already associated to a y, which could be a continuous value (regression) or a categorical value (classification)  we need to create a model to assign labels to input and which works well also on unseen data, not only on the training set.

Speaking about the medical field: the model is based on a question (it could be a diagnostic confirmation, prognostic, predictive, lifestyle influence). Starting from the question, the most suitable parameters are considered.

N.B. ML must incorporate the complexity of phenomena, we can’t stop to just one layer to explain biomedical conditions, we must discover them one at a time. Diseases can be analysed by different points of view: − Metabolic network (“why some people had covid and others not?”) − Disease network (“people who had covid have prior status? Have they factors which could help it?”) − Social network  some people are hubs (they meet more people than others). Attention! Precise and personalized medicine is very difficult to achieve.

The real-world scenario It is more complicated. Aim: capture and describe complex phenomena. Keywords (to keep in mind): − Interpretability (understand the presence of errors AND be able to explain why the model is working) − Reproducibility (in medicine we usually don’t have open data. It deals with questions like “can I share data with others?”, “can I share the code?”) − Human-centred AI (plan and design products which are simple to use for humans!)

  1. Data Data scarcity is one of the problems because we have few data in medical environments. Data in medicine are very expensive to store (a lot of consequences in terms of permissions, costs, people involved (the most expensive)). For this reason, we share data with other scientists (open data), we program scripts that search for information relative to the data you want to obtain, online (scraping), or we collect data from scratch (da zero) (this is the ideal situation, but it takes time).

Large scale data In medicine there are fat matrices (few samples, a lot of variables).

Resampling strategies: training set  testing set When dealing with a non-representative testing set, resampling strategies can be employed to address issues such as class imbalance, heterogeneity, or other imbalances in the distribution of data. Split and prove different models (with different combinations)  find the performance for each model and find the accuracy for each of them  compute the average (standard deviation) and evaluate the result. Goal: have one model able to work OPEN LOOP (drawback: we have k models, not one). For example:

  • K-fold cross validation  the dataset is divided into k folds, and the model is trained and tested k times.
  • Leave-one-out cross validation  only one sample is used as the testing set while the rest are used for training. This process is repeated for each sample in the dataset.
  • Boot-strap  create multiple bootstrap samples (random samples with replacement) from the original testing set.
  1. Models What have we learned so far?
  2. Multivariate models are good (normally the phenomena in medicine are multivariate)
  3. Latent variables are important (when we decide to measure something in a patient there are also other causes that aren’t calculate that influence the result)
  4. Interdisciplinarity

Learning from data paradigm

Label vector *Depending on the problem we have, it could be a classification o regression.

ML for disease (they are all classifications):

  • Diagnosis  identify whether an individual has a particular disease or condition (binary classification problem).
  • Staging  determine the severity or stage of a disease based on various clinical factors, imaging data, or other relevant information. If we consider disease staging, we are facing a multiclass classification problem  one-hot vector  which means that even if the staging uses numbers, it’s not a regression problem. So, I take a binary classification of 5 dimensions, and I decide the labels (they aren’t numbers, they are categorical).

Example of multi-classes problem: in Alzheimer we have healthy, MCI (Mild Cognitive Impairment) and Alzheimer.

  • Prognosis involves time: this is more complex, there are matrices that change over time  predict the likely course and outcome of a disease for an individual patient, considering factors such as treatment response, survival rates, or complications.

How do I compute models? It depends on the algorithm which models data. We have algorithms specifically defined for:

  • Classification (Least Squares, Logistic Regression, Naive Bayes, K-Nearest Neighbors, Decision Trees, Support Vector Machine, SVC)
  • Regression (Least Squares, Linear Regression, Logistic Regression, Support Vector Regression, SVR)

General idea [consider the regression case]: Simplest case: one variable as input and one as output  find a function such as: <  D Graph: these are all good options  all of them touch all data points. Among the options, there is the linear model (a simple line)  In this case we must compare, for each point, the observed response and the predicted one (discrepancy)  find m and b: <  e< 5 Learn the parameters: m and b  we use the so called “loss function” ,  it measures the discrepancy (how different are all the points from the original ones): min q ,<, D

How to choose ,? Depending on the choice we obtain different results (absolute loss, square loss)  it is usually used the square loss: ,<, D  < A D There exist other loss functions:

  1. Zero-one (measures the discrepancy between predicted and actual values by assigning a value of 0 for correct predictions and 1 for incorrect predictions. Commonly used in classification problems).
  2. Logistic (measures the performance of a classification model that outputs probabilities. Encourages correct classification by penalizing confidently wrong predictions more heavily (widely used in logistic regression and binary/multiclass classification problems)).
  3. Hinge
  4. Square (measures the average of squared differences between predicted and actual values. Often used in regression problems, penalizing larger errors more heavily due to squaring. Sensitive to outliers).
  5. Absolute (Measures the average of absolute differences between predicted and actual values. Similar to square loss but less sensitive to outliers. Used in regression tasks where outliers need to be treated more robustly).
  6. r Ainsensitive (Defines a tube around the regression line where errors within the tube are considered negligible).

Example: least squares for regression *Elements: data points, m, b, square loss function. Compromise  I look at a model which fits as good as possible data points (of course there will be points whose discrepancy affects the solution):

min s,t /< A D ^  

min s,t / (^)   min q ,<, D

e 

H ∑XV A ∑ V ∑ X

H ∑X A ∑ X^

∑ V A e ∑ X H

*Arbitrary decision: linear model

__ Generalization − Underfitting (the trend is not capture)  data do not contain enough information, or the training set is not big enough (increasing the training size o reducing model complexity). − Appropriate fitting  optical in capture the trend and discard the noise. − Overfitting  too much noise into the model (the model learns the trend+ something else)  use regularized methods or increase the training size.

< remember > To compute a model , we need to collect data points and minimize discrepancies.

Regularization methods (to prevent overfitting) Overfitting occurs when a model becomes too complex and captures noise in the training set, rather than the underlying patterns.

min q ,<, D 5 v<

Find the minimum of:

  • ,<, D → the fitness term (the most common is the square)
  • v< → the regularization penalty term (term which controls the complexity) (the most common is the square).
  •  → regularization parameter (it is typically a scalar)  if it is 0, we have no interest in incorporating the complexity parameter. Easy solution or fits all the points? It is our decision.

How to choose :

If   QQ → regularization is not considered  separated function which is very detailed (includes noise) 

overfitting.

If  f → the model is too simple (it doesn’t catch the trend of data)  underfitting

  • In classification:
  • In regression:

So? We need  in the middle. But, how to decide? Practical rule (choose the hyper-parameters)

We start from available data! We divide them into two groups: training set (80%) (used to learn the model) and testing set (20%) (used to test the generalization). Then we divide the training set, now called learning set, into the actual training set (60%) (used to learn the model) and a validation set (20%) (used to set the hyper-parameters).

Compute the Euclidian distance: min q ?|< A D|?





Where the model taken into consideration has different  (arbitrary choice).

N.B. Hyperparameters are parameters that are not learned from the data during the training process but are set before the training begins.

Then, use the validation set to understand which  is the best one (the one which minimizes the error).

Then, change the combination of the learning set (creating a different validation set a time) and repeat the

process, calculating each time the accuracy for each   create a matrix:

 D  {

According to performances (mean error) we pick the best  (resampling strategies to make the algorithm

consistent!).

N.B. For “hyper parameters” we think about  and distance!

Rule: perform k-fold cross-validation it helps estimate how well the model will generalize to new, unseen

data. Try different values of the regularization parameter  and choose the one that provides the best

performance on the validation set.

After all this procedure, I test the model using the testing test (never used until now) It's essential to keep the test set separate from the training and validation sets to provide an unbiased evaluation of the final model. Attention! if I change data, all this changes a little bit.

Stability In supervised learning, model stability refers to the consistency and robustness of a trained model's predictions when faced with different inputs or data subsets. A stable supervised learning model is less sensitive to variations in the training data and generalizes well to unseen data.

If data points change a bit, is that going to affect that much? The main problem with the standard supervised learning pipeline is that it produces only one accuracy score and one list of variables. If there is just one split, then there is only one model.

Is it good enough? We don’t know until resampling! The main idea of proposed approach consists in producing not just one list of variables with associated accuracy score, but many of them, to be able to observe the distribution of the values for the accuracy (rather than just one value). To do so, we repeat the entire learning pipeline multiple times, each time resampling the learning and the test set. This means that, for each repetition of the experiment, a different learning and test set are generated by randomly sampling without replacement from the original dataset.

So: repeat the pipeline K differently times! K different accuracy scores (histogram/ distribution)  pick the best one.

Supervised learning paradigm

Logistic Regression for classification (supervised learning) *It explores the sigmoid function (continuous values between 0 and 1) Example Two classes: exam passed, and exam not passed (linear function with sign). The function has positive or negative sign without considering the closeness of the data point to the surface of the separation plane. The outcome is always +1 or -1, and thus I don’t know how close the data point is to the separation plane. Knowing the distance from the boundary could be useful, because if a point is near, the probability that it belongs to the other class is higher than when the point is far.

Support Vector Machine (SVM) (supervised learning) SVM works for both classification and regression problems by mapping data to a high-dimensional feature space so that data points can be categorized, even when the data are not otherwise linearly separable. Margin: it is the distance between the hyperplane and the observations closest to the hyperplane (support vectors). In SVM large margin is considered a good margin. Indeed, its results depend on whether the classes are well separable or not. Also in this case, we find in the equation both the fitting and the regularizing terms:

min / < , D 5 ?||? 7

F  4 V represents the loss function (e.g., Euclidean distance in LS), and it becomes constant when the classification is correct, as it can be seen in the figure on the right. It also shows that the loss function weights more the errors that are farther from the separation boundary.

Hinge loss: as long as the point is correctly classified, it is not count anymore. Is it is ambigous, it is counted a lot during minimization.

Objective: SVM aims to find a hyperplane that best separates the data points of different classes while maximizing the margin between the classes. Hyperplane: in a two-dimensional space, the hyperplane is a line. In higher dimensions, it becomes a plane or a hyperplane. The optimal hyperplane is the one that maximizes the margin, which is the distance between the hyperplane and the nearest data point from each class. Support Vectors: support vectors are the data points that are closest to the decision boundary (hyperplane). These points play a crucial role in determining the optimal hyperplane and are used to define the margin. Margin: the margin is the distance between the hyperplane and the nearest data point from each class. SVM aims to maximize this margin, leading to a more robust and generalizable model.

Kernel methods (for both supervised and unsupervised learning) Wilder class of algorithms (SVM belongs to it). This theory computes different distance metrics, according to the kernel considered. Kernels are functions (e.g., Gaussian) used to preserve the possibility to look for more complex functions than linear, so they transfer the complex problem into a feature space. Data inputs are transferred into the feature space (which has a higher dimension), and then in that space I am going to solve the linear problem.

In supervised learning, kernel methods are often associated with Support Vector Machines (SVM). The kernel trick allows these algorithms to implicitly operate in a higher-dimensional feature space without explicitly calculating the transformed features. In unsupervised learning, kernel methods are commonly applied to tasks such as clustering and dimensionality reduction.

Example: − k-Nearest Neighbours algorithm (k-NN)  supervised learning (both classification and regression) Classification: Assigns the most common class among the k-nearest neighbours. Regression: Predicts the average of the target values of the k-nearest neighbours. Concept: the algorithm classifies or predicts a new data point based on the majority class or average target value of its k-nearest neighbours in the feature space. If we want to classify a new sample  show it in space  calculate the distance between it and the nearby points and associate the point in question with the class to which the closest point belongs. − Random Forests  supervised Learning (both classification and regression). It builds multiple decision trees during training and outputs the mode (for classification) or average (for regression) of the individual predictions.

VARIABLE SELECTION

Understand why some variables are able to explain some conditions (they are usually features directly extracted from raw data or coming from a second variable). Anyway, feature selection is primarily focused on removing non-informative or redundant predictors from the model. Attention! Any variable contributes to make the model (both bigger and very low variables)

Goal of feature extraction: make smaller the dimensionality. Advantages:  It enables the machine learning algorithm to train faster.  It reduces the complexity of a model and makes it easier to interpret.  It improves the accuracy of a model if the right subset is chosen.  It reduces overfitting.

(question)

Variable selection is typically associated with supervised learning, where the goal is to train a model to predict an output variable based on input features. In supervised learning, variable selection involves choosing a subset of relevant features that contribute the most to the predictive performance of the model. The aim is to improve model efficiency, interpretability, and generalization by focusing on the most informative features.

Three different approaches:

  1. Filter methods (based on hypothesis tests)
  2. Wrapper methods (machine learning methods)
  3. Embedded methods

Attention! Dimensionality reduction is not the same thing (here the interpretability is lost). In the case of variable selection, variables are discarded.