Docsity

ARTIFICIAL INTELLIGENCE IN MEDICINE, Appunti di Machine learning

Toggle sidebar
bg1
Artificial Intelligence in
Medicine
Aca dem ic Year 2022-2023
Introduction to Artificial Intelligence
We are branched into a culture of movies and stuff where artificial intelligence is very present and
associated with the idea of robots, but also systems capable to observe the environment and to react. But this
is not what we should really think of, not robots as we are intended to think, but more simple systems. The
first definition of artificial intelligence came into 60s: artificial intelligence is a technique of getting
machines to work, act, or behave as a human.
Then the question is why is AI relevant in medicine? There are some answers:
- Advantageous to speeding up processes
- Cost-effective, rapid, automatic, and scalable
- Can reach expert level precision.
Even if math and medicine share a long history, there still is a long way to go because of
communication: in fact, common language is not like medical one, but there is also the problem that experts
(doctors) are not familiar with AI, seeing it as a black box. The role of the engineer is then to work with
doctors and convince them on all the possibilities AI can give. Another question can be do we have to rely
more on doctors or on AI? The answer, in this case, depend on the task.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13

Anteprima parziale del testo

Scarica ARTIFICIAL INTELLIGENCE IN MEDICINE e più Appunti in PDF di Machine learning solo su Docsity!

Artificial Intelligence in

Medicine

Academic Year 2022-

Introduction to Artificial Intelligence We are branched into a culture of movies and stuff where artificial intelligence is very present and associated with the idea of robots, but also systems capable to observe the environment and to react. But this is not what we should really think of, not robots as we are intended to think, but more simple systems. The first definition of artificial intelligence came into 60s: artificial intelligence is a technique of getting machines to work, act, or behave as a human. Then the question is why is AI relevant in medicine? There are some answers:

  • Advantageous to speeding up processes
  • Cost-effective, rapid, automatic, and scalable
  • Can reach expert level precision. Even if math and medicine share a long history, there still is a long way to go because of communication : in fact, common language is not like medical one, but there is also the problem that experts (doctors) are not familiar with AI, seeing it as a black box. The role of the engineer is then to work with doctors and convince them on all the possibilities AI can give. Another question can be do we have to rely more on doctors or on AI? The answer, in this case, depend on the task.

Today, AI in medicine can be used into several applications, like:

  • Electronic Health Records;
  • Disease identification and diagnosis, using data from analysis and making classifications;
  • Robotic patient support tasks;
  • Personalized medicine, like analysis of genomic characteristics and some other features;
  • Medical imaging, observing the content of scans and finding out if the subject has something;
  • Robotic surgery, reacting also to patient motions and other artefacts, making instruments better than humans in making the work. Main characteristics of AI and Learning AI represent a very large context, where we can identify some subsets as machine learning and deep learning. We can define Machine Learning by using the definition Arthur Samuel gave in 1959: machine learning gives computers the ability to learn without being explicitly programmed. So, machine learning uses statistics and learn a statistical model to behave basing on data and generalizing capabilities. It creates algorithms that can learn from data and make decisions based on patterns observed in the data. Deep Learning is then a subset of Machine Learning and is based in Deep Neural Networks. The most important concept is that machines learn from examples. Data are categorized and machine learns how to, for instance, recognize things into image. The main principle is to collect data that are categorized into classes (for instance: our image contains a lot of things and some tags). An important task is to learn image and signal processing, or something to prepare the data, depending on the task. The problem of ML can be divided in two:
  • Supervised learning : in this case we have data available with input and output, that can be numerical or simply labels (if nominal or categorical). The main problems of SL are known as regression (when outputs are numeric) or classifications (when outputs are labels).
  • Unsupervised learning : thoughter than SL but way more common, does not require the existence of labels or outputs, but sees if there are groups or patterns without, or with a minimum quantity of prior knowledge. This type of learning steps into a general problem called structure/pattern discovery. Supervised Learning #1: more characteristics Learning is supervised when we have data where we can learn using features (outputs or labels). The main idea is to have a matrix, that is X, where columns represent variables and rows represent samples. The features are then represented into a vector that we can call Y. The goal of supervised learning is to find that function that, given X, get us to Y, approximating it as best as it can. We can identify two main cases:
  • When the feature vector is represented by (two) labels, the problem is of ( binary ) classification. If we consider an example of 2 variables explaining our dataset (represented by dots), and we know that data are coming from a specific class without knowledge on the rule, we can set our rule by defining a separating function. What we can obtain is not perfect but has to be good enough.
  • When the feature vector is a continuous-valued output, the problem is a regression. In this case we represent inputs and outputs graphically and dots are the dataset. We can define a regression function, starting from very simple models as a benchmark. In supervised learning, then, we are making predictions on new data that are coming. But we have to make sure that these predictions are functional. That’s why we usually do not use the whole dataset to obtain a rule, but we divide it into two sets, called training set and test set. Then we follow this simple procedure:
  1. We define our training set that are data for our system.
  2. With this set of data, we look for the rule.
  3. Now, having a rule, we test it both with training and test set , having not a 100% fitting with training and trying to find the best compromise between training and test.
  4. When we test the rule, we can find out what are false negatives and false positives in classification problems or errors into regression problems. Now the goal is to minimize one of these quantities, like false negatives, basing on their relevance.

