scieee AI-readable full text Open interactive document viewer

A study of generalization in regression: proposal of a new metric and loss function to better understand and improve generability

Alpalhão, Nuno Tiago Falcão

Abstract

Intuitively Generalization in Machine Learning can be understood as a models ability to apply its trained or acquired knowledge to a previously unseen scenario. In the recent years there has been an exponential growth in machine learning models both efficiency and accuracy, yet the current research is still trying to understand and trust how well models can perform on previously unseen data. For this thesis we propose a study of machine learning’s theoretical background to further expand the notion of generalization and it’s limitation’s, enabling us to derive its commonly accepted approximation, definitions that we will use to present a new generalization metric or score more consistent in detecting and providing understanding of the occurrence of generalization. Additionally a new loss function will be presented in order to mitigate generalization error inherit to a noisy sample, where extensive tests suggest that our loss function has a higher rate of convergence while producing statistically similar or even better results when compared with classical loss functions.

Full text

\ A Study of Generalization in Regression Proposal of a New Metric and Loss Function to better understand and improve Generability Nuno Tiago Falcão Alpalhão Dissertation presented as the partial requirement fo r obtaining a Master's degree in Data Science and Advanced Analytics NOVAInformationManagementSchool InstitutoSuperiordeEstatísticaeGestãodeInformação UniversidadeNovadeLisboa A Study of Generalization in Regression Proposal of a New Metric and Loss Function to better understand and improve Generability by NunoTiagoFalcãoAlpalhão Dissertation presented as the partial requirement for obtaining a Master's degree in Data Science and Advanced Analytics Advisor: Leonardo Vanneschi January 2021 Generalization in Regression Copyright © Nuno Tiago Falcão Alpalhão, Information Management School, NOVA University Lisbon. The Information Management School and the NOVA University Lisbon have the right, perpetual and without geographical boundaries, to file and publish this dissertation through printed copies reproduced on paper or on digital form, or by any other means known or that may be invented, and to disseminate through scientific repositories and admit its copying and distribution for non-commercial, educational or research purposes, as long as credit is given to the author and editor. Acknowledgements To all who helped me. v Abstract Intuitively Generalization in Machine Learning can be understood as a models ability to apply its trained or acquired knowledge to a previously unseen scenario. In the recent years there has been an exponential growth in machine learning models both efficiency and accuracy, yet the current research is still trying to understand and trust how well models can perform on previously unseen data. For this thesis we propose a study of machine learning’s theoretical background to further expand the notion of generalization and it’s limitation’s, enabling us to derive its commonly accepted approximation, definitions that we will use to present a new generalization metric or score more consistent in detecting and providing understanding of the occurrence of generalization. Additionally a new loss function will be presented in order to mitigate generalization error inherit to a noisy sample, where extensive tests suggest that our loss function has a higher rate of convergence while producing statistically similar or even better results when compared with classical loss functions. Keywords: Generalization; Machine Learning; Loss Function; Metric; Noise; vii List of Tables 6.1 Problem Set Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 7.1 Difference between Custom and Control Test MAE with Wilcox Rank-Sum test p-values on ANN Results on Epoch 50 .................. 34 7.2 Difference between Custom and Control Test MAE with Wilcox Rank-Sum test p-values on ANN Results on Epoch 100 ................. 34 7.3 Difference between Custom and Control Test MAE with Wilcox Rank-Sum test p-values on ANN Results on Epoch 150 ................. 35 7.4 Difference between Custom and Control Test MAE with Wilcox Rank-Sum test p-values on ANN Results on Epoch 200 ................. 35 7.5 Difference between Custom and Control Test MAE with Wilcox Rank-Sum test p-values on ANN Results on Epoch 500 ................. 35 7.6 Difference between Custom and Control Test MAE with Wilcox Rank-Sum test p-values on GP Results on Epoch 500 .................. 36 xv Acronyms ANN Artificial Neural Network. GP Genetic Programming. MAE Mean Absolute Error. ML Machine Learning. MSE Mean Squared Error. xvii Chapter 1 Introduction In the current scenario where machine learning models are increasingly more used in our societal infrastructures the need to ensure they’ll perform as expected in all possible situations is higher than ever. In the recent years there has been an exponential growth in machine learning models both efficiency and accuracy, yet the need to understand and trust how well they will perform on previously unseen data is still a highly debated topic, in other words how well does a model generalize it’s given problem? 1.1 Proposal Overview For this thesis we purpose a study of the mathematical basis of supervised machine learning in order to further understand the notion of generalization. The purpose is to use said theory to arrive at the commonly accepted approximation of generalization, which will enable us to to show the limitations inherent from a chosen model and problem set separately, making the link between the results derived from theory with the common tools that machine learning users commonly use. Definitions required to later introduce a new more robust generalization metric called generalization score that aims to offer more explainability than its predecessor. All of these notions will later serve as inspiration to propose a new loss function intended to improve a machine learning’s model generalization, where a broad study of it’s statistical validity will be undergone. 1 Chapter 2 Generalization in Supervised Machine Learning Intuitively Generalization in Supervised Machine Learning (ML) can be seen as a models ability to apply its acquired knowledge to a previously unseen scenario. In this chapter we will go through the theoretical foundations of ML that led to the classical definition of generalization which will serve as groundwork for the new proposed metrics later in this work. 2.1 Statistical Learning Theory on PAC Statistical learning theory (SLT) [Moh+12] can be understood as the formal background of ML based on the mathematical fields of statistics, measure theory and functional analysis [Lan93]. Probably approximately correct (PAC) [Evg+00] learning is a sub field of computational learning theory focused on the conditions in which a function can generalize a problem [Gol10]. 2.1.1 Data and Probability Spaces Any ML problem begins with a set of pairs ( x,y ) or dataset S from two spaces, the inputs x∈X and the outputs y∈Y both obtained from a random sampling [Tah16] S , i.e: S:= {(x1,y1),(x2,y2),...,(xn,yn)}(2.1) We assume that our random sampling S comes from an underlying probability distribution on a probability space defined by the product space D = X×Y with a joint probability measure µ ( x,y ) = µ ( d ) on D [KBH19]. In other words, the pairs (x1,y1),...(xn,yn) 3 CHAPTER 2. GENERALIZATION IN SUPERVISED MACHINE LEARNING can be seen as independent and identically distributed (i.i.d.) [KBH19] samples from Dthrough µ. For the next steps we will build our results solely on the definitions of X , Y and our measure µ. 2.1.2 Hypothesis Space The intended objective is to predict an outcome y from a target space Y of possible outcomes from given a set of features x in X , in other words to infer a function f that maps [BS51]: fλ:X→Y(2.2) We define the hypothesis space F [Moh+12] as a space of all possible hypotheses or functions for mapping the feature space into the target space, normally constrained by a given structure. The parameter λ in equation (2.2) can be understood as the variation between functions in F, we will use it when in need to differentiate between different functions. For example imagine we want to produce a polynomial to fit a given problem, the λparameter is the vector of the coefficients of the polynomial. 2.1.3 Loss Function In order to evaluate how a function fλ ( x ) fits a pair ( x,y ) we define a loss function or fitness function las a mapping: l:Y×Y→R+(2.3) Intuitively it is used to verify how close two values in Y are, naturally l ( f ( x ) ,y ) = 0 is equivalent to a perfect prediction of fon the pair (x,y). 2.1.4 Learning Algorithm Given a random sampling S , an hypothesis space F and a loss function l , a learning algorithm Λis a function that maps: Λ:S×F→F(2.4) Producing a new fλ∗in order to minimize the loss function over the whole sample S. Using our polynomial example, imagine we want to fit a polynomial to a given sample S, we can use Newton’s Polynomial algorithm [CC12] to produce such an fλ. 4 2.1. STATISTICAL LEARNING THEORY ON PAC 2.1.5 Statistical Risk Until this point we have only seen loss or error point wise, but remember the objective of a learning algorithm is to produce a function f∈F that minimizes l in all of Y , there is a need to produce a global error for all pairs ( x,y ) ∈S and if possible over all pairs in D , given this setting the statistical risk or error of f over all the the underlying space is defined as: LD(f) := Eµ[l(f(X),Y )] = ZD l(f)dµ (2.5) Intuitively by integrating over D with respect to µ , in other words applying the expected value [KBH19], we average the error of all the pairs (x,y). Naturally the learning algorithm’s objective is to produce an fsuch that: f= argmin fλ∈F Eµ[l(fλ(X),Y )] (2.6) For every x∈X , let µ ( y|x ) with respect to x be the conditional probability measure on Yand µXbe the marginal probability measure [KBH19] on X. For most ML datasets it is safe to assume that X is a compact domain [Sem65] or a manifold [Ghr14] in the euclidean space (e.g. X⊂Rn ) and Y bounded, requirements needed for: For every integrable function [Nel15] ϕ : X×Y→R+ , Fubini’s Theorem [CS] states that: ZX×Y ϕ(x,y)dµ =ZX ZY ϕ(x,y)dµ(y|x)!dµX(2.7) Which means that by taking into consideration the composite function l◦f:X×Y→R+ we can: Eµ[l(f)] = ZX ZY l(f(x),y)) dµ(y|x)!dµX(2.8) Intuitively we are separating (in the integral) the spaces X and Y so that we can look at the domain Das the product of input domain Xand target Y. We then proceed to define fµ:X→Yas: fµ(x) = ZY y dµ(y|x) (2.9) The function fµis called the regression function [CS] of µand from this construction it can be understood as the true input-output function reflecting the underlying distribution D. 5 CHAPTER 2. GENERALIZATION IN SUPERVISED MACHINE LEARNING Fixing x∈X and considering the integrable composite function l◦f:X×Y→R+ , then to infer an optimum fit is sufficient to minimize our expected value solely on Y: f= argmin c∈FZY l(c,y)dµ(y|x) (2.10) Thus we’ll consider the average measurement of error or risk of fas: LD(f) = ZY l(f ,y)dµ(y|x) (2.11) Note that while fµ and µ are most likely unknown, µ ( y|x ) is known in some situations, more specifically remember the set S. 2.1.6 Bias Variance Trade off Before going into a definition of generalization let’s first analyse the particular case where the loss function is the mean square error (MSE) the expected value as in equation (2.7): Eµ[l(f(X),Y )] = ZX ZY (y−f(x))2dµ(y|x)!dµX(2.12) Calculations presented in section (A.0.1) of Appendix 1 lead to: = ZX f(x)dµX− ZY y dµ(y|x)!!2 +σ2 f+σ2 Y(2.13) Where, σ2 f=ZX f(x)2dµX− ZX f(x)dµX!2 (2.14) And, σ2 Y=ZY y2dµ(y|x)− ZY y dµ(y|x)!2 (2.15) Remember the definition of regression function in equation (2.9), we can also write as: =EX[f]−fµ2+σ2 f+σ2 Y(2.16) Before we interpret term wise the above equation let’s first introduce the notion of noise [Has+01] given by: y=fµ(x) + e(2.17) Under the assumption that the noise e∼N (0 , ) and is independent. Intuitively this 6 2.4. OVERFITTING in a particular layer, which ignores a subset of neurons in that layer with a set probability. In a way it forces the model to expand reducing interdependent learning among units, which may have led to overfitting. 2.4.2 Data Augmentation The more pairs ( x,y ) the random sample Strain has, the higher the probability it fully represents the underlying space D . Which naturally would help the learning algorithm to better generalize [Won+16]. In some situations there is no possibility of gathering more data being constrained to the random sample Strain , although it is more common for classification problems, more in particular images, we can apply data augmentation to artificially increase the size of our random sample. Using the image classification example, we can perform various image transformations to each image creating "new"ones (e.g., flipping, rotating, re scaling, shifting). 2.4.3 Validation Set Validation Set is a sub partition of the test set usually used to fine-tune the hyperparameters of a learning model (change the hypothesis set), there are some applications that use this sub partition to either prevent or reduce overfitting, some of them are presented bellow. 2.4.4 Early Stopping In subsection (2.1.4) we stated that a learning algorithm has a terminal condition, normally this terminal condition is given by a predefined value on the training loss or due to computational limitation a certain number of iterations or epochs. In these situation there is no control or knowledge about the models generalization error. Early Stopping can be understood as method to act as a terminal condition or an overwrite of the previous existing terminal condition in a learning model according to some particular measure (does not need to be the definition of generalization) over a different random sampling commonly called as validation sample. Naturally the early stopping method cannot base itself on the test sample, in order to use the generalization error one of the requirements is a sample of unseen pairs which would have been corrupted if used in this method. A common implementation is to terminate training in cases where the training error is reducing while the validation’s error increases (which suggests overfitting) with a given patience level to mitigate any natural fluctuation of the errors [Car+00]. 13 CHAPTER 2. GENERALIZATION IN SUPERVISED MACHINE LEARNING 2.4.5 Cross Validation Cross-validation [Rod+10] is a widely used method to choose the value of a hyperparameter redefining an hypothesis space, that might be less prone to overfit. The method splits the sample Strain into k sets (k-fold cross-validation), for each k-fold each one of the sets will be the test sample while the others together make the train sample. The result is an average error over all k-folds using all of sample S creating a more robust model which should be less prone to overfitting, an immediate minus is that it is k times more computationally expensive. Regarding the hyperparameter tuning, according to [A Bias Correction for the Minimum Error Rate in Cross-validation], by training and testing the model on separate subsets of the sample S , we achieve a notion of the model’s prediction error as a function of the tuning parameter, a better method to choose a different parameter. 14 Chapter 3 Related Work Throughout the years there have been several studies conducted to both grasp the essence of what it means to have a generalized f and also also to improve the generalization of learning algorithms on existing hypothesis spaces. Although most of the studies where based on classification problems, one can summarize them in the sections outlined below. 3.1 Train Test Distribution Disparity As some papers state [Chu+18], most machine learning (ML) learning models assume that the random sampling for training has the same distribution as the test data in which the generalization error will be calculated. However, due to sample selection bias [LZ14] or, more broadly, covariate shift [IS15], there exist potential training examples that are completely unknown to the learning model. This discrepancy between training and testing samples leads to a low generalization performance of the learning algorithms and hence biased predictions (remember section 2.1.6). 3.2 Problem Complexity Some studies [Ney+17] try to understand a models generalization capacity trough a study of the models robustness [Zha+18] and sensitivity [Set15]. While others [Gó+14] define a measure (originally defined in a Boolean target space) to quantify the complexity of data in relationship to the prediction accuracy that can be expected when using a supervised classifier like a neural network. 15 CHAPTER 3. RELATED WORK 3.3 Over-parameterization Paradox Both papers [Nov+18][BG18] explore the phenomenon, that in practice it is often found that complex over-parameterized neural networks architectures have a lower generalization error when compared with their smaller counterparts, an observation that appears to conflict with classical notions of function complexity, which typically favor smaller models. 16 Chapter 4 A Generalization Metric The initial conjecture in section (2.1.1) assumes that S is an i.i.d sample of an underlying distribution defined by D = X×Y , from that a definition of generalization is constructed on the difference between the training sample’s with an unseen sample’s Stest empirical loss. Assuming that Stest was sampled from the same exact conditions as S is in many situations is not true and raises two immediate problems: 1. Difficulty of interpretation, using the common examples of underfit and overfit in both states of poor generalization one cannot accurately understand the difference in metric between them; 2. The above definition dissolves all the training information and does not capture the relation between the sample used for training and the one used for testing. If the distribution of both is sufficiently diverse, the model will always under perform on Stest although this shouldn’t be seen as an error in generalization but as a result of sub optimal sampling. Meaning Stest is not a good representation of D. These assumptions are both hindering, since an interpretable metric of a models generalization given its training is more than desirable, and also wrong, since more often than not real world data is full of noise and wrong observations. We propose that it is more reasonable to weight the empirical loss over Stest with regard to the probability of each ( xi,yi ) ∈Stest belonging to D . In other words, we are not proposing a new loss function as defined in section 2.3, we are simply stating 17 CHAPTER 4. A GENERALIZATION METRIC that the definition of generalization should not be the difference between the empirical losses of two samples. 4.1 Probability Score As stated in (chapter 2), µ or in this case p ( x,y ) cannot be known, but under the assumption that a learning algorithm can also learn the underlying distribution of the training set S [Kim+19] we can infer p based on a kernel density estimation (KDE) [Weg18]. Thus for each (x,y)∈Stest we approximate p(x,y) by p∗(x,y): p∗(x0,y0) = X (x,y)∈S exp −|l(f(x0),y0)−l(f(x),y)| 1 + k(x0,y0)−(x,y)k!(4.1) Note that basing this probability estimate on the assumption that a learning algorithm can learn the underlying distribution of the training set denies the possibility of using it during any learning step. We define Probability Score as: Pf(Stest) = 1 nX (x,y)∈Stest p∗(x0,y0) (4.2) Through some initial empirical experiments we have reason to believe that this score can be used as a learning algorithm’s stopping condition in order to prevent overfit. 4.2 Generalization Score We define a new error over Stest as: L∗ Stest (f) = 1 |Stest|X (x,y)∈Stest l(f(x),y)p∗(x,y) (4.3) An immediate result that comes from (4.1) is the comparability it offers with the empirical loss over S , ideally if Ltest was well sampled and f ’understood’ the underlying distribution of Strain then: ∀(x,y)∈Stest :p∗(x,y) = 1 (4.4) Where LStest ( f ) becomes the classical empirical error over Stest . The new generalization metric is: G(f) = LStrain (f)−L∗ Stest (f) (4.5) Where LStrain (f) is the usual empirical error of fover Strain 18 Chapter 5 A New Loss Function The construction of the new loss function l∗ is based on the assumption that given some random sample of pairs ( x,y ) ∈Strain that come from an underlying distribution in D, it is always possible to fit a function fsuch that LStrain (f) = 0. But, in the presence of noise or bias we have: y=f(x) + : (x,y)∈S∧∈R(5.1) Under the assumption that the noise e∼N(0,) and is independent. So a direct approximation metric, such as the mean absolute error (MAE) is not optimal as it would always have error induced by the existence of noise (section 2.1.6) leading to a poor performance on unseen instances. Intuitively the idea is that under the assumption that the set of ξ = {i}i=1,..,n comes from a underlying distribution independent to Y of expected value 0, by sub sampling Strain we can infer for each pair ( x,y ) ∈Strain acorrection ratio in order to mitigate the error induced be noise. 5.1 Nearest Neighbors For each pair ( x,y ) ∈Strain we use a k-nearest neighbors algorithm [AL16] a simple method that returns the set of k closest pairs in Strain denoted as Nα ( x,y ) with respect to the euclidean distance. So the only user defined parameter is the number of nearest neighbors to use. 19 CHAPTER 5. A NEW LOSS FUNCTION Intuitively the set { ( x,y ) ,Nα ( x,y ) } defines a sub distribution centered around an unbiased pair, remember that E(ξ) = 0 and is independent. 5.2 Density Centroids A centroid is defined as the arithmetic mean of the points but can also be seen as a minimizer of the average distance of a center object to a given collection of objects. For each pair ( x,y ) ∈Strain we find its respective set of α nearest neighbors. We then proceed to calculate it’s centroid defined as: centroidα(x,y) = 1 αX (xk,yk)∈Nα(x,y) (xk,yk) (5.2) Intuitively each pair ( x,y ) defines a ball centered around centroidα ( x,y ) with radius k(x,y)−centroidα(x,y)k[Xin+03] denoted as Bcentroidα(x,y)(x,y). 5.3 Correction Ratio Now that we have a ball Bcentroidα(x,y) ( x,y ) for each ( x,y ) ∈Strain given each prediction f(x) there is the need to correct an unbiased position of the pair (x,f (x)). We define the correction ratio as : cr(x,y) = k(x,f (x)) −centroidα(x,y)k k(x,y)−centroidα(x,y)k(5.3) Intuitively the closest the pair ( x,f ( x )) is to the centroid center the more unbiased it will be, on the other hand it also accounts the proximity to the intended target. 5.4 Loss Function The evaluation of f for each point ( x,y ) ∈Strain will be it’s previous loss function (for example the Mean Absolute Error) multiplied by the correction ratio: l∗(f(x),y) = l(f(x),y)×cr(x,y) (5.4) Intuitively we are correcting each loss values respectively in order to mitigate the effect of noise in the training sample Strain . Finally the empirical error of Strain is given by: L∗ Strain (f) = 1 |Strain|X (x,y)∈Strain l∗(f(x),y) (5.5) 20 5.5. AN EXAMPLE 5.5 An Example Strain is the set of pairs ( x,y ) where x∈X is a set of 100 points uniformly distributed in [0 , 2 π ] and y = sin ( x ), we proceed to add some noise from a normal distribution N(0,0.1). Figure 5.1: True f and noisy points Figure 5.2: Visual Construction of the loss function As one can see in the figure predictions (x,f (x)) such that: (x,f (x)) ∈Bcentroidα(x,y)(x,y) (5.6) Then, k(xk,f (xk)) −centroidα(xk,yk)k k(xk,yk)−centroidα(xk,yk)k<1 (5.7) Which means it will have a lower evaluation when compared with the absolute difference between y and f ( x ), analogy if the pair does not belong to said ball it will have comparatively a higher evaluation. 21 Chapter 7 Experimental Results 7.1 Overview In this section we will present the results obtained from the experimental pipeline defined in the previous chapter. 7.1.1 Artificial Neural Networks Benchmarks The obtained results from the Artificial Neural Networks benchmarks are presented in Figures 7.1, 7.2, 7.3, 7.4, 7.5, 7.6, 7.7, 7.8, 7.9 (respectively for the Bioavailability, Concrete, Energy and Istanbul, PPB, Park Motor, Residential, Toxicity and Park Total datasets). Each one of the sub figures represents a different Hypothesis Space showing the Mean Absolute Error of the test sample over all 500 epochs for the control loss function and both custom loss functions with 20 and 40 nearest neighbors. NN Hypothesis Space 1 NN Hypothesis Space 2 NN Hypothesis Space 3 Figure 7.1: Median Test Mae over 30 seeds on Bioavailability 29 CHAPTER 7. EXPERIMENTAL RESULTS NN Hypothesis Space 1 NN Hypothesis Space 2 NN Hypothesis Space 3 Figure 7.2: Median Test Mae over 30 seeds on Concrete NN Hypothesis Space 1 NN Hypothesis Space 2 NN Hypothesis Space 3 Figure 7.3: Median Test Mae over 30 seeds on Energy NN Hypothesis Space 1 NN Hypothesis Space 2 NN Hypothesis Space 3 Figure 7.4: Median Test Mae over 30 seeds on Instanbul NN Hypothesis Space 1 NN Hypothesis Space 2 NN Hypothesis Space 3 Figure 7.5: Median Test Mae over 30 seeds on PPB 30 7.1. OVERVIEW NN Hypothesis Space 1 NN Hypothesis Space 2 NN Hypothesis Space 3 Figure 7.6: Median Test Mae over 30 seeds on Park Motor NN Hypothesis Space 1 NN Hypothesis Space 2 NN Hypothesis Space 3 Figure 7.7: Median Test Mae over 30 seeds on Residential NN Hypothesis Space 1 NN Hypothesis Space 2 NN Hypothesis Space 3 Figure 7.8: Median Test Mae over 30 seeds on Toxicity NN Hypothesis Space 1 NN Hypothesis Space 2 NN Hypothesis Space 3 Figure 7.9: Median Test Mae over 30 seeds on Park Total 7.1.2 Genetic Programming Benchmarks The obtained results from the genetic programming benchmarks are presented in Figures 7.10, 7.11, 7.12, 7.13, 7.14, 7.15, 7.16, 7.17, 7.18 (respectively for the Bioavailability, Concrete, Energy and Istanbul, PPB, Park Motor, Residential, Toxicity and Park 31 CHAPTER 7. EXPERIMENTAL RESULTS Total datasets). Showing the Mean Absolute Error of the test sample over all 500 generations for the control loss function and both custom loss functions with 20 and 40 nearest neighbors. Figure 7.10: GP Median Test Mae over 30 seeds on Bioavailability Figure 7.11: GP Median Test Mae over 30 seeds on Concrete Figure 7.12: GP Median Test Mae over 30 seeds on Energy Figure 7.13: GP Median Test Mae over 30 seeds on Instanbul Figure 7.14: GP Median Test Mae over 30 seeds on PPB Figure 7.15: GP Median Test Mae over 30 seeds on Park Motor 32 7.2. STATISTICAL VALIDATION Figure 7.16: GP Median Test Mae over 30 seeds on Residential Figure 7.17: GP Median Test Mae over 30 seeds on Toxicity Figure 7.18: GP Median Test Mae over 30 seeds on Park Total 7.2 Statistical Validation Since the intended purpose was analyse the behaviour of our custom loss function over the training procedure we ended up not using any stopping condition besides epochs or generation number, naturally to proceed with any statistical testing we need to choose a particular iteration. For the ANN benchmarks, as one can clearly see the main difference between custom and control seems to be its convergence rate (number of iterations required to stabilize), with that in mind we’ll perform statistical tests for the epochs 50; 100; 150; 200; 500 in order to better understand their validity. Regarding the GP benchmarks this trend is not so clear so we will only test for the last generation 500. A Kolmogorov-Smirnov test [Kol] has shown that the results do not come from a normal distribution and thus a rank-based statistic [RN11] has to be used. Bellow there a tables showing the results of the Wilcoxon rank-sum test for pairwise data [Wwwb] comparison under the null hypothesis that the medians between custom and 33 CHAPTER 7. EXPERIMENTAL RESULTS control results are equal. In the tables below we show the difference in the median MAE values of the test samples between custom and control where entries are in bold if their respective p-values are below .05, in other words they reject the null hypothesis with 95 % degree of confidence. 20 Nearest Neighbors 40 Nearest Neighbors Dataset H. 1 H. 2 H. 3 H. 1 H. 2 H. 3 Bioavailability -0.0263 0.0023 -0.0146 -0.0017 -0.003 0.0035 Concrete -0.1297 -0.172 -0.0871 -0.1478 -0.1827 -0.1134 Energy -0.052 -0.1946 -0.0528 -0.0794 -0.1794 -0.0713 Instanbul -0.0692 -0.0835 -0.0229 -0.0528 -0.0856 -0.021 PPB -0.0013 0.0063 0.0055 0.005 0.001 0.0108 Park Motor -0.0888 -0.0918 -0.0696 -0.1126 -0.0848 -0.0655 Residential -0.0254 -0.0381 -0.0053 -0.0374 -0.0389 -0.0313 Toxicity -0.0019 0.0111 0.0105 0.0177 -0.004 0.0157 Park Total -0.0933 -0.1142 -0.1104 -0.0787 -0.1165 -0.1064 Table 7.1: Difference between Custom and Control Test MAE with Wilcox Rank-Sum test p-values on ANN Results on Epoch 50 20 Nearest Neighbors 40 Nearest Neighbors Dataset H. 1 H. 2 H. 3 H. 1 H. 2 H. 3 Bioavailability -0.0009 0.0112 0.0387 -0.0079 -0.005 0.0308 Concrete -0.0762 -0.0849 -0.0563 -0.0829 -0.0761 -0.0539 Energy -0.0256 -0.0348 -0.0091 -0.0448 -0.0302 -0.0141 Instanbul -0.0408 -0.029 0.01 -0.0404 -0.0293 0.0097 PPB -0.0081 -0.0241 0.0151 0.0094 -0.0272 0.0241 Park Motor -0.0488 -0.0601 -0.0438 -0.0458 -0.061 -0.0454 Residential 0.0237 -0.0679 0.008 -0.0078 -0.0229 -0.0077 Toxicity 0.0012 0.037 0.0675 0.0176 0.0252 0.0438 Park Total -0.0567 -0.0797 -0.0514 -0.0581 -0.0736 -0.0585 Table 7.2: Difference between Custom and Control Test MAE with Wilcox Rank-Sum test p-values on ANN Results on Epoch 100 34 7.2. STATISTICAL VALIDATION 20 Nearest Neighbors 40 Nearest Neighbors Dataset H. 1 H. 2 H. 3 H. 1 H. 2 H. 3 Bioavailability 0.031 0.0293 -0.007 0.0051 -0.0043 0.0006 Concrete -0.0505 -0.0405 -0.0277 -0.05 -0.0241 -0.0171 Energy 0.0007 -0.005 -0.021 -0.0168 -0.0279 -0.0031 Instanbul -0.0225 -0.0136 0.0121 -0.0345 -0.0191 0.0107 PPB -0.0151 -0.0375 -0.0259 -0.0016 -0.0355 0.0083 Park Motor -0.0326 -0.0399 -0.0361 -0.0344 -0.0281 -0.0415 Residential 0.0516 -0.0099 0.0345 0.0387 -0.0393 0.0424 Toxicity 0.0134 0.0253 0.0655 0.0274 0.041 0.0582 Park Total -0.0521 -0.0571 -0.062 -0.0648 -0.0556 -0.0666 Table 7.3: Difference between Custom and Control Test MAE with Wilcox Rank-Sum test p-values on ANN Results on Epoch 150 20 Nearest Neighbors 40 Nearest Neighbors Dataset H. 1 H. 2 H. 3 H. 1 H. 2 H. 3 Bioavailability 0.0731 0.0219 0.0175 0.024 0.0106 0.0019 Concrete -0.0298 -0.0229 -0.0071 -0.0266 -0.0335 -0.0133 Energy 0.019 -0.0098 -0.0273 0.0043 -0.0164 -0.019 Instanbul -0.0086 -0.0032 0.0193 -0.0195 -0.0138 0.0095 PPB -0.007 -0.0416 0.0167 -0.0029 -0.0079 0.03 Park Motor 0.0002 -0.0274 -0.0445 -0.0082 -0.0291 -0.0435 Residential 0.0346 -0.0232 0.0044 0.0172 -0.017 0.0065 Toxicity -0.0034 0.0264 0.0509 0.0084 0.0429 0.0221 Park Total -0.044 -0.045 -0.0486 -0.0404 -0.0549 -0.046 Table 7.4: Difference between Custom and Control Test MAE with Wilcox Rank-Sum test p-values on ANN Results on Epoch 200 20 Nearest Neighbors 40 Nearest Neighbors Dataset H. 1 H. 2 H. 3 H. 1 H. 2 H. 3 Bioavailability 0.0425 -0.0404 0.0007 -1e-04 0.0038 0.0118 Concrete 0.0004 -0.013 -0.0114 0.0031 -0.0201 -0.0084 Energy 0.0129 -0.024 -0.0267 0.0058 -0.0273 -0.0562 Instanbul 0.0032 0.0089 0.0028 0.0074 0.0109 0.0089 PPB 0.0601 0.02 0.0489 0.0359 -0.0515 0.0353 Park Motor -0.0071 -0.0238 -0.0392 0.0005 -0.0044 -0.0396 Residential 0.0105 -0.0093 0.0163 0.0065 0.0199 -0.0071 Toxicity 0.0042 0.0269 0.0462 -0.0354 0.0077 0.0306 Park Total -0.0122 -0.0334 -0.035 -0.016 -0.0272 -0.0394 Table 7.5: Difference between Custom and Control Test MAE with Wilcox Rank-Sum test p-values on ANN Results on Epoch 500 And now for the GP results: 35 CHAPTER 7. EXPERIMENTAL RESULTS 20 Nearest Neighbors 40 Nearest Neighbors Dataset Bioavailability 0.0015 0.0035 Concrete -0.0729 -0.0951 Energy -0.0132 -0.0174 Instanbul -0.0075 -0.0045 PPB -0.0427 -0.0297 Park Motor 0.0215 -0.0017 Residential 0.0 0.0 Toxicity 0.0124 0.0065 Park Total -0.0255 -0.0316 Table 7.6: Difference between Custom and Control Test MAE with Wilcox Rank-Sum test p-values on GP Results on Epoch 500 36 Chapter 8 Discussion 8.1 Interpretation The observed results are very satisfactory. Indeed both custom and control loss functions generally converge to the same loss values, nevertheless the fact the custom loss function converges much faster is by itself a significant victory in terms of generalization. Remember section (2.1.6), we can see a function’s error lower boundary solely dependent on the chosen hypothesis space and the irreducible error separably. These particular lower boundaries cannot be overcome by a new loss function, which means that converging faster translates in a better generalization. The following section provides an interpretation of the previously observed results from chapter 7, in order to explain said results, we will analyse the main difference between both learning models, their hypothesis sets as well as the difference between using a different number of nearest neighbors for the custom loss function. As one can see in figures (7.1), (7.5) and (7.8) the ANN model almost immediately started to degenerate it’s test loss in the Bioavalability, PPB and Toxicity datasets for all three hypothesis spaces where we can’t infer much about the degeneration itself. Looking at the same datasets on the GP learning model, there is hardly any degeneration but again we cannot infer anything about these benchmarks. Difficulty in learning these datasets is no surprise, in table 6.1 one can see that they are the only problem sets that have more features than instances naturally making the problem much harder to solve. 37 CHAPTER 8. DISCUSSION The ANN model on the Instanbul dataset on figure (7.4) provides a very good example of the possible problems that can arise from increasing the complexity of a hypothesis space, notice how changing to more complex spaces actually translates in the models test error degeneration, nevertheless in the first two hypothesis spaces both parameterizations of the custom loss function have much higher and statistically significant convergence rate compared with control, regarding hypothesis space 3 we have some very curious results, where if we were to align the three training procedures test MAE minimum in the same epoch they would practically match in the remaining of the training procedure, but again the custom loss is much faster. Regarding the GP benchmark on Instanbul in figure (7.13) we can actually see some small differences but they are not statistically significant. In the remaining datasets (Concrete, Energy, Park Motor, Residual and Park Total) the ANN model actually learned consistently, the results overall converged to similar error comparatively, with the exception of the two ’Park’ datasets which curiously were the ones that had a much higher instances by features ratio (5875 by 18) where a higher complexity meant a even higher negative difference between terminal median values. However in all of them there is a consistent and very significantly higher convergence rate when compared to control where a higher complexity translated in a less accentuated convergence rate. Regarding the GP model there was only one statistically significant benchmark in figure 7.11 on the Concrete Dataset, where the custom loss in both parameterizations over performed against control by a wide margin. Regarding the remaining datasets on GP we can see some differences but again not statistically significant. The differences in parameterizations between loss functions with 20 and 40 nearest neighbors were hardly ever noticeable but again only two were used. 8.2 Advantages and Shortcomings As we have seen there are very strong evidences that this new loss function can actually perform with a higher convergence ratio against a comparable control loss and in some cases even outperform its convergence error, however the situations where it happens are still unknown. Additionally due to its definition it is slightly more computationally costly, although not much it has its effects. 38 BIBLIOGRAPHY [OAB14] H. B. O. Akbilgic and M. E. Balaban. “A novel Hybrid RBF Neural Networks model as a forecaster.” In: (2014). [VRD09] G. Van Rossum and F. L. Drake. Python 3 Reference Manual. Scotts Valley, CA: CreateSpace, 2009. isbn: 1441412697. [Cho+15] F. Chollet et al. Keras. 2015. url: https://github.com/fchollet/ keras. [Aga18] A. F. Agarap. “Deep Learning using Rectified Linear Units (ReLU).” In: CoRR abs/1803.08375 (2018). arXiv: 1803.08375 .url: http://arxiv. org/abs/1803.08375. [GG18] E. Goceri and A. Gooya. “On The Importance of Batch Size for Deep Learning.” In: July 2018. [Wwwa] GPLearn: A Genetic Programming library in Python. https://gplearn. readthedocs.io/en/stable/. Accessed: 2020-08-14. [Kol] “Kolmogorov–Smirnov Test.” In: The Concise Encyclopedia of Statistics. New York, NY: Springer New York, 2008, pp. 283–287. isbn: 978-0- 387-32833-1. doi: 10.1007/978- 0- 387- 32833- 1_214 .url: https: //doi.org/10.1007/978-0-387-32833-1_214. [RN11] D. Rey and M. Neuhäuser. “Wilcoxon-Signed-Rank Test.” In: International Encyclopedia of Statistical Science. Ed. by M. Lovric. Berlin, Heidelberg: Springer Berlin Heidelberg, 2011, pp. 1658–1659. isbn: 978-3-642-04898- 2. doi: 10.1007/978-3-642-04898-2_616 .url: https://doi.org/10. 1007/978-3-642-04898-2_616. [Wwwb] Scipy.stats: Wilcoxon’s signed-rank test. https://docs.scipy.org/doc/ scipy//reference/generated/scipy.stats.wilcoxon.html/ , note = Accessed: 2020-08-14. 45 Appendix A Appendix A.0.1 Bias Variance TradeoffPart 1 Continuation of calculus from section (2.1.6) equation (2.12): =ZY f(x)2−2yf (x) + y2dµ(y|x) (A.1) =ZY f(x)2dµ(y|x)−2ZY yf (x)dµ(y|x) + ZY y2dµ(y|x) (A.2) = f(x)−ZY y dµ(y|x)!2 − ZY y dµ(y|x)!2 +ZY y2dµ(y|x) (A.3) = f(x)−ZY y dµ(y|x)!2 +ZY y2dµ(y|x)− ZY y dµ(y|x)!2 (A.4) The second and third term by definition are the variance [citar] of Y denoted as σ2 Y , which means: ZY (f(x)−y)2dµ(y|x) = f(x)−ZY y dµ(y|x)!2 +σ2 Y(A.5) Now let us: ZXZY (f(x)−y)2dµ(y|x)dµX=ZX f(x)−ZY y dµ(y|x)!2 +σ2 YdµX(A.6) =ZX f(x)−ZY y dµ(y|x)!2dµX+σ2 Y(A.7) =ZXf(x)2−2f(x) ZY y dµ(y|x)!+ ZY y dµ(y|x)!2dµX+σ2 Y(A.8) 47 APPENDIX A. APPENDIX =ZX f(x)2dµX−2ZX"f(x) ZY y dµ(y|x)!#dµX+ZX ZY y dµ(y|x)!2 dµX+σ2 Y(A.9) =ZX f(x)2dµX−2 ZY y dµ(y|x)!ZX f(x)dµX+ ZY y dµ(y|x)!2 +σ2 Y(A.10) =ZX f(x)2dµX+ ZX f(x)dµX− ZY y dµ(y|x)!!2 − ZX f(x)dµX!2 +σ2 Y(A.11) =ZX f(x)2dµX− ZX f(x)dµX!2 + ZX f(x)dµX− ZY y dµ(y|x)!!2 +σ2 Y(A.12) The first and second term by definition are the variance of f ( x ) denoted as σ2 f , which means: =σ2 f+ ZX f(x)dµX− ZY y dµ(y|x)!!2 +σ2 Y A.0.2 Bias Variance TradeoffPart 2 Continuation of calculus from section (2.1.6) equation (2.16): Consider the equation (2.7): Eµ[l(f(X),Y )] = ZX×Y l(f(x),y)dµ =ZX ZY l(f(x),y)dµ(y|x)!dµX(A.13) Assume l(f(x),y)=(f(x)−y)2(MSE), ZY l(f(x),y)dµ(y|x) = ZY (y−f(x))2dµ(y|x) (A.14) σ2 Y=ZY y2dµ(y|x)− ZY y dµ(y|x)!2 (A.15) =ZY (fµ(x) + e)2dµ(y|x)− ZY (fµ(x) + e)dµ(y|x)!2 (A.16) =ZY (fµ(x)2+ 2efµ(x) + e2)dµ(y|x)− ZY fµ(x)dµ(y|x) + ZY e dµ(y|x)!2 (A.17) =ZY fµ(x)2dµ(y|x) + 2ZY efµ(x)dµ(y|x) + ZY e2dµ(y|x)− ZY fµ(x)dµ(y|x)!2 (A.18) =fµ(x)2+ 2fµ(x)ZY e dµ(y|x) + ZY e2dµ(y|x)−fµ(x)2(A.19) =ZY e2dµ(y|x) = σ2 e(A.20) Also when dealing with the Bias:                   ZX f(x)dµX− ZY y dµ(y|x)! | {z } bias                   2 = ZX f(x)dµX− ZY (fµ(x) + e)dµ(y|x)!!2 (A.21) 48 = ZX f(x)dµX− ZY (fµ(x)dµ(y|x) + ZY e dµ(y|x)!!2 (A.22) = ZX f(x)dµX−fµ(x)!2 (A.23) 49