









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!










Sometimes, machine learning systems for non-medical data can be adapted for medical data, but sometimes they must be tailored to medical data: machine learning techniques must handle the shortage of medical data, that are, also, usually protected by restricted data access and distributed machine learning algorithms, that do not require data pooling, may be needed. Machine learning is the field of study that gives computers the ability to learn without being explicitly programmed: it’s the science (and art) of programming computers so they can learn by extracting patterns from raw data. Comparison between the traditional approach and the ML approach: Usually, we don’t apply the algorithms directly to the data, due to the heterogeneous and complex data sources; instead, we extract features from the data, that are measurable characteristic detectable properties.
The feature extraction is included in the deep learning algorithm, while in the traditional ML algorithm the features extraction is performed by humans. Deep learning is a particular kind of machine learning that achieves great power and flexibility by representing the world as a nested hierarchy of concepts, with each concept defined in relation to simpler concepts, and more abstract representations computed in terms of less abstract ones. The deep learning algorithm is more complex wrt the traditional one, so also the training is harder and not always the dataset size is larger enough. Signal (data) processing scheme: Algorithm inputs are features (salient characteristics) obtained by processing biomedical data/signals/images. Basics of Hardware for AI: CPU (Central Processing Unit): manages all the functions of a PC GPU (Graphical Processing Unit): enhances the graphical performance of a PC TPU (Tensor Processing Unit): custom build application specific integrated circuit (ASIC) to accelerate TensorFlow projects Usually, ML algorithms run on the CPU (also on multiple CPUs). The GPU is a processor optimized to perform parallel computing (identical operations on all the data samples), for gaming and graphic, and it has its own RAM memory (small and specialized); if the computation doesn’t fit in the main memory of GPUs, the computation will slow down significantly. TPU is an application-specific integrated circuit, to accelerate the AI calculations and algorithm for a specific app framework. (incomplete) ML taxonomy ML algorithms can be broadly categorized as supervised, unsupervised or reinforcement, by what kind of experience they are allowed to have during the learning process.
All the information in the matrix can be represented by a point A on a 2-dimensional graph (in abscissae the FPs and in ordinates the TPs): the ROC curve (Receiver Operating Characteristic curve). A dichotomous classifier, corresponding to a confusion matrix, is represented by a point in the ROC plane. The point (0,0) represents a classifier that always answers "N”. The point (1,1) represents a classifier that always answers "Y”. The point (0,1) represents the perfect classification. Example with 10 positive and 10 negative instances (ordered by score): Any ROC curve generated by a finite number of instances is a step curve that approximates a continuous curve as the number of instances tending to +∞. A threshold of +∞ produces the point (0,0). As the threshold decreases, the points will move up and to the right (note that decreasing the threshold corresponds to moving between a "conservative" to a "liberal" area of the ROC plane). If, for example, a random classifier responds with the positive class half the time, it is expected to take half positive and half negative cases correctly: this gives the point (0.5, 0.5) of the ROC plane. If it responds with the positive class 90% of the time, it is expected to take 90% of positive cases correctly but the TPs will rise to 90%: this gives the point (0.9, 0.9) of the ROC plane. The random classifier then produces a point on the diagonal of the ROC plane that depends on the frequency with which it predicts a positive response and any classifier that ranks in the bottom triangle has lower performance than the random classifier (usually this triangle is empty). The ROC curve is a 2-dimensional graph that represents the performance of a classifier. To compare various classifiers, we want to reduce the ROC to a single scalar that represents their performance. One commonly adopted method is to calculate the area under the ROC curve ( AUC ), between 0 and 1; It’s worth 0.5 for the random classifier, so for a realistic classifier AUC > 0.. The AUC of a classifier is equivalent to the probability that a classifier predicts a score of a randomly chosen positive instance to be greater than that of a randomly chosen negative instance. The ideal ROC curve joins the points (0,0), (0,1) and (1,1), that means it’s a unit area curve (max possible area). If 2 ROC curves don’t intersect, the classifier whose curve is higher than the other is the "better" one (higher AUC).
If the 2 curves intersect, one must limit the calculation of the subtended area in the range of interest for the application, for example high specificity (low FP values) or high sensitivity (high VP values). Example of regression task in ASD:
Supervised Learning: LINEAR REGRESSION The goal is to build a system that can take a vector x∈Rn^ as input and predict the value of a scalar y∈R as its output. The output of linear regression is a linear function of the input.
that determine how much each feature affects the prediction: if a feature xi receives a positive weight wi, then increasing the value of that feature increases the value of our prediction; otherwise, if a feature receives a negative weight, then increasing the value of that feature decreases the value of our prediction. If a feature’s weight is large in magnitude, then it has a large effect on the prediction; otherwise, if a feature’s weight is zero, then it has no effect on the prediction. Next, we need a definition of the performance measure. Suppose that we have a design matrix of m example inputs (that will not be used for training, but only for evaluating how well the model performs, so we call it “test-set”) and a vector of regression targets (providing the correct value of y for each of these examples). Both for the training and test datasets, we have the overall design matrices, from which we extract only the intersection samples.
predictions of the model on the test-set. One way of measuring the performance of the model is to compute the mean squared error (MSE) of the model on the test-set:
predictions and the targets increases:
We need to design an algorithm that will improve the weights w in a way that reduces MSEtest when the algorithm is allowed to gain experience by observing a training-set (X(train), y(train)); so, we have to minimize the MSEtrain and we can do it imposing that its gradient is equal to 0: The system of equations whose solution is given by this last equation is known as the normal equations (plural because w is a vector). The linear regression with the intercepted term b (bias) is also called “affine” and it must be used when we don’t know if the line crosses the zero axis or not. The mapping from parameters to predictions is still a linear function, but the mapping from features to predictions is now an affine function, meaning that the plot of the model’s predictions still looks like a line, but it doesn’t need to pass through the origin. Instead of adding the bias parameter b, we can use the model with only weights, but augmenting x with an extra entry that is always set to 1: the weight corresponding to the extra entry plays the role of the bias parameter. The machine learning algorithm must perform well on new, previously unseen inputs and not just those on which our model was trained: this ability is called GENERALIZATION. Typically, when training a ML model, we have access to a training set, so we can compute some error measures on this training set, called “training error”, and we want to reduce this training error, that is an optimization problem. What separates ML from optimization is the fact that we want the generalization error (defined as the expected value of the error on a new input), also called “test error”, to be low as well. We typically estimate the generalization error of a ML model by measuring its performance on a test-set of examples that were collected separately from the training set. Training error = Test error = How can we affect the performance on the test set, when we can observe only the training set? The training and test data are generated by a probability distribution over datasets called “data-generation process”. We typically make a set of assumptions known collectively as i.i.d assumptions :
The most sophisticated algorithm we can conceive of has the same average performance (over all possible tasks) as merely predicting that every point belongs to the same class. Fortunately, these results hold only when we average over all possible data generating distributions and the goal of ML research is not to seek a universal learning algorithm or the absolute best one: instead, the goal is to understand what kinds of distributions are relevant to the “real world” that an AI agent experiences and what kinds of ML algorithms perform well on data drawn from the kinds of data-generating distributions we care about. REGULARIZATION The no free lunch theorem implies that we must design our machine learning algorithms to perform well on a specific task. We do so by building a set of preferences into the learning algorithm: when these preferences are aligned with the learning problems that we ask the algorithm to solve, it performs better. So far, the only method of modifying a learning algorithm that we have discussed concretely is to increase or decrease the model’s representational capacity by adding or removing functions from the hypothesis space of solutions the learning algorithm can choose from. The behaviour of the algorithm is strongly affected not just by how large we make the set of functions allowed in its hypothesis space, but also by the specific identity of those functions. The learning algorithm we have studied so far, linear regression, has a hypothesis space consisting of the set of linear functions of its input: these linear functions can be useful for problems where the relationship between inputs and outputs truly is close to linear, while they are less useful for problems that behave in a very nonlinear fashion. We can also give to a ML algorithm a preference for one solution over another in its hypothesis space, meaning that both functions are eligible, but one is preferred: the unpreferred solution will be chosen only if it fits the training data significantly better than the preferred solution. For example, we can modify the training criterion for linear regression to include weight decay. Linear regression with weight decay: we minimize J(w) expresses a preference for the weights to have smaller squared L^2 norm:
Minimizing J(w) results in a choice of weights that make a trade-off between fitting the training data and being small: this gives us solutions that have a smaller slope or that put weight on fewer of the features.
Since the validation set is used to “train” the hyperparameters, the validation set error will underestimate the generalization error, though typically by a smaller amount than the training error does. After all the hyperparameter optimization is complete, the generalization error may be estimated using the test set. In practice, when the same test set has been used repeatedly to evaluate the performances of different algorithms over many years, we end up having optimistic evaluations with the test set as well, that don’t reflect the true field performance of a trained system. The community tends to move on new and usually larger benchmark datasets. If the 3 distributions are not similar, we are introducing a bias in our model. Situations with a small number of samples (small dataset, typically in the medical field) require the CROSS VALIDATION scheme , to be able to use all the examples in the estimation of the mean test error (in order to not have too small training and test sets), at the price of increased computational cost. These procedures are based on the idea of repeating the training and testing computation on different randomly chosen subsets/splits of the original dataset. The most common of these is the K-FOLD CROSS validation , in which a partition of the dataset is formed by splitting it into K non-overlapping subsets and the test error is then estimated by taking the average test error across K trials. For example, for K=10 we can train the algorithm in the first 9 training folds and test it in the last one, the test fold; then we obtain other performances, for a totality of 10 iterations, changing the test fold (each time the training set covers the 90% of the data set). The final performance is the average, obtained considering the data set as equal to the overall the test set. 2 successive iterations experience a strong overlap. If the number of folds is equal to the number of samples, it’s called “ leave one out ” and the test fold is just 1 sample. Now I have 10 models and their average, but computing the average coefficients/parameters doesn’t make sense. So, which model do I use? NONE, because I can just find an estimation of the performance (not the best model, not the hyperparameter value):
I must retrain considering all the data set as the training set, without the test set. Whenever we split, we have DATA LEAKAGE. Example: the input of the algorithm is a 3D MRI image, corresponding to 160 slices → the correct way to split the data is to split the subjects: some are in the training sets and some in the test set. Methodological error: some slices of the same patient go in the training set and some in the test set, so the test set is strongly related to the training set (they aren’t independent). This may lead to very big errors in the evaluation of the level of the training/test set accuracy (the obtained accuracy could be very different to the real one). NESTED K-FOLD cross-validation scheme Nested means inside something: we have 2 cross validations, one inside the other one. We want to assess the performance of the ML model with the outer CV and find the best hyperparameter with the inner CV and apply it to the whole original dataset, obtaining the final model. The outer CV is equal to the basic CV (we split the dataset in K 1 (5/10) folds: 1 for test and K 1 -1 for training and we iterate K 1 times), then, since in the outer CV we can’t optimize the hyperparameter, the inner cross validation is applied to the outer training set, obtaining the inner training set and the inner validation set. We evaluate the error in the validation sets, so that, in the inner loop, we obtain an array of K 2 -1 errors (for simplicity, we consider K 1 =K 2 ), so I find the lowest one and I consider the corresponding hyperparameter, then I train the model in that found degree, I test it in the outer test set and, finally, I repeat the procedure for all the outer CV iterations. So, I evaluate the performance of the outer CV iterations and I choose the model with the best one. In different iterations of the inner CV, the hyperparameter value could vary, but it’s not a problem, because we are evaluating the precision and not the exact value of the hyperparameter.
So different hyperparameters are tried: we train and test in the validation set using a fixed C=0.1, then we iterate this procedure for each of the 5 columns, obtaining at the end an average performance (score). Then we do this for different values of C. Then we compare the average scores, consider the better one and train the outer CV using this best hyperparameter; after, we test the performance in the blue test set and iterate for each outer CV. At the end, we have a performance for each test set of the outer CV and we consider their average as the performance of the whole model. AGE PREDICTION We use these T1-weighted images to display the 3D volume in 2 dimensions. We must pay attention to the orientation of these images: the most popular is the radiological standard/convention and, for example for the axial plane imaging, on the left we see the right side of the patient and vice versa. Another convention is the neurological one, but it’s less used. Algorithms can eliminate the contour or to segment other deep (non-cortical, subcortical) structures. For measuring the volumes, we must count the number of voxels. During aging, the cerebral volume decreases, as well as the thickness of the cerebral cortex (“cortical ribbon”), that normally is about 2.5 mm. This decrease may be different in different cortical regions. We also can extract some complexity features: the gyrification index (Igi) and the fractal dimension (FD). Igi can be used to measure how much the cortex is complex in a certain point: if the cerebral cortex very different from the smoothed normal surface, then the Igi is high, otherwise it’s low. The FD of the brain is normally between 2.5 and 3, but, during aging and with Alzheimer's disease, it decreases.
Feature extraction example: the fractal dimension of the brain Geometrical self-similarity: the magnified piece of an object is an exact copy of the whole object. Statistical self-similarity: the copy is only approximated, it’s self-similar in a statistical sense. It can be proved that in the brain we have a certain statistical similarity between a zoomed part and the whole brain. It’s better to have the correct number of input features that explain very well the output, instead of having too many. We can split the brain into 2 hemispheres and compute separately the features (cortical grey matter volume and white matter volume FDs), for both of left and right side: We can do the same for the cerebellum and for the hemisphere lobes.