Supervised Learning #4: conclusions Now that we said everything to now about supervised learning algorithms, we can resume everything with these take-home messages:

  1. We need to check on our data quality, ensuring that these are representative and that the do contain low-level biases.
  2. We must build models that overcome data issues and that generalizes to unseen data (during the step of model generation).
  3. Usually data are messy, that’s why we need to make data cleaning in AI (concerning things like interoperability, protocols and some other annoyances).
  4. Use all the strategies you can find to fill in the gaps in incomplete data, when there are.
  5. Methods can be based on how data are: structured, time-dependent,… All these things going through, like data cleaning, management, domain experts and data collection should always be done with a purpose. So data can enter a lifecycle described by the figure below. Unsupervised Learning #1: introduction If in SL we saw both input and output, we can’t see the same on Unsupervised Learning: we do not have outputs or labels, just data. The problem of classification or prediction now becomes a problem of structure or pattern discovery.

That’s the base concept: we have a set of observations ( x 1 ,^ x 2 ,…^ ,^ xN ), like genomic data, medical images

and so on. Assuming that the vector comes from a probability distribution Pr ( X ), we have to directly

infer the properties of this probability density without the help of a supervisor or a teacher providing correct answers or degree-of-error for each observation. An important thing is that, given a dataset, sometimes we have to see clearly if there is an initial pattern by view, in order to make some initial considerations: that’s why we can make an exploratory analysis before we assure that we can set up a protocol to learn from data. We can use a large quantity of tools, like PCA for dimensionality reduction. There are batch of different methods of different complexity. Among these we can define association rules , that represent the basic method, with simple approaches, very common into commercial databases. Having a set of observations we have to find the joint values of the most frequent variables in the dataset: we are

looking for the prototype values ( v 1 , v 2 , … , vL ) such that the probability density for each prototype is

relatively large. So, a natural estimator for each Pr^ (^ vi )^ is the fraction of observations for which X^ = vi.

And, to have a tractable problem, both the goals of the analysis and the generality of the data to which is applied must be greatly simplified. So, at a certain point we have to simplify our problem Unsupervised Learning #2: clustering Creation Processing Analysis Preservati on Access Reuse

Another method for unsupervised learning is the so-called clustering : its goal is to find similarities between objects, represented by our data or observations. These methods, in general, are called partitional clustering , because they partition space into regions that we can use to assign new data. It works such that pairwise dissimilarities between those assigned to the same clusters tend to be smaller in than those in different clusters. We can set up several algorithms to make clustering, that are divided into three main groups. Combinatorial algorithms work on data without looking on underlying probability models, assigning each observation to a group of clusters, labeling the observation with an integer. A number of clusters K has to be set as a parameter of the problem, one of each is encoded by an integer. The goal for these algorithms is to find the optimal encoder, where the key point is the optimality. The idea is such that it satisfies the minimization of a measure over the observation pairs and their similarity degree. A simple example can be found in the computation of the total point scatter : this is a quantity constant, given the data.

T =

∑ i = 1 N ∑ i'^ = 1 N

di i' =

∑ k = 1 K ( ∑ C ( i'^ )= k di i' + (^) ∑ C ( i )^ ≠k

di i'

)

= W + B

W and B quantities are the within-point-scatter and the between-point-scatter. We can set up a mathematical loss function for W and attempt to minimize it, corresponding to maximize B. Such optimization by complete enumeration is feasible only for very small datasets, then the number of distinct assignments becomes quickly very big. Another group of algorithms is called mixture modelling , where we can set up protocols that estimate the probability density functions with Bayes methods. Then we can cite mode seekers , estimating distinct modes of probability density functions without parametric approaches. Unsupervised Learning #3: K-Means K-means algorithm is an iterative descent clustering method in which variables must be quantitative and their space endows with Euclidean distance. This tool uses a few prototypes, Euclidean distance as similarity parameter and the number of cluster K a-priori fixed. The value of K is chosen by making an exploratory analysis or by advice of the expert following the project. Also, if there is some kind of prior knowledge, this doesn’t mean that a problem of UL becomes a problem of SL. Basically the algorithm works in a way like this:

  1. We first try to randomly guess the prototypes, picking k data points from the data set.
  2. Then, we can use these prototypes to make assignments, by grouping all the data points that are closer to the prototype (by Euclidean distance).
  3. We now move the prototypes towards the position of the mean of every Euclidean distance measured.
  4. Then we check the points, asking if them are again the closest to this new prototype, making some changings. 3 and 4 are repeated until we get convergence. This criterion is not optimal in certain cases, for instance cluster with elongated or strange shape. This algorithm is also influenced by outliers and by the data pre-processing we make, like data normalization. See https://k-means-explorable.vercel.app with Google Chrome to see more details. Unsupervised Learning #4: Model Assessment in Clustering K means, between all the other algorithms we can use to divide our data in clusters, doesn’t give information on how much these results have a high level of performance. That’s why we need to perform some quantitative analysis of the results. There are several clustering performance evaluation metrics proposed in literature, but we can focus on five of them.
  • A clustering result satisfies homogeneity if all its clusters contain only data points which are members of a single class.
  • A clustering result satisfies completeness if all data points that are members of a given class are elements of the same clusters.
  • V-measure is a harmonic mean between homogeneity and completeness.

use AI to solve all complex tasks, and this can be improved only if experts and programmers/analysts are communicating the right way. From our side, what we can do to make our best is to keep in mind the concepts of interpretability (are these models understandable for experts?), reproducibility (comparable results) and Human-Centered AI (because we are producing models designed for human beings). Problems to deal with During the first phases of working with data in ML, we can encounter several problems. One of the greatest in this field is data scarcity****. Sometimes projects are founded to grounded data, and we must pay for this. But there are a lot of possibilities by the way, like Open AI, API Scraping (useful to extract textual info in websites), or the way more common in medicine context, that is Data collected from scratch. This last one can be considered as the ideal situation, but today what happens is that we are dealing with large scale data, often and mistakenly called as big data. Our model must be described by using X and Y, so we need n samples in p variables, that are called measures or features. We often assume that p is a way greater than n (and this, mathematically speaking, could be a problem). But we do not obtain always data collected as X and labels collected as Y: we need to make a pre-processing first. This is an example of poor quality of data, but the quality is not always reflected on this. We can find some reasons:

  • Missing or incomplete data : Machine Learning methods cannot work if there are blanks, but for cases like this one we can act an imputing, by using a particular matrix. If our data are numerical, the idea is that the blank space can be the average of the rest: it is probably not the real value, but this is a way better choice than use an arbitrary number.
  • Interoperability : we need data giving information to make each individual sample comparable with the others, meaning that these ones are coming from the same source or that, generally speaking, are using the same standard.
  • Data cleaning : the ideal dataset is the one full of measure, but in medicine this is not a case for so many reasons. Using different modalities, selecting between different groups and working with other structures or colleagues, we obtain data that are messy because of this variety of sources. An example of data messy is what is called longitudinal incoherence , that is a follow up without some modalities made into the first examination. We can use several modalities to make a non-messy analysis, but then we must consider other modalities we took behind. Made our pre-processing procedures, we can encounter other problems, that are, for example, the unbalance into datasets. For example, in a classification we have 100 subjects, with 80 belonging to 1 and 20 belonging to 2. Ideally, we can stop there and gather more data to fill in the blanks and make a more balanced analysis, but this is not feasible if we do not have the right resources. What we can do, by a practical way, can be resumed in 2 phases :
  1. Training : as we saw in the last chapters, we can split our dataset and use some of these data to make training; to solve the unbalance problem, what we can do in this phase is to make undersampling or oversampling, and both can have drawbacks. Even if the algorithm is working, we do not care of some data from a side or we can encounter computational issues to the other.
  2. Testing : as we saw before, the other slice of the splitting is the testing set; here we can set some measures to deal with unbalanced situations. Some reflects into assessment measures, like accuracy : if we have 37 green things and 5 orange things, we can reach an accuracy of 88%, that is, coincidentally, the ratio of green things between the whole set. Another problem is the limited amount of data: normally in this case there’s not so much to do instead of studying well the problem. We must pick the right algorithm and to use all the prior knowledge we have, and that’s the key part in training phase. In testing, if we do not have much representative data, we can take all the available data and use some strategies commonly used in machine learning, such as k-fold cross validation (keeping k slices), leave-one-out cross validation, boosting c.v. and boot-strap c.v. But be aware: for every step we make, we can define (mathematically speaking) a different model. The last of the problems we can encounter is that features can be irrelevant or unwanted , so redundant, misleading, or non-informative. Normally the solution is to take correlation into account, select right variables, use prior knowledge and domain experts. Model Formulation

Once concluded all data preparation, we can finally define a model. In medicine we often encounter multivariate models but also models with latent variables representing all the hidden phenomena involving some measures. For models like these we may not be able to measure all variables, but we can obtain better results by interdisciplinarity. But back to the model formulation, we got the X representing our input data and Y representing our labels. The goal is to find the f that better approximates Y from X. We can define two main common situations: when Y is nominal we can define a classification problem, that can be binary or multivariate. Then there is regression , in which we must approximate a curve. Moving towards medicine, the classification problem is often used in diagnosis, in particular binary one can represent healthy and sick subjects. We can also consider a multiclass problem, for example in genomic analysis or in disease staging, or also in differential diagnosis. The keyword used in problems like this is the “one-hot-vector”: this is a way to represent nominal labels by using a binary code. For example, if we have green, red and blue as labels, we can set respectively 100, 010 and 001. But why can’t we use simply 0, 1 and 2? We can, obviously, and this is called “integer encoding”, but integer values have a natural ordered relationship between each other, and some ML algorithms can understand and harness this relationship: if it is reflected also on our variables, it can be used, but this is not the case of red, green, and blue. And if we got more and more labels to make a classification, if I use integers ML algorithms can muddle and make an unwanted regression. Machine learning algorithms are used also in prognosis, but this is a more complex approach, because our method must incorporate time (because matrices are changing, both for regression and classification). In any case, the goal is the same: compute the best function. Machine learning is full of methods: basically, there are few that are like decision trees belonging to a specific problem, but others, like support vector machine (see later), belonging to all. This time, we consider deeply two methods: least squares and support vector machine. Least Square Method The least squares method can be considered in both problems. Starting from regression, we have data points in x and y. The goal is to find a function that best approximates y depending on x. The distance between the real y and the predicted y is near to 0. There are different functions doing the job, but we must identify the one that is the simplest possible. The easiest case is to use a model of linear function and then set parameters to best approximate data: we make a linear approximation. By design, the model of a linear function is

f ( x )= mx + b , where m and b are the parameters to learn. To do that, we define a measure of approximation,

called loss function , that is min f^ L ( f^ (^ x^ )^ ,^ y ), meaning what we just said: f ( x )− y ≅ 0 .We have freedom on

the loss function, but we commonly use distance or square loss. There are also other functions that are more used in classification problem. But in regression, we can set an example of algorithm: it consists of taking all the errors for data point and then compute m and b to obtain a minimized error. In formula we have that:

min

m ,b ∑ i ( f^ ( xi )−^ yi ) 2

= min

m ,b ∑ i

ei

2 This reflects on these expressions for m and b, having n samples:

m =

n (^) ∑ i xi yi −∑ i yi ∑ i

xi

n (^) ∑ i

xi

2

(∑ i

xi

)

2 ;^ b =

∑ i yi − m ∑ i

xi

n

  • Values closer to 0 correspond to nothing better than a random prediction
  • Values closer to -1 correspond to a total disagreement between prediction and observation The correlation is in fact measured between observations and predictions. The formula is:

MCC =

TPTN − FPFN

√(^ TP + FP )^ (^ TP + FN )^ (^ TN + FP )^ (^ TN + FN ) Another method used in assessment is the representation of the receiver operating characteristic curve , better known as ROC curve , a graph showing the performance of a classification model at all classification thresholds. This curve plots two parameters: one is the true positive rate, or sensitivity , as we know it and the other is the false positive rate , corresponding to 1-specificity as we know it. It plots these values at different classification thresholds. Lowering the classification threshold, more items are classified as positive, thus increasing both false positives and true positives. This figure represents a typical ROC curve, where the area under the curve is a real parameter of the accuracy of the model. We can say that: AUC value Model

AUC =0.5 Not informative

0.5< AUC ≤ 0.7 Low Accurate

0.7< AUC ≤ 0.9 Moderately accurate

0.9< AUC <1.0 Highly accurate

AUC=1 Perfection Regularization methods: an introduction When we introduced the problem of supervised learning, we also introduced the notions of underfitting and overfitting, saying that when we search for a model for our data, we need it simple, but not the simplest one. I can consider errors, counting and minimizing them, but without deleting them at all. The problem of overfitting, recurrent in medicine AI, comes when training has a 100% match, with a lowering assessing to the test set. The best we can do is to balance the outcome of training and testing sets. The opposite problem is underfitting: we can see that, for example in a LIGO experiment, that there is a trend but with a function that does not capture some other things. In the underfitting case, the model does not care about the data, or better, data does not contain enough information, or the training set is not big enough. In this case I can reduce model complexity or increase training size. The decision depends on what I’m working on, we must ask ourselves if the training size increment increases costs. Between the solutions we can apply, the most used are falling into regularization methods. These are a very wide class of methods dividing the problem in two parts: one referring to the fitting, making the comparison between y and f(x), and the other referring to the regularization, dependent only on the function f(x) we obtained. It can be described with this formula:

min

f ( L^ ( f^ (^ x^ )^ ,^ y^ )+^ λR^ ( f^ (^ x^ )^ ) ) The part referring to the fitting uses the loss function that search for the function f(x) as we saw on the

previous pages, then R is called regularization function , pondered by the λ , that is the regularization

parameter or penalty. By making an example, the loss function can find our linear model, but we need it not so much vertical, and that’s where the regularization works. Of course, we must minimize this expression. So, having x and y, we can find our best f(x) approximating y, with the perfect solution passing through all data, but then we are given a test set that does not satisfies the similar conditions made up on the training part, with different errors; that’s why we need regularization. Now the question is how to choose the parameter lambda. Considering, for example, a classification problem:

  • When λ is too small, we have fitting much more than regularization (L>>R), obtaining overfitting.
  • When λ is too big, we have the opposite (underfitting) because regularization is oversized (R>>L). The right parameter stands in the middle, normally is empirical and depends on data, but the thing is that we cannot use all data to choose that parameter, so we find lambda on the first split and then we assess our model. Regularization methods: cross validation

But how this can be made in practice? There’s not so much to do rather than split our set. We make our first split by making learning and testing sets. Our test set is the benchmark, and that’s why we leave it separate from the rest. We start working into the learning set, splitting in two parts that are called training set and validation set. Each time we try a different lambda parameter setting a range of values. Then we validate the function getting an error. We can try different lambdas by making different chunks, then we are happy with that lambda minimizing the average error. This problem can be represented like this:

Chunk 1 er r 11 er r 12 er r 13 er r 14

Chunk 2 er r 21 er r 22 er r 23 er r 24

Chunk 3 er r 31 er r 32 er r 33 er r 34

Chunk 4 er r 41 er r 42 er r 43 er r 44

Chunk 5 er r 51 er r 52 er r 53 er r 54

AVERAGE

e 1 =

∑ i

er ri 1 e 2 =

∑ i

er r i 2 e 3 =

∑ i

er r i 3 e 4 =

∑ i

er ri 4

Sometimes regularization is composed by more than just one term, but the idea remains the same, regardless of the complexity of the model. This is what is done on cross-validation , meaning that we learn functions by repeating the process with more validation parts. At the end of the story, this is what we can do in practice in four passages:

  1. Having our raw data, we make our feature extraction to end up with matrices.
  2. Make the split between training and testing sets.
  3. Sometimes we must learn with sparsity, so there are algorithms that are looking for relevant features (see later). We tempt to do first feature selection and then learning, or we can make this all together into a single process (embedded variable selection, see later).
  4. Then we end up with a trained model that must be assessed: we are done when we got the best score. Regularization and Accuracy What if we pick up other data? Will the result be the same? Sometimes no. So, we do not prefer just one list of feature or just one accuracy score, but we can split differently or make more than just a split. So, we got different models, different lists, and different scores. But at the end the accuracy is the parameter that we must care it to be stable. Let’s clarify this sentence with an example into classification: we can start from the whole dataset for each experiment and, as always, we split it in training and testing. We learn our model and we get an accuracy score, every time sampling different learning and testing sets. This way we end up with a distribution of accuracy scores and thus have a much clearer idea of how much we can learn a model which is predictive, having ruled out the randomness included by the split. But how these results are demonstrated to be valid? What we can do is to shuffle all variables, or, in plain words, to make a random labeling. Making all the same we did for the right labels, if our job is good, we obtain an accuracy distribution that is totally different from the right-one and that is putting its trend in 50% (meaning that the binary classification problem with random labeling is representing a tossing coin-like phenomena). We can check its difference by using a statistical test to explain the difference between distribution, collecting its p-value. The next figure shows the complete pipeline of the learning process, basing on what we just said.

feature space, so that data points can be categorized, even when data are not otherwise linearly separable. This can be considered as a regularized method basing also on the function: min (^) ∑ i = 1 n V (^) ( f (^) ( xi ) , y (^) )+ λ || f || k 2 The loss function here represented is called hinge loss : it consists of having no penalties when our data are correctly classified; in the opposite case, we set a higher loss, basing on how the error is great (mathematically speaking, the more the distance from the boundary increase (setting into the wrong area),

the more the loss increases). If we consider our model as linear, like f ( x )= h ( x )

T

β + β 0 , our hinge is:

min

β (^) 0 ,β ∑ i = 1 n [ 1 −^ yi f^ (^ xi )^ ]+^

|| β || 2 Kernel Methods The last family of methods is the one called kernel methods. We’d like to solve linear methods, but what happens when our input space is complex? Kernel methods give us the answer by transferring the problem into the feature space, that means we are working into different dimensions and defining linear problems in these terms. We can use several functions to make this transfer, like the gaussian kernel or RDF. Other – not into quiz!! These are not the unique methods used. In fact, we can also consider k nearest neighbors that is an algorithm based on data point’s closeness. We keep a training group of classifications, and we consider the new data points classified on that (most frequent) group belonging to the k points next to him. It does not always work well because of the position of the new data, but this can be easily solved by choosing the right k, considering that it can’t be too small (because noise can affect the classification) neither too big (because unbalance can affect the classification). Another method used is the one called random forest : with the assumption that we know about the construction of a classification tree, this method grows many classification trees, each one affecting the general error rate basing on the correlation between couples of trees and the strength of each tree. The construction of that forest is also based on the training we make. To classify a new object, we put the input down every tree, each one giving a classification (or “voting” for the class) and then the object is classified into the most voted group. Feature Selection in Machine Learning In lots of machine learning problems, we often interface with large datasets having a particularly large whole of features, often regarding redundant and noisy information. So that’s why we need feature selection : this is an operation primarily focused on removing non-informative or redundant predictors from the model. This is

an advantageous process, having an impact on the supervised learning problem and making the overall learning process cheaper by a computational point of view, but it also reduces the complexity of a model making it easier to interpret, improves the accuracy of the model when right subsets are chosen and reduces overfitting. This process is important, especially when dealing with medical data: a feature can be a geometric property into a medical image, a specific gene to describe the development of a tumor, or some biomarkers to identify into molecular data. There are lots of examples for variable selection: these are very relevant despite they probably belong to the deep learning class (see later). Into these examples there aren’t the already saw methods regarding dimensionality reduction , such as PCA, because these methods simplify the problem by projecting the whole set of features into just 2 or 3 new features, without removing the old ones. In feature selection, instead, we remove all the features we are not interested in. These examples can be divided in three families of methods: filter, wrapper, and embedded methods. Filter methods evaluate the relevance of the variables outside of the predictive models and subsequently model only the predictors that pass some criterion. So, into a supervised learning problem, we check every single feature at a time, subjecting them to a filter, that classifies this feature as relevant or not, basing on some criteria we defined. By a mathematical point of view, we can say that:

X n, p Y n → Xn , p ¿ Y n with p

¿

≪ p

Let’s see an example in classification: for each variable we can set, as our filter, a hypothesis test such as χ^2 ,

ANOVA, t-test and so on, obtaining a p value for each. Then we can rank our features basing on this p-value, then discarding all the variables having a p-value greater than a threshold we decide. Sometimes we need also to make corrections Bonferroni -like and to consider correlation, cause filter methods does not take this automatically, and it is useful when an enrichment analysis (add features) is necessary. Filter methods are simple and fast, scaling well to high dimensional data and being independent of the classifier but this is, generally, a univariate or low-variate method. (*2). Wrapper methods, instead, evaluate multiple models using procedures that add or remove variables to find the optimal combination that maximizes model performance. It generates the subset by what we can obtain from the learning algorithm, with an iterative process. The clearest example is the recursive feature elimination in support vector machine, known as SVM-RFE. We start with our original set made by p

features, with p very big. We start our training process with SVM obtaining the β coefficients as the weights

of the model (see last chapters). We rank them and we discard the worst 10, and then we go back to our sub- featured matrix, and we restart the process. In medicine, we use these methods especially when we analyze medical images, because are requiring lots of data. These methods select a near perfect subset and the error rate is less as compared to other methods. But there are also cons: these methods are computationally very intensive and are intended for the learning machine on which it has been tested; therefore, there is a high risk of overfitting than filter techniques. Then, embedded methods are called so because there are some model containing a built-in feature selection, meaning that the model will only include variables that help maximize accuracy. So, having a set of features we directly feed them to the learning algorithm including both training (with performance analysis and optimization) and feature selection. Their functioning is based on a specific regularization to enforce sparsity, meaning that the more the function is regular, the less are the feature selected. Depending on the loss and on the algorithm, we can define different models, but we can define some examples into the least square method. We start considering, as a premise, the already seen RLS , in which add a simple constraint to the OLS to have regularization, and this is written like:

RLS →min

β

[|| Xβ − Y ||

2

  • λ || β || 2

]

In this regularization we do not cancel features, because there are no coefficients set to 0 that, from a mathematical point of view, cancel some X’s columns. So, what if we decide to make it possible by taking

β p =^ p −^10

p =

[

βp − 10 ( best )

β 10 (^ worst )^ ]

X n, p Y n β p

SVM

Data\Labels Continuous Categorical Continuous Pearson’s Correlation LDA

Categorical ANOVA Chi-Square ( χ^2 )

Deep Learning Deep Learning, in a sense, it has become a synonym for AI, also because it is used in several and popular applications: for example, the most popular systems available in free trial in Open AI, like chat GPT (a chatbot capable of understanding a question and formulating an answering text) or Dall-E (image generator based on the description you give), but is also widely used in medical applications, such as medical imaging. In this section will be discussed Deep Learning’s functioning and some of its limitations (such as the computational power, considering that in DL methods we need more and more data than in ML methods and that we have to choose also between some hyperparameters). We already know that DL is a subset of ML that is a subset of AI. In this case we consider the same problems as we did in ML, so classification and regression, but with a different methodological approach, considering that in this case we are not searching for a model able to solve the problem, but we are searching for the best parameters for some existing architectures, that are called deep neural networks. What is a neural network? The concept of neural network is not new by a theoretical point of view, but the news is that we are finally capable of computing them (even if is not so easy and quick). In networks we can define a simple structure, in which input elements (variables) are connected to each output element (label): connections are based on parameters that has to be learned by minimizing some functions. Input and output elements, in DL slang, are called layers. It’s easy to explain why these networks are called neural: in fact, the theoretical principle is similar to what happens in neurons, where different stimuli are arriving at the same time from neighborhood’s neurons, and its response can be represented by an activation function (that is called action potential ), firing the response basing on the weighted sum of the stimuli arriving. So, we can follow this neuron parallel to define the architecture of our network, based on three operations: weight, sum up and activate. This concept is not new, and it has been formulated in 1958 by Mr. Rosenblatt , when he defined the perceptron , the simplest neural network ever. Perceptron takes into account all the signals coming in input with their weights and a bias , going into the activation function. That is, in formula:

^ y = f ( x )= φ

( w 0 +∑ i = 1 m

xi wi

) Now, if we consider a matrix, each element undergoes through this transformation. We can optimize for all data points we have. This schema is then considered for all data points, obtaining just one element of y. In a sense, we got this: ^ yi = φ ( Xi^ T^ W + w 0 ) So, there are different parameters for a different element of Y and that’s why we use several parameters in NN. The classical examples functioning with perceptron are the simplest linear problems, like the OR and the AND functions. These are both used in disease classification. Consider a bidimensional output, where 0 correspond to normal and 1 not. When diagnosis requires at least one variable equal to 1, we need a OR function, and when diagnosis requires both elements equal to 1 we need the AND one. Here we got all the activation functions f(z) that are considered:

f ¿ (^ z )=

{

1 z > 0

0 z ≤ 0

; f ¿ (^ z )=

{

1 z > 1

0 z ≤ 1

What are DEEP neural networks All it’s easy and linear, until we encounter more complex problems like the XOR function. A linear model is not able to solve this, but we can consider it as a combination of AND with OR: better saying, we verify if x_1 and not x_2 gives TRUEORnot x_1 and x_2 gives TRUE. By the architectural point of view, we have added an intermediate layer to the classical perceptron and obtained a multi-layered perceptron. This intermediate step is called hidden layer, and when we got hidden layers we got deep neural networks, where each of the edges represents manipulation of the previous layer. To obtain a more complex model, we have just to add more and more hidden layers. In a practical way we can use some already trained networks or different architectures belonging to the most popular deep learning methods, such as geometric deep learning and convolutional neural networks. In deep learning methods, we can find the optimal representation and the best model using raw data: we don’t need feature extraction as we needed in ML and we just skip the part of ordinary pre-processing. Shallow vs Deep Another example of neural network is the one referring to shallow neural networks: this is a family of deep learning methods used when the dataset is too small for deep neural networks as we knew. These networks are composed by just 1 or 2 hidden layers, but with a large number of neurons per layer comparing to input and output. There is a theorem (Cybenko, Hornik, Stinchombe, White, Allan Pinkus; 1989-1999) saying that a neural network with one single layer is a universal approximator , i.e., it can represent any continuous

function on a compact subset of Rn^ with error 0. It means that in theory shallow networks can model any

problems, and in practice just one layer is enough to solve problems but having an exponential number of neurons to get a prediction error close to 0. We still have a high number of parameters to learn, so that’s why we more often fall into usual deep neural networks with more hidden layers. Learning process and hyperparameters From a mathematical viewpoint, we have a series of different layers transforming the input according to functions and weights. Choose the right architecture it’s easy, but we still have to learn these weights for each transformation. We can use an example in imaging: we often use pyramidal approaches to have information at different scales, so we can consider each layer of a DNN as some parts of the image, extracting information at different scales. So, let’s see how to train our deep neural network. In formula, we can consider this: h 1 = φ (^) ( w 0,1 + X T W (^) 1 ) → h 2 = φ (^) ( w 0,2 + h 1 T W (^) 2 ) → … → hH = φ (^) ( w 0 , H + hH − 1 T W (^) H ) → ^ y = φ ( w 0 , H + 1 + hH T W (^) H + 1 ) All the W are the parameters to learn from our data, but there is also the problem of the activation function. At the end, we set all the neurons and the function deals with an optimization problem. The selection of the right activation function is important because it introduces non linearities in the model. There are lots of examples, but the most used are the logistic function and the ReLU. Once we have chosen the activation function, we end up solving the problem by learning the parameters, made by using a loss function and optimizing according to all data points. In practice, we use a random start at time 0, and we update at each timestamp, or epoch , iteratively. This process is regulated by another

hyperparameter, called learning rate ( η ), determining the length of the step. This hyperparameter cannot be

set a priori so easily:

  • Google photo takes advantage of an algorithm to search images by text. It uses a deep learning algorithm, trained on millions of inputs.
  • There are also some services generating artificial images or realistic photos, trained with high quality photo-sets, in terms of DPI.
  • Deep learning in diagnosis: it is used to discriminate subjects from the biomarker viewpoint, meaning not only molecular or biological data, but also some other things like medical images.
  • Sometimes DL and ML are combined: for example, in MRI, we can automatically extract features by segmentation made with deep learning methods; then, we can use these features to make machine learning.
  • In some cases, deep learning could be a problem, because data are not big. This is what can happen in MRI datasets. 150 patients: a number that is too small for DL. This is not the case for breast cancer data: a different storing and many data points.
  • Deep learning is the base for most of the algorithms used in natural language processing: this is a problem well studied in digital health, because sometimes we need data (like recurrent patterns in a disease or drug treatment tracking) that are coming from a wide description in a common language taken from medical reports.
  • Feed Forward DNN are used to treat features in order to make classifications; for example, we can make a classification for diabetes.
  • Recurrent neural networks are used for audio processing; this is the principle used in most of the vocal assistant as Alexa, Siri, Ok Google and so on and it is also used in medicine to process impaired speech , to obtain a text from speech enhancement.