scieee AI-readable full text Open interactive document viewer

Learning latent variable models : efficient algorithms and applications

Ruffini, Matteo

Abstract

Learning latent variable models is a fundamental machine learning problem, and the models belonging to this class - which include topic models, hidden Markov models, mixture models and many others - have a variety of real-world applications, like text mining, clustering and time series analysis. For many practitioners, the decade-old Expectation Maximization method (EM) is still the tool of choice, despite its known proneness to local minima and long running times. To overcome these issues, algorithms based on the spectral method of moments have been recently proposed. These techniques recover the parameters of a latent variable model by solving - typically via tensor decomposition - a system of non-linear equations relating the low-order moments of the observable data with the parameters of the model to be learned. Moment-based algorithms are in general faster than EM as they require a single pass over the data, and have provable guarantees of learning accuracy in polynomial time. Nevertheless, methods of moments have room for improvements: their ability to deal with real-world data is often limited by a lack of robustness to input perturbations. Also, almost no theory studies their behavior when some of the model assumptions are violated by the input data. Extending the theory of methods of moments to learn latent variable models and providing meaningful applications to real-world contexts is the focus of this thesis. ssuming data to be generated by a certain latent variable model, the standard approach of methods of moments consists of two steps: first, finding the equations that relate the moments of the observable data with the model parameters and then, to solve these equations to retrieve estimators of the parameters of the model. In Part I of this thesis we will focus on both steps, providing and analyzing novel and improved model-specific moments estimators and techniques to solve the equations of the moments. In both the cases we will introduce theoretical results, providing guarantees on the behavior of the proposed methods, and we will perform experimental comparisons with existing algorithms. In Part II, we will analyze the behavior of methods of moments when data violates some of the model assumptions performed by a user. First, we will observe that in this context most of the theoretical infrastructure underlying methods of moments is not valid anymore, and consequently we will develop a theoretical foundation to methods of moments in the misspecified setting, developing efficient methods, guaranteed to provide meaningful results even when some of the model assumptions are violated. During all the thesis, we will apply the developed theoretical results to challenging real-world applications, focusing on two main domains: topic modeling and healthcare analytics. We will extend the existing theory of methods of moments to learn models that are traditionally used to do topic modeling – like the single-topic model and Latent Dirichlet Allocation – providing improved learning techniques and comparing them with existing methods, which we prove to outperform in terms of speed and learning accuracy. Furthermore, we will propose applications of latent variable models to the analysis of electronic healthcare records, which, similarly to text mining, are very likely to become massive datasets; we will propose a method to discover recurrent phenotypes in populations of patients and to cluster them in groups with similar clinical profiles - a task where the efficiency properties of methods of moments will constitute a competitive advantage over traditional approaches.

Full text

Learning Latent Variable Models: Efficient Algorithms and Applications Matteo Ruffini PhD program in Artificial Intelligence Universitat Politècnica de Catalunya Department of Computer Science Supervisor: Ricard Gavaldà Abstract Learning latent variable models is a fundamental machine learning problem, and the models belonging to this class – which include topic models, hidden Markov models, mixture models and many others – have a variety of real-world applications, like text mining, clustering and time series analysis. For many practitioners, the decade-old Expectation Maximization method (EM) is still the tool of choice, despite its known proneness to local minima and long running times. To overcome these issues, algorithms based on the spectral method of moments have been recently proposed. These techniques recover the parameters of a latent variable model by solving – typically via tensor decomposition – a system of non-linear equations relating the low-order moments of the observable data with the parameters of the model to be learned. Moment-based algorithms are in general faster than EM as they require a single pass over the data, and have provable guarantees of learning accuracy in polynomial time. Nevertheless, methods of moments have room for improvements: their ability to deal with real-world data is often limited by a lack of robustness to input perturbations. Also, almost no theory studies their behavior when some of the model assumptions are violated by the input data. Extending the theory of methods of moments to learn latent variable models and providing meaningful applications to real-world contexts is the focus of this thesis. Assuming data to be generated by a certain latent variable model, the standard approach of methods of moments consists of two steps: first, finding the equations that relate the moments of the observable data with the model parameters and then, to solve these equations to retrieve estimators of the parameters of the model. In Part I of this thesis we will focus on both steps, providing and analyzing novel and improved model-specific moments estimators and techniques to solve the equations of the moments. In both the cases we will introduce theoretical results, providing guarantees on the behavior of the proposed methods, and we will perform experimental comparisons with existing algorithms. In Part II, we i will analyze the behavior of methods of moments when data violates some of the model assumptions performed by a user. First, we will observe that in this context most of the theoretical infrastructure underlying methods of moments is not valid anymore, and consequently we will develop a theoretical foundation to methods of moments in the misspecified setting, developing efficient methods, guaranteed to provide meaningful results even when some of the model assumptions are violated. During all the thesis, we will apply the developed theoretical results to challenging real-world applications, focusing on two main domains: topic modeling and healthcare analytics. We will extend the existing theory of methods of moments to learn models that are traditionally used to do topic modeling – like the single-topic model and Latent Dirichlet Allocation – providing improved learning techniques and comparing them with existing methods, which we prove to outperform in terms of speed and learning accuracy. Furthermore, we will propose applications of latent variable models to the analysis of electronic healthcare records, which, similarly to text mining, are very likely to become massive datasets; we will propose a method to discover recurrent phenotypes in populations of patients and to cluster them in groups with similar clinical profiles – a task where the efficiency properties of methods of moments will constitute a competitive advantage over traditional approaches. ii Acknowledgements I have to confess that writing this thesis has been quite an amazing adventure, which contributed to make these years in Barcelona an unforgettable time. Without doubts, this has been possible thanks to the help and the contribution of many people, that I would like to acknowledge in this note. My first and most special thank goes to my advisor Ricard, for his patience and flexibility, for the papers that we wrote together as coauthors and for introducing me to Computer Science back in 2015. I am grateful to my amazing coauthors Marta, Borja and Guillaume for sharing with me their ideas, being willing to listen to my proposals and helping me to become a better scientist with their help and advice; and to my Master thesis advisor Giacomo, with whom I shared back in 2011 my first steps in the path of scientific research. Combining a PhD with a full-time job in the industry is not an easy task, and it would not have been possible without the support of ToolsGroup, who encouraged me with trust and flexibility during the first years of this adventure. To all the great people working there goes a special acknowledgement, and in particular to Yossi, Eugenio – for having been a role model – to Angela and David – for their interest and curiosity toward my studies and for always pointing me great ideas and new perspectives. Likewise, I want to thank all the people in Skyscanner for sharing with me the last part of this journey, and in particular my amazing team – the Albatross squad. My lifelong friends in Melegnano deserve a special mention for being an invaluable support during such a hard-working time, and for sharing millions of adventures across Europe that made this PhD easier and more fun. I want to acknowledge all the institutions who provided us clinical data allowing its use for our studies – the MIMIC project, the Hospital de Sant Pau and the Catalan Health Service (CatSalut) – and all the people who helped me on the analysis and interpretation of healthcare data carried on iii during this thesis: Drs. Julianna Ribera, Salvador Benito, Mireia Puig, Montserrat Busting and Esther Limón. Completing this thesis would have been way harder without the contribution of the projects and the institutions that partially funded my PhD: the projects SGR2014-890 and 2017SGR-856 (MACDA) of AGAUR (Generalitat de Catalunya); the projects MDM-2014- 0445 (BGSMath María de Maeztu Programme for Units of Excellence in R&D), TIN2014-57226-P (APCOM), and TIN2017-89244-R (MACDA) from MINECO (Ministerio de Economia, Industria y Competitividad). I will be forever grateful to my family for always pushing me beyond my limits, to my mum Paola, my dad Marco and to my lovely grandparents who are a continuous source of inspiration. Last, but foremost, I want to dedicate this thesis to my fiancée Francesca, for supporting me in this idea of starting a PhD, for her help in proofreading, editing and improving this thesis and for her infinite patience: I can not imagine how I could have completed this thesis without such an incredible partner. iv Contents Abstract i Acknowledgements iii Introduction 5 Research problems and related works . . . . . . . . . . . . . . . . . 9 Overview of contributions . . . . . . . . . . . . . . . . . . . . . . . 13 Publications derived from the thesis . . . . . . . . . . . . . . . . . . 19 I Methods of Moments for Learning Latent Variable Models 21 1 Background: Methods of Moments 23 1.1 Naive Bayes Models . . . . . . . . . . . . . . . . . . . . . . . . 23 1.1.1 Learning Naive Bayes Models . . . . . . . . . . . . . . 24 1.1.2 Naive Bayes Models and Clustering . . . . . . . . . . . 25 1.1.3 Example: Poisson’s Naive Bayes Models . . . . . . . . 26 1.2 The Method of Moments . . . . . . . . . . . . . . . . . . . . . 27 1.2.1 Tensor Decomposition . . . . . . . . . . . . . . . . . . 32 1.3 A Framework for Several Models . . . . . . . . . . . . . . . . 37 2 Singular Value-Based Tensor Decomposition 39 2.1 Singular Value based Tensor Decomposition . . . . . . . . . . 40 2.1.1 Comparison with other decomposition methods. . . . . 44 2.2 Perturbation Analysis . . . . . . . . . . . . . . . . . . . . . . 46 2.2.1 Proof of Theorem 2.2.1 . . . . . . . . . . . . . . . . . . 47 2.3 Experiments............................ 52 1 2.4 Conclusions ............................ 55 3 Methods of Moments for Topic Models 57 3.1 Learning Topic Models with Methods of Moments . . . . . . . 59 3.2 Moments Estimators for the Single-Topic Model . . . . . . . . 60 3.2.1 Proof of Theorem 3.2.2 . . . . . . . . . . . . . . . . . . 65 3.3 Extension to Latent Dirichlet Allocation . . . . . . . . . . . . 68 3.4 Experiments............................ 70 3.4.1 Recovering M2and M3.................. 71 3.4.2 RealData......................... 73 3.5 Conclusions ............................ 79 4 Methods of Moments for Clustering and an Application to Healthcare Analytics 83 4.1 Introduction............................ 83 4.1.1 Clustering Patients . . . . . . . . . . . . . . . . . . . . 84 4.2 Clustering with Mixtures of Independent Bernoulli Variables . 88 4.3 Learning Mixtures of Independent Bernoulli Variables . . . . . 89 4.3.1 Existing Methods . . . . . . . . . . . . . . . . . . . . . 89 4.3.2 A New, Approximate Approach . . . . . . . . . . . . . 92 4.4 Putting it All Together . . . . . . . . . . . . . . . . . . . . . . 96 4.5 Experiments............................ 97 4.6 Patient Clustering . . . . . . . . . . . . . . . . . . . . . . . . . 101 4.6.1 TheDatasets .......................101 4.6.2 Modeling Strategy . . . . . . . . . . . . . . . . . . . . 102 4.6.3 Analysis of the Results . . . . . . . . . . . . . . . . . . 103 4.7 Conclusions ............................111 II Hierarchical Methods of Moments 113 5 A Method of Moments Robust to Model Misspecification 115 5.1 Introduction............................115 5.2 Existing Decomposition Algorithms and the Misspecified Setting 117 5.3 Simultaneous Diagonalization Based on Whitening and Optimization..............................120 5.3.1 SIDIWO in the Realizable Setting . . . . . . . . . . . . 121 5.3.2 The Misspecified Setting . . . . . . . . . . . . . . . . . 123 2 5.3.3 An optimal solution when l= 2..............128 5.4 Case Study: Hierarchical Topic Modeling . . . . . . . . . . . . 129 5.4.1 Experiment on Synthetic Data . . . . . . . . . . . . . . 131 5.4.2 Experiment on NIPS Conference Papers 1987-2015 . . 133 5.4.3 Experiment on Wikipedia Mathematics Pages . . . . . 134 5.5 Conclusions ............................134 6 Hierarchical Methods of Moments for Clustering High-Dimensional Binary Data 137 6.1 Introduction............................137 6.2 A data-centric Interpretation of SIDIWO . . . . . . . . . . . . 140 6.3 A Hierarchical Clustering Algorithm . . . . . . . . . . . . . . 144 6.4 Experiments............................147 6.4.1 MIMIC Dataset . . . . . . . . . . . . . . . . . . . . . . 147 6.4.2 Tertiarism Dataset . . . . . . . . . . . . . . . . . . . . 151 6.5 Conclusions ............................153 Conclusions and Open Problems 157 3 Abbreviations ALS Alternating Least Square ASVTD Approximate Singular Value-based Tensor Decomposition D-SIDIWO Data-centric Simultaneous Diagonalization based on Whitening and Optimization EHR Electronic Healthcare Records EM Expectation Maximization LDA Latent Dirichlet Allocation LVM Latent Variable Models MAP Maximum A Posteriori MCMC Markov-Chain Monte Carlo MDL Minimum Description Length MMD Maximum Mean Discrepancy MoM Method of Moments SIDIWO Simultaneous Diagonalization based on Whitening and Optimization SVD Singular-Values Decomposition SVTD Singular Value-based Tensor Decomposition TPM Tensor Power Method 4 can rely on the specific structure of the whole set of low-order moments by using not only the third, but also the first and the second order moments to explicitly exploit their symmetry properties and obtain the desired model parameters more efficiently and with provable guarantees of global optimality. This is the approach followed by methods of moments. The reference method here is the Tensor Power Method (TPM) from Anandkumar et al. (2014). TPM manipulates the low-order moments to obtain a symmetric orthogonal tensor that is decomposed using a high-dimensional extension of the well-known matrix power method, with an approach proposed by Zhang and Golub (2001) and Kolda (2001). The main issue of this algorithm is its scalability, since its running time grows as k5 where k is the number of latent components. An alternative, which in general has better dependence on the number of latent factors, consists in using matrixbased techniques and a simultaneous diagonalization approach, specializing an approach that can be traced back to Sanchez and Kowalski (1990) and Leurgans et al. (1993). Examples of these methods of moments are provided by Anandkumar et al. (2012b), with an algorithm based on the eigenvectors of a linear operator; Anandkumar et al. (2012a) also present an alternative method based on the singular vectors of a Singular-Values Decomposition (SVD). These two methods are faster than TPM by far, but they are more sensitive to perturbations on the input data. A method of moments uses a set of n samples to empirically estimate the moments and then uses tensor decomposition methods to recover the model parameters from the decompositions of the estimated, perturbed, moments. Methods of moments can thus be improved by improving the convergence rate of the estimators – obtaining better moments with smaller sample sizes – by working on the decomposition algorithms to reduce their sensitivity to input perturbations – returning better model parameters when the input moments are perturbed – and improving their performance – performing the decompositions in shorter running times. In this thesis, we will focus on all these aspects, working on novel moment-estimators for several latent variable models and providing improved tensor decomposition techniques that allow to recover, from an estimation of the moments, robust estimates of the parameters of a latent variable model in short running times. As explained in the introduction, the traditional approach to learn latent 11 variable models is based on the maximum-likelihood principle and aims at finding the model that maximizes the likelihood of an observed dataset. However, maximizing the likelihood is a difficult task even for simple models: Arora et al. (2012) for example proved that maximum likelihood estimates for the single topic model are NP-hard, while Roch (2006) proved the same for latent trees. Consequently, several heuristics have been developed aiming at solving the maximum likelihood problem under an approximate point of view. Expectation Maximization (Dempster et al., 1977), for example is an iterative technique that, starting from a user defined initialization (typically random), iteratively updates the parameter of a model, increasing the likelihood at each iteration. EM has only local guarantees of convergence, but is easy to understand and to implement, which makes it the most used technique in this field. Furthermore, EM requires the complete calculation of the posterior distributions, which may not be feasible for models with a complex structure; in this case it is common to use approximate inference approaches based on variational inference or Monte Carlo-based approaches (see Bishop 2006 for a detailed presentation of these techniques). Approximate inference techniques are widely used in tasks like topic modeling (Blei et al., 2003; Griffiths and Steyvers, 2004) and mixture-models learning (Marin et al., 2005). Thanks to their flexibility, they allow to deal with complex models, but, unlike methods of moments, they fail to provide optimal models in small running times. Methods of moments and likelihood-based techniques aim at the same purpose – retrieving the parameters of a model – following two different frameworks. However, these two frameworks are not unrelated, but complementary. For example, empirical studies indicate that initializing EM with the output of a MoM algorithm can improve the convergence speed of EM by several orders of magnitude, yielding a very efficient strategy to accurately learn latent variable models (Balle et al., 2014; Chaganty and Liang, 2013; Bailly, 2011). In the case of relatively simple models this approach can be backed by intricate theoretical analyses (Zhang et al., 2014), showing that initializing EM with the output of a method of moments can provide guarantees of global optimality. Despite their theoretical appeal, the practical applications of methods of moments are still limited, and EM remains the tool of choice of most of practitioners, notwithstanding the slow running times and the well-known proneness to poor local optima. While this is partially due to the novelty of 12 the MoM framework, there are also deeper theoretical issues that limit the robustness of these methods in real-world applications. Methods of moments in fact, to work with guarantees, require the user to know the exact structure of the latent variable model that he wants to learn; this means knowing the number of latent variables of a model, their distribution, and their probabilistic relation with observable data. However, most of these characteristics, are by definition unknown to the user, who can only estimate them with cross-validation techniques. Kulesza et al. (2014) demonstrated that when the number of latent states imposed by the user is not enough to describe the training data, a MoM can lead to unexpected results, and provided in a subsequent work (Kulesza et al., 2015) potential ways to overcome this issue. In general, it is possible to demonstrate (see Chapter 5) that when the characteristics of the model generating the data are unknown or misspecified, most of the traditional methods of moments provide no guarantees on their results. Furthermore, for methods of moments to work properly, it is crucial to deal with moments whose expectations are in a prescribed relation with respect to the parameters of the model one wants to learn; however, efficient formulations of the moments are known only for few, simple, latent variable models, requiring heavy assumptions on the data, that are systematically violated in real world scenarios. The problem of the applicability of methods of moments in settings where the model generating the data is unknown or not properly specified is largely unstudied; in this context, the traditional approach consists of refining the results of a MoM with EM, so to obtain a parameter that, at least locally, is guaranteed to be meaningful, locally maximizing the likelihood. While this approach is effective in practice, a theory on why in the misspecified setting a MoM would return a meaningful model (and thus a good initializer for EM) is still not present. Providing a theoretical analysis of methods of moments in the misspecified setting is one of the objectives of this thesis. Overview of contributions The first part of this thesis (Chapters 1 to 4) is dedicated to the theory of methods of moments for learning latent variable models when all the characteristics of the model generating the data are known, and only the parameters of that model need to be recovered. 13 Chapter 1 is dedicated to recalling the basis of methods of moments. We will present how methods of moments work by presenting a simple application for learning Naive Bayes Models with Poisson-distributed features. We will show how it is possible to recover a set of equations that relate the low-order moments of the observable data with the parameters of the model and we will then present the most used techniques to solve these equations – namely the tensor decomposition methods from Anandkumar et al. (2012b, 2014), and Alternate Least Square (Kolda and Bader, 2009). We will conclude the chapter with a brief discussion on how this approach can be generalized to any latent variable model, and on the conditions required to guarantee the identifiability of a model in this setting. A fundamental part in methods of moments is the step that decomposes the matrices/tensors containing the moments to retrieve an estimate of the parameters of the model generating the data. This step is generally accomplished using algorithms that employ matrix/tensor decomposition methods, which ideally are required to run in short running times and to guarantee good robustness to random perturbations – providing good learning accuracy when only a limited amount of data is available. A scan of the literature for these methods present some alternative tools of choice: Anandkumar et al. (2012a,b) present methods with high scalability, but poor robustness to perturbations, while Anandkumar et al. (2014) introduce a method with better robustness but significantly worse running times. At the same time, existing methods from tensor factorization theory (see for example Tomasi and Bro 2006; Kolda and Bader 2009; Sidiropoulos et al. 2017) provide heuristics with a worse computational complexity and less guarantees on the learning accuracy. These limitations of existing methods led us to search for an algorithm with high learning accuracy and strong efficiency guarantees. In Chapter 2 we provide a novel algorithm for the simultaneous solution of moment equations that allows to retrieve, from estimates of the moments, a set of estimates of the model parameters. This algorithm will rely on simple matrix operations – being consequently fast – and will guarantee a best-in-class learning accuracy. We will analyze the proposed method under the theoretical point of view, studying its computational complexity and its robustness to random perturbations of the input. Finally we will experimentally compare the proposed method with existing techniques, showing that the proposed algorithm outperforms each existing method either in terms of speed or in learning accuracy. 14 One of the areas where latent variable models find a natural field of application is natural language processing and topic modeling. In this field, the observable variables are the words appearing in a text, while the latent variables are the topics with which a text is dealing. A simple model is the single-topic model, where each text is assumed to be about only one topic and the probability of a given word appearing in a text depends on the topic of the text. An alternative and more complex model is Latent Dirichlet Allocation (LDA) (see Griffiths and Steyvers, 2004; Blei et al., 2003), where each text is assumed to deal with a multitude of topics, and each word of a text is assumed to be associated to a unique topic. Learning techniques for topic modeling are in general dominated by Bayesian approaches, with techniques based on Markov Chain Monte Carlo methods (Griffiths and Steyvers, 2004) and variational techniques (Blei et al., 2003). At the same time, methods of moments exist to learn standard models like the single-topic model (Anandkumar et al., 2012b; Zou et al., 2013) and LDA (Anandkumar et al., 2012a). In Chapter 3 we present novel methods of moments to learn these two models aiming at improving existing ones. In particular we will introduce new of estimators of the moments for the single-topic model and for LDA, studying their sample complexity and providing novel sample complexity bounds. We will show, both experimentally and with a theoretical analysis, that the proposed estimators have an improved robustness in comparison with existing ones. Furthermore we will compare the proposed approaches with the standard Bayesian approach proposed by Griffiths and Steyvers (2004) on real-world text corpora, both for single-topic model and LDA. We will show that the moment-based method presented in this chapter recovers higher-quality topics in much smaller running time. In Chapter 4 we will present an application of latent variable models to healthcare analytics, focusing on the specific task of patient clustering. We will consider the most simple kind of electronic healthcare records – namely ICD9 records (Geraci et al., 1997) registering patient diagnostics – and we will use these data with two objectives: clustering patients in groups with homogeneous clinical profiles and retrieving meaningful phenotypes – i.e. abstract representations describing the most recurrent diseases-patterns in patient statuses. To accomplish this task we will model our data as mixture models, learn the mixture with a method of moments and use that mixture to cluster the various patients, using a model-based clustering approach (Marin et al., 2005). The choice of a model-based approach over the more traditional 15 distance-based methods like k-means (Macqueen, 1967) or spectral clustering (Ng et al., 2002) has two benefits: first it allows to deal with high-dimensional sparse data, as it will be the case for our dataset, and second it provides a meaningful generative model for our dataset, allowing an easy construction of phenotypes. The task of performing a moment-based learning of a mixture model will come with a peculiar challenge, because no efficient moment-estimators are known for such kind of latent variable models. As a consequence, we will propose an approximate approach where we will develop moment-estimators that are provably almost-unbiased – i.e. with a bias that can be calculated and is provably small – and feed a decomposition algorithm with these estimators. The resulting parameters will then be refined with EM, in order to remove the bias inherited from the moment estimation. We will see that this hybrid MoM-EM approach will work effectively, with EM rapidly converging to good optima. Furthermore, it will allow to present an efficient implementation of the decomposition method presented in Chapter 2, allowing it to run with a better computational complexity. We will apply this approach to the considered dataset of patients obtaining clusters and phenotypes that make sense under the clinical point of view. Furthermore, we will compare on synthetic data our approach with more traditional clustering algorithms, outperforming them in terms of clustering accuracy. In all the chapters above we have focused on scenarios where data was generated by a latent variable model whose structure was assumed to be known to the user, and the task of a learning algorithm was reduced solely to recovering the parameters of the model. Methods of moments require the user to explicitly know the structure of the latent variable model that he wants to learn, as this information is explicitly used in two points: one is when the moment are calculated, as the formulation of the moment estimators depend on the specific model generating the data; different model will have different estimators. The second is in the decomposition algorithm, where a user needs to ask for a specific number of latent states to be returned by the algorithm. All the theory of methods of moments has been developed in the realizable setting where the model characteristics are known to the user, and data does not violate any model assumption. This approach allowed to build a clear and round theoretical framework for methods of moments, but also limited the theoretical reliability of these methods in real-world scenarios, where the model generating the data is always unknown, and model assumptions are sure to be violated. In the second part of this thesis (Chapters 5 and 6), we 16 will concentrate on analyzing methods of moments when data does not follow a model of the mathematical form assumed by the algorithm, violating some of the assumptions that the user makes. In Chapter 5 we will focus on the scenario where a method of moments is required to learn a latent variable model from data, but the number of latent states required by a user is too small to accurately represent the training data. This is a very common scenario, in particular when data is high-dimensional and it is difficult to find a number of latent states to comprehensively describe the dataset, or this number is too high to be estimated. For example, an important application of low-dimensional learning comes from exploratory data analysis, where a mixture model with two states is required to bisect a dataset into two well-distinct classes. The desired behavior of a learning technique when run in a low-dimensional setting, is to return a small model that synthetically describes the data, providing the optimal low-dimensional model approximating the data we are observing. In Chapter 5 we will demonstrate that this is not the behavior of existing methods of moments, which instead are likely to return unexpected results when plugged with a misspecified number or latent states. As a consequence, we provide a novel decomposition algorithm for method of moment, that phrases the decomposition task as a non-convex optimization problem and generalizes the method presented in Chapter 2. We demonstrate that the proposed algorithm, when run in a low-dimensional setting, returns the optimal low-dimensional model approximating the one generating the data, according to an intuitive definition of optimality. Starting from these remarks, we apply this method to hierarchically learn latent variable models, starting with a simple, twodimensional model, which is then refined iterating the learning step on each of the retrieved dimensions. The hierarchical nature of this method allows for a fast and accurate solution of the optimization problem raising in the decomposition task, based on low-dimensional grid search. An immediate application of this approach is to perform hierarchical clustering, where a mixture with two classes is learned, used to bisect our dataset, and then the procedure is iterated on each of the two retrieved clusters. In this chapter we will also present an application of this approach to natural language processing, providing a specialization of our method to perform hierarchical topic modeling. All the guarantees provided by the theoretical analysis of methods of moments 17 come with the assumption that a user is able to calculate unbiased estimators of the moments, that asymptotically exhibit a prescribed relation with the parameters of the model. However, this assumption is possible only when data is accurately described by a latent variable model of known structure, while when the structure of the model is not known or no finite model accurately describes the data – as it is the case in real-world scenarios – nothing is known on the asymptotic behavior of the moment equations. Consequently, the theoretical infrastructure guaranteeing that methods of moments will return a good model approximating the data, loses most its strength in real-world contexts. In Chapter 6 we demonstrate that theoretical guarantees on the behavior of methods of moments can be retrieved also when no hypotheses on the model generating the data are made. In particular, we will consider a simple calculation formula for the moments, and we will demonstrate that the decomposition technique introduced in Chapter 5 provides a meaningful relation between the input data and the output model, regardless the model generating the data. This means that its output will accurately describe the data, even if the user imposes no hypotheses on the input data. Additionally, we will analyze the cost function of the considered method and its action on the input data, observing that it automatically suggests a rule to split them into meaningful clusters. From this observation, we will introduce a novel model-independent clustering algorithm that will be particularly suitable for high-dimensional binary data. We will thus apply this approach to the medical records studied in Chapter 4, obtaining meaningful hierarchical phenotypes and clinically reasonable trees of clusters. The last chapter concludes this work and highlights the main research challenges emerging from the problems faced in this thesis. Some of them are theoretical and aim at improving our current understanding of methods of moments, studying the relations that link this family of techniques with traditional likelihood-based methods. Some others are applied, and focus on extending the applicability of methods of moments to real-world scenarios. 18 Publications derived from the thesis The following papers have been written as an outcome of this thesis. • Ruffini, M. (2018). Hierarchical Methods of Moments for Clustering High Dimensional Binary Data. Submitted • Ruffini, M., Casanellas, M., and Gavaldà, R. (2018). A new method of moments for latent variable models. Machine Learning, 107(8-10):1431– 14551 • Ruffini, M., Rabusseau, G., and Balle, B. (2017b). Hierarchical methods of moments. In Neural Information Processing Systems, pages 1901–1911 2 • Ruffini, M., Gavalda, R., and Limon, E. (2017a). Clustering patients with tensor decomposition. In Machine Learning for Healthcare Conference, pages 126–146 3 1https://mruffini.github.io/assets/papers/method-moments-LVM-preprint. pdf 2http://papers.nips.cc/paper/6786-hierarchical-methods-of-moments.pdf 3http://proceedings.mlr.press/v68/ruffini17a/ruffini17a.pdf 19 20 The vector µj = ( µj,1, ..., µj,d ) ∈Rd will thus coincide with the j th center of the model: µj = E [ X|Y = j ]. For a Poisson’s naive Bayes model the model structure is thus simple: S=(Pj,i ≈Poiss(·) klatent states and the parameters characterizing each distribution will coincide with the centers of the model: µj,i = Θj,i. Poisson’s naive Bayes models are thus entirely determined by their mixing weights ω and their matrix of the centers M , which are their only parameters: ( M, ω ) = (Θ , ω ). 1 From now on, we will call the pair ( M, ω )the parameters of a Poisson’s naive Bayes model. Considering a dataset X generated by a Poisson’s naive Bayes model with parameters ( M, ω ), we want an algorithm able to return an estimate ( ˜ M, ˜ω ) of its parameters. 1.2 The Method of Moments In this section we present a framework to learn latent variable models, called method of moments. We will use as instrumental example Poisson’s naive Bayes models, clarifying how the approach can be easily generalized to several well-known latent variable models. The idea at the basis of the method of moments is an immediate consequence of the law of large numbers, which we recall here: Theorem 1.2.1. Let {x(1), ..., x(n)} be an iid sample generated from a distribution Xsuch that E[X] = µ. Then the following relation holds: lim n→∞ n X i=1 x(i) n=µ. 1 We remark that this is the case for any naive Bayes model whose features conditional distributions Pj,i depend on a unique parameter µj,i ; for example, this is the case for Bernoulli or Exponential random variables. 27 The consequence of this theorem is that we can calculate for a distribution a good estimator of its expectation, by just averaging out a large-enough set of observed samples. Furthermore, the estimator is guaranteed to approximate the parameters µ with increasing accuracy while the sample size increases. If for example, the samples are generated by a Poisson distribution, and if we have enough data, the sample average will be a good estimator for the parameter µ , which is the sole parameter of the considered distribution. The sample average Px(i)/n is commonly called first-order sample moment, and it is an approximation of the theoretical first-order moment, that is the expectation µ of the random variable; the usage of the moments of a distribution for calculating its parameters is commonly called method of moments. While the Poisson distribution example is a trivial application of the method of moments, it provides a possible learning strategy for more complex latent variable models. We will now see how to extend this approach to naive Bayes models, focusing on the special case of Poisson’s naive Bayes model. Consider a dataset generated by a Poisson’s naive Bayes model with parameters ( M, ω ) and klatent states: X={x(1), ..., x(n)}, where each observation is a d dimensional vector. Our goal is to provide a method to recover an estimate ( ˜ M, ˜ω )of the model parameters. Trying to repeat the steps used to estimate the parameters of a Poisson distribution, we begin by calculating the first order moment of the observed sample, which will be called ˜ M1: ˜ M1= n X i=1 x(i) n∈Rd. It is easy to observe that the expectation of ˜ M1has a nice form: E[˜ M1] = M1= k X i=1 ωiµi,(1.1) which suggests to solve the system of d equations that arises by substituting M1 with its estimator in equation (1.1) , to obtain asymptotically converging estimators of the model parameters. However, even in the theoretical scenario where we have infinite data and ˜ M1 = M1 , the system M1 = Pk i=1 ωiµi has, in most of the cases, several solutions: we have k×d + ( k− 1) parameters and just d equations, which are in general not enough to identify the 28 model we want to learn. To see a simple example, consider the case where d>k and assume that ( M, ω )is a solution of the system (1.1) ; then also ( MO, O>ω )will be a solution of the same system for any orthogonal matrix O . A possible learning strategy may thus consist in providing additional constraints to system (1.1) , by including also the second and the third order moments. These constraints will be provided by the following proposition: Proposition 1.2.1. Define the following estimators, called respectively the second and the third order sample moments : ˜ M2= n X i=1 x(i)⊗x(i) n−diag( ˜ M1)∈Rd×d ˜ M3= n X i=1 x(i)⊗x(i)⊗x(i) n−˜ M3,2∈Rd×d×d where (˜ M3,2)h,l,m =χh=l=m(( ˜ M1)h+ 3( ˜ M2)h,h) +χ(h6=l=m)∨(l6=h=m)(˜ M2)h,l +χh=l6=m(˜ M2)h,m, χ is the indicator function and ⊗ represents the Kronecker product between vectors. Then we have, for a Poisson naive Bayes model E[˜ M2] = M2= k X i=1 ωiµi⊗µi,(1.2) E[˜ M3] = M3= k X i=1 ωiµi⊗µi⊗µi.(1.3) Proof. We only provide the proof for the second order moment, that for M3 being conceptually identical. Consider first the off-diagonal entries of our 29 estimator, for certain l6=j: E[( ˜ M2)l,j] =E[ n X i=1 (x(i))l(x(i))j n] =E[(X)l(X)j] = k X h=1 ωhE[(X)l(X)j|Y=h] = k X h=1 ωhE[(X)l|Y=h]E[(X)j|Y=h] = k X h=1 ωhµh,lµh,j. The proof for the diagonal terms works similarly: E[( ˜ M2)l,l] =E[(X)2 l]−E[(X)l] = k X h=1 ωhE[(X)2 l|Y=h]− k X h=1 ωhµh,l = k X h=1 ωh(µh,l +µ2 h,l)− k X h=1 ωhµh,l = k X h=1 ωhµ2 h,l where we have used the fact that for a Poisson distribution X with expectation µ, it holds that E[X2] = µ+µ2. The estimators for the second and the third order moments provided above, allow to add d2 + d3 equations to system (1.1) , obtaining the following set of equations:      M1=Pk i=1 ωiµi, M2=Pk i=1 ωiµi⊗µi, M2=Pk i=1 ωiµi⊗µi⊗µi. (1.4) Unlike system (1.1) , system (1.4) admits a unique set of solutions if d≥k and if M is a full-rank matrix, which is a quite generic constraint. In fact, 30 Comon et al. (2017) guarantee that if equation (1.3) has a unique solution and system (1.4) has at least one solution, then also the whole system (1.4) admits the same unique solution. Generic uniqueness of the real solutions of (1.3) is guaranteed by known results on tensor decomposition (Chiantini et al., 2017; Qi et al., 2016), and can be verified using Kruskal’s (Kruskal, 1977) criterion (see also Kolda and Bader, 2009, Sec. 3.2). The fact that the system (1.4) has a unique solution, suggests a possible learning strategy for Poisson’s naive Bayes models: 1. Calculate estimators for the low-order moments of the model, namely ˜ M1,˜ M2and ˜ M3, using equation (1.1) and Proposition 1.2.1. 2. Plug the estimated moments in the left terms of the system (1.4) and find a set of parameters ( ˜ M, ˜ω )that approximately solve that system:      ˜ M1≈Pk i=1 ˜ωi˜µi, ˜ M2≈Pk i=1 ˜ωi˜µi⊗˜µi ˜ M2≈Pk i=1 ˜ωi˜µi⊗˜µi⊗˜µi. (1.5) Notice that the approximations symbols in system (1.5) are required, because the existence and the uniqueness of a solution is only guaranteed in the theoretical scenario where we have infinite data. The idea of this approach is that while the sample size increases, the estimators of moments get closer to their theoretical values, and, as a consequence, the parameters ( ˜ M, ˜ω )will asymptotically approach their theoretical homologous (M, ω). It is important to remark that the usage of the third order moment is necessary to guarantee the uniqueness of solution for system (1.4) , for which it is not sufficient the second order moment, as the following theorem shows. Theorem 1.2.2. Let ( M, ω )a pair of parameters solving the following system of equations: (M1=Pk i=1 ωiµi, M2=Pk i=1 ωiµi⊗µi.(1.6) Then, also the pair (ˆ M, ˆω), where ˆ M=MΩ1/2Odiag(O>ω1/2)−1(1.7) ˆω= (O>ω1/2)◦(O>ω1/2),(1.8) 31 is a solution of the same system, for any orthogonal matrix O , where ◦ is the point-wise (Hadamard) product between vectors.2 Proof. We can rewrite the system (1.6) as follows (M1=Mω M2=MΩM> Our thesis is proved if we demonstrate that (ˆ Mˆω=Mω ˆ Mˆ Ωˆ M>=MΩM> where ˆ Ω = diag(ˆω). We begin with the first equality: ˆ Mˆω=MΩ1/2Odiag(O>ω1/2)−1(O>ω1/2)◦(O>ω1/2) =MΩ1/2OO>ω1/2 =Mω. The second equality works similarly. The only remaining challenge is thus to find a technique able to solve system (1.5) . Concretely, we will need an algorithm A able to recover exactly ( M, ω ) from the unperturbed system (1.4): A: (M1, M2, M3, k)→(M, ω) Furthermore, when the exact moments M1, M2, M3 are not available, and only their estimators ˜ M1,˜ M2,˜ M3 are accessible to the user, A needs to return approximate pairs ( ˜ M, ˜ω )that get closer to ( M, ω )while ˜ M1,˜ M2,˜ M3 get closer to M1, M2, M3 . In the next section we present the most popular approaches to accomplish this task. 1.2.1 Tensor Decomposition In this section we concentrate on the task of solving the system      M1=Pk i=1 ωiµi, M2=Pk i=1 ωiµi⊗µi, M3=Pk i=1 ωiµi⊗µi⊗µi 2We have used the notation Ω = diag(ω). 32 where only the left terms of the equations are known. The objective the task will be to recover the values of the vector ω and of the matrix of the centers M = [ µ1, ..., µk ], assuming to know the value of k . While an overview of approaches for tensor decomposition is presented in the introduction of this thesis, we present here in more detail a few techniques that are widely used in the literature: Alternating Least Square (Carroll and Chang, 1970; Harshman, 1970), SVD method from Anandkumar et al. (2012a) and tensor power method from Anandkumar et al. (2014). Alternating Least Square and Other General-Purpose Decomposition Methods Theoretically, the solution to system 1.4 could be found by looking just at the third order moment, solving the following set of d3equations: M3= k X i=1 ωiµi⊗µi⊗µi(1.9) This is a consequence of the well-known Kruskal’s criterion (Kruskal, 1977), which guarantees that M3 has a unique CP decomposition of the form described at Equation (1.9) . As a consequence, one could simply try to directly decompose the third order moment, without considering the constraints imposed by M2 and M1 which are theoretically redundant. To this objective, a variety of tensor decomposition algorithms exist to approximatively solve this problem, with the algorithm named Alternating Least Square (ALS) (Carroll and Chang, 1970; Harshman, 1970; Kolda and Bader, 2009) being by far the one most used by practitioners. ALS is a general-purpose decomposition algorithm, that works even for non-symmetric tensors, a more general case with respect to that studied by methods of moments. Given a three-dimensional tensor T , it aims at finding three d×kmatrices A= [a1, ..., ak], B = [b1, ..., bk], C = [c1, ..., ck] enabling the following decomposition: T= k X i=1 λiai⊗bi⊗ci(1.10) 33 for a certain vector λ = ( λ1, ..., λk ). After a random initialization, the decomposition is found via an iterative algorithm that first fixes two of the matrices to be learned (say A and B ) and then retrieves C by solving the overdetermined system of equations (1.10) , leaving C as the only unknown variable. This algorithm, which is described in detail by Kolda and Bader (2009), however may have very large running times, because M3 may be very high dimensional. Furthermore ALS is not guaranteed to find the matrices A, B and C allowing the decomposition at Equation (1.10) , even when such decomposition is possible, being prone to poor local optima. Beside ALS, literature provides several examples of general-purpose decomposition methods aimed at finding the decomposition of M3 described at Equation (1.9) (see for example Tomasi and Bro, 2006; Kolda and Bader, 2009; Sidiropoulos et al., 2017). A recent example, that specifically focuses on the case of a symmetric tensor with the structure of M3 is the Random Projections method, proposed by Kuleshov et al. (2015). The method consists in finding the matrix M by directly performing simultaneous diagonalization – using a variation of the well-known Jacobi algorithm (Cardoso and Souloumiac, 1996) – of random linear combinations of the slices of M3 , which the authors observe admitting the following writing M3,r =MΩ1/2diag(mr)Ω1/2M>, where M3,r is the r th slice of M3 and mr is the r th row of M . This method, under an incoherence assumption on the vectors µi , can robustly recover the weights ωi and vectors µi from the tensor M3 , even when it is not orthogonally decomposable. However, in practice the Random Projections method is way slower than ALS (see for example the experiments in Chapter 5) and hardly usable on high-dimensional tensors, reason why we will omit it from most of the experiments of this thesis. The SVD Method Anandkumar et al. (2012a) provide a simple technique to solve the system of equations (1.4) , based on the well-known Singular Value Decomposition (SVD) of a matrix (Golub and Reinsch, 1970). Letting M2 = USU> be the SVD of M2 , the authors develop two equivalent writings for the second order moment: M2=EE>, M2=MΩM>,(1.11) 34 where E = US1/2∈Rd×k will be called the whitening matrix and Ω = diag(ω) , and show that there exists a unique orthogonal matrix O∈Rk×k such that M Ω 1/2 = EO . The SVD method consists thus of finding O and retrieving the desired parameters by solving the following system of equations: (MΩ1/2=EO Mω =M1. To find O , they introduce the following matrix-based characterization of the slices of M3: M3,r =MΩ1/2diag(mr)Ω1/2M>=EO diag(mr)O>E>, where M3,r is the r th slice of M3 and mr is the r th row of M . Multiplying M3,r at the left and at the right with the pseudoinverse (Stewart and Sun, 1990) of matrix E, they get a new matrix Hr=E†M3,r(E†)>=Odiag(mr)O> whose left singular vectors coincide with the matrix O . However, the singular vectors O may not be uniquely determined if two or more values of mr are identical; to solve this issue, Anandkumar et al. (2012a) suggest to perform a random linear combination of the various matrices Hr , using some random vector η∈Rd, and get the matrix Hη=Odiag((ηµ> 1, ..., ηµ> k))O> whose left singular vectors are almost surely unique. SVD method requires the matrix M to be full rank, and asks for d≥k . Under these conditions, it guarantees to return the exact solution of the system (1.4) (Anandkumar et al., 2012a) – a guarantee that ALS does not present. The behavior of this method has been also studied in the context where it only has access to perturbed moments, providing guarantees of learning accuracy even in a perturbed setting. Another critical advantage over ALS lays in the fact that it works with lowdimensional whitened matrices, a fact that dramatically reduces its memory requirements and speeds up its running time, which is extremely competitive. 35 However, despite its theoretical soundness, SVD method is known to have a poor learning accuracy, not being able to learn reliable model parameters when the input moments are perturbed (see Anandkumar et al. 2014, and Chapter 2). Tensor Power Method The tensor power method (TPM) (Anandkumar et al., 2014) also considers the whitening matrix defined above, E = US1/2∈Rd×k , as defined in the previous section, but instead of whitening the slices of M3 , it directly whitens the full tensor M3into a symmetric orthogonally decomposable tensor: T= k X i=1 ωiE†µi⊗E†µi⊗E†µi∈Rk×k×k The authors then observe that if ( v, λ )is a robust eigenvector/eigenvalue pair of T , then there exists a column µi of M such that λEv = µi . Consequently, the problem reduces to find the robust eigenvectors of T , a task that is performed via a three-dimensional extension of the well-known matrix power method to find the eigenvectors of the matrix. The requirements and the guarantees of TPM are similar to those of SVD method: M should be full rank, d≥k and it guarantees to return the exact solution of the system (1.4) . A study of its robustness to perturbation has been carried on by Anandkumar et al. (2014); in general, TPM is known to provide a better learning accuracy with respect to the SVD method. TPM works with whitened tensors, which makes it faster than ALS. However, its running time is asymptotically slower than that of SVD method – depending a factor O ( k5 )on the number of latent states k . This makes the scalability the major drawback of TPM. 36 Remark 2.1.1 (On the generality of the algorithm) . Like other decomposition algorithms for methods of moments, our method requires the number of latent states to be smaller than the features size, k≤d , which is in general a realistic requirement: think for example of the naive Bayes models to perform clustering; in general one wants to retrieve few tens of clusters from hundreds of available features. Also, we remark that during the construction of the algorithm we have not made any hypotheses on the probability distribution of the data; instead, we have required the matrix M to be full rank and, in addition, to have at least one feature r with different conditional expectations on the various clusters. Furthermore, we do not need to know in advance what this feature is, as Remark 2.1.2 will explain. This last requirement is not present in the other matrix-based methods, as they rely on a randomized matrix to guarantee the uniqueness of the results (see Section 2.1.1); but the reconstruction accuracy of these methods is significantly worse than that of SVTD, as we will show experimentally. Finding a deterministic method that joins the scalability properties of simultaneous diagonalization methods without requiring this separation condition is an interesting open problem. Remark 2.1.2 (On the selection of feature r ) . The initial steps of the algorithm require the isolation of a feature r to compute the matrix O . While theoretically we could select any feature r such that all elements of mr = ( µ1,r, ..., µk,r )are distinct, it is clear that, if matrices M1 , M2 and M3 are subject to perturbations, the results obtained by the algorithm might vary, depending on the selected feature r . However, known results from matrix perturbation theory (see for example Stewart and Sun 1990), indicate that the matrix O (which contains the singular vectors of Hr ) is more sensitive to random perturbations when the minimum difference between the entries of mr = ( µ1,r, ..., µk,r )is small. This fact suggests that a possible heuristic to choose the feature r (and hence a reliable matrix O ), is to repeat steps 3 and 4 of the algorithm, isolating different features and selecting the one that maximizes the quantity mini6=j(|µi,r −µj,r|).With this heuristic, a user can run SVTD without any previous knowledge of the feature to extract. Its cost is that of performing d times a k×k SVD, therefore O ( d k3 ), and is dominated by the costs of other parts of the algorithm as discussed next. Remark 2.1.3 (Complexity analysis) . We start analyzing the time complexity. Using randomized SVD techniques (see Halko et al., 2011), step 1 can be carried out with a total of O ( d2k )steps, the SVD on E†M3,r ( E> ) † requires O ( k3 )steps while step 6 requires O ( d2k )steps for matrix multiplication for 43 each one of the diterations. So the overall complexity of Algorithm 1 is O(d2k+k3+d3k). We need to add the additional cost of the feature-selection method outlined in Remark 2.1.2, whose cost is O ( dk3 ). Since d≥k , this cost is dominated by the larger O(d3k)component. It is important to highlight that the general implementation given in Algorithm 1 has mainly a descriptive purpose. For a specific latent variable model, optimized implementations may exists, as we will see in Chapter 4. Computations can be further accelerated by exploiting the sparsity of the data, that is, using sparse matrix arithmetic techniques. We also remark that the algorithm is trivially parallelizable: Assuming that we have m machines on which to parallelize steps 5, 6, 7 of the algorithm and the feature selection task, we can reduce the total running time to O(d2k+k3+d3k/m). Regarding memory, notice that we never use the full tensor M3 , but only its r th slice, for the selected feature r . This means that only that slice has to be computed and stored, and the memory complexity of the algorithm is O(d2). These complexity requirements are comparable to those of the methods from Anandkumar et al. (2012a,b); however, those methods are randomized, with nontrivial variance in their output, so they may require several runs of the full algorithm in order to provide accurate results. The tensor power method from Anandkumar et al. (2014) has in general higher cost. It is an iterative technique, with a number of iterations difficult to bound a priori; the authors suggest that accuracy  can be reached with O ( k5+δ ( log ( k ) + log log (1 / ))) operations, among iterations, random restarts and actual matrix operations, higher than our O ( k3 ). To this time we need to add the time to get the k×k×k whitened tensor from the sample, which is not trivial for many LVMs. 2.1.1 Comparison with other decomposition methods. As said in Chapter 1, Kruskal’s criterion guarantees that M3 has a unique CP decomposition, so, instead of SVTD, one could simply try to directly decompose the third order moment, using for example one of the generalpurpose tensor decomposition methods described by Tomasi and Bro (2006); Kolda and Bader (2009); Sidiropoulos et al. (2017), to retrieve the parameters ( M, ω ). However, this approach is impractical: M3 may be too large, 44 and explicitly decomposing it may not even be computationally feasible on common machines. SVTD instead relies on the full system of equations (1.4) , and uses a whitening matrix to work with low dimensional tensors, while maintaining guarantees of provably solving the considered system. For example, the whitening step that SVTD performs at step 4 of Algorithm 1 reduces the slices of M3 to small k×k matrices, reducing the complexity of the algorithm and allowing for fast yet optimal solutions on commodity machines, even when dhas is very high. The tensor power method (TPM) – described by Anandkumar et al. (2014) and recalled in Chapter 1 – is the most popular alternative. While very robust, the implementation of this method may be complex for someone who is not familiar with tensors. In addition, it is an iterative method, and so it requires a tuning of the hyperconvergence parameters, which might require many trial-and-error tests. These practical considerations, together with its higher time and memory complexity outlined in Remark 2.1.3, are drawbacks compared to matrix-based methods like SVTD. Matrix-based methods from Anandkumar et al. (2012a,b), are technically more similar to the method presented here, and they are two variations of the same approach, one (Anandkumar et al., 2012b) using eigenvectors, and the other (Anandkumar et al., 2012a) using singular vectors, and have been presented as well in Chapter 1. There are at least two differences between SVTD and these approaches: 1. The first difference is the way the matrix M is retrieved. In fact, the SVD method from Anandkumar et al. (2012a) recovers M essentially from Equation (2.3), relying on the identity MΩ1/2=EO while SVTD recovers the r th row of M from the singular values of the matrix Hr=E†M3,r(E†)>=Odiag(mr)O>. 2. The second difference, is how the matrix O is retrieved; SVD method gets it as the singular vectors of Hη=E†( d X r=1 ηrM3,r)(E†)>=Odiag((ηµ> 1, ..., ηµ> k))O>, 45 for some random vector η∈Rd . The introduction of the random vector η has the purpose of guaranteeing that the elements of ( ηµ> 1, ..., ηµ> k ) are almost surely distinct, and so O is unique. In SVTD instead we fix a specific feature r , choosing the one with the maximum minimum variation between the feature components; this is the same of saying that we fix η to be the r th coordinate vector, giving a recipe for finding r in Remark 2.1.2, providing in this way the choice that maximizes stability. 2.2 Perturbation Analysis In the previous section we have presented an algorithm to recover the parameters ( M, ω )from the unperturbed low-order moments M1 , M2 and M3 . However, in real world applications, we do not have access to the exact values of the moments, but to a set of estimators ˜ M1 , ˜ M2 and ˜ M3 that aim at approximating them, with the guarantee that each estimator ˜ Mi gets closer to its theoretical counterpart Mi while the sample size increases. When learning a latent variable model from data, we thus plug the estimated moments ˜ M1 , ˜ M2 and ˜ M3 into a decomposition algorithm like SVTD; ideally, the more similar the perturbed moments are to their expectations, the better the output parameters ( ˜ M, ˜ω )of the algorithm are expected approximate ( M, ω ). The following theorem shows that SVTD presents this property, showing how the approximation of the input moments propagates to the estimated model parameters. Theorem 2.2.1. Given the unperturbed versions of M1 , M2 and M3 and the feature we want to isolate, r, let αrand αM2be αr= min i6=j(|µi,r −µj,r|)>0, αM2= min i≤k(σi(M2)2−σi+1(M2)2)>0 where σi ( M2 )are the singular values of M2 . Assume the empirical estimates ˜ M2and ˜ M3satisfy || ˜ M2−M2||F< , || ˜ M3−M3||F< . Then, there exists a function 1γ ( M, ω ), of the model parameters, such that, if <γ ( M, ω ), Algorithm 1, fed with ˜ M1 , ˜ M2 and ˜ M3 , provides an estimated 1 For an explicit formulation of the value of γ ( M, ω ), we refer the reader to the proof of the theorem and to Remark 2.2.1. 46 matrix ˜ Mwhose rows ˜mi, for all i∈ {1, ..., d}, satisfy ||mi−˜mi||2≤C1+√k αr (C2+C3 αM2 ) + O(√kC42) where mi are the rows of M , C1 , C2 and C3 are polynomial functions of ||E||F,||O||F and ||M3,i||F , and C4 is a polynomial function of ||E||F , ||O||F , ||M3,i||F,1/αrand 1/αM2. A key role is played by αr , the minimum difference between the elements of ( µ1,r, ..., µk,r ); when samples are large enough, the theorem guarantees that the algorithm works correctly, although “large enough” depends on αr . When this condition is not satisfied, the learning algorithm still works, but might provide output results that are different from the theoretical generative model. We recall here Remark 2.1.2, where we wondered how to select the proper feature r ; Theorem 2.2.1 confirms the intuition that the one guaranteeing the highest accuracy would be the one with the highest possible αr. The role played by αM2 is less intuitive, as it is not directly related to the parameters of the model. Looking at the proof of the theorem, it is possible to see that αM2emerges as a consequence of the whitening step. In particular, the whitening matrix E is calculated from the singular vectors of the perturbed M2 , whose sensitivity to perturbations gets worse when αM2 is small. We can conjecture that if we were able to find a different method to retrieve the whitening matrix, we could get rid of the component dependent on αM2 in the perturbation theorem; this is equivalent to claim that the components depending on αM2 in the perturbation bound are a consequence of the algorithm that we are using rather than of the complexity of the problem. The exploration of this conjecture and the research of algorithms to calculate the whitening matrix not depending on αM2 is an open problem for future research. 2.2.1 Proof of Theorem 2.2.1 The goal of the proof is to develop a perturbation bound for each row mi of the unknown matrix M such that, ||˜mi−mi||2≤Bound (  ) , for a certain function Bound (  ). We notice, from Algorithm 1, that each ˜mi is obtained as the diagonal entries of the following matrix: ˜ O>˜ E†˜ M3,i(˜ E>)†˜ O, 47 where the tildes indicate that we are dealing with perturbed matrices. Therefore, we will need to find the perturbations of the matrices composing this equation, as the following relation holds: ||˜mi−mi||2≤ ||˜ O>˜ E†˜ M3,i(˜ E>)†˜ O−O>E†M3,i(E>)†O||F. In short, having perturbation bounds on ˜ M3,i , ˜ E† and ˜ O will be sufficient to reach our goal. Perturbations on ˜ M3,i We know by hypothesis that || ˜ M3,i −M3,i||F=||∆M3,i ||F< . Perturbations on ˜ E† It is a known fact (see Stewart, 1990) that, given the SVD ˜ M2 = ˜ U˜ S˜ V , and M2=USU>,if || ˜ M2−M2||F< , we have that ||˜ S−S||F≤. (2.4) Algorithm 1, when fed with perturbed moments retrieves a perturbed whitening matrix ˜ E = ˜ Uk ( ˜ Sk ) 1/2, while the unperturbed value of E is defined as E = Uk ( Sk ) 1/2, where the subscript k indicates the truncation at the k th singular value. So, to reach a perturbation bound on ˜ E† , we first need to look for a perturbation bound on ˜ E , that will be obtained bounding the error of ( ˜ Sk ) 1/2 and ˜ Uk . The first one is a consequence of equation (2.4) : if ∆S= ( ˜ Sk)1/2−S1/2 k, we have ||∆S||F< 2pσk(M2), where σk ( M2 )is the k th the singular value of M2 . To find a bound on ˜ Uk we will use Lemma 2.2.1 to get ||˜ Uk−Uk||F<√8k2||M2||F+2 αM2 , where αM2 = mini≤k(σi(M2)2−σi+1(M2)2) and σi ( M2 )are the singular values of M2 . We thus conclude that, if ∆ U = ˜ Uk−Uk , ˜ E=E+ ∆US1/2+U∆S+ ∆U∆S , 48 and hence ||˜ E−E||F< f() = ||S1/2||F√8k2||M2||F+ αM2 +||U||F 2pσk(M2)+ +√8k2||M2||F+2 αM2(2pσk(M2)). We are now ready to find a perturbation bound on the pseudoinverse of ˜ E , using a known bound from Stewart and Sun (1990): if ||˜ E−E||F< f (  )then ||˜ E†−E†||F≤f()τ(E) where τ(E) = ||E†||2 F+||(E>E)−1||F||I−EE†||F. Perturbations on ˜ O We now look for the value of g (  ) = ||O−˜ O||F . If SVTD is fed with unperturbed moments, Ocomes from the decomposition of E†M3,r(E>)†: E†M3,r(E>)†=Odiag(mr)O>.(2.5) ˜ O will be obtained from the singular vectors of the same, but perturbed, matrix: ˜ E†˜ M3,r(˜ E>)†.First, we observe that ||E†M3,r(E>)†−˜ E†˜ M3,r(˜ E>)†||F≤ ≤2f()τ(E)||E†||F||M3,r||F+||E†||2 F + 2f()τ(E)||E†||F +f()2τ(E)2(||M3,r||F+) =h(). Using Corollary 2.2.1, we assume the hypothesis that h()≤α2 r √2 2||Hr||F(1 + q1−1 k) + rα2 r+ 4||Hr||2 F(1 + q1−1 k)2!(2.6) where Hr = E†M3,r ( E> ) † and αr = mini6=j ( |µi,r −µj,r| ), to get that ||˜ O− O||F< 2 √2h()/αr = g (  ). We are now able to conclude our proof by analyzing ||mi−˜mi||2≤ || ˜ O>˜ E†˜ M3,i(˜ E>)†˜ O−O>E†M3,i(E>)†O||F≤ 49 ≤P1g() + P2+P3f() + O(2P4), where P1, P2 and P3 are polynomials in ||E||F,||O||F and ||M3,i||F , and P4 is a polynomial in ||E||F,||O||F,||M3,i||F, g (  ) ,  and f (  ). The thesis follows making explicit these polynomials. Remark 2.2.1. In the statement of Theorem 2.2.1, we said that there exists a number γ ( M, ω ), such that, if <γ ( M, ω ), the perturbation bound of the thesis works. Looking at the proof of the theorem, we are able to explicitly calculate this number, just by solving the inequality (2.6) . We can practically think at γ(M, ω)as the largest value of that satisfies this inequality. Lemma 2.2.1. Consider M2 , the perturbed ˜ M2 , and their SVD, ˜ M2 = ˜ U˜ S˜ V> , M2 = USU> . Let ˜ Uk and Uk be matrices of the first k left singular vectors of ˜ M2 and M2 . Define αM2 = mini≤k(σi(M2)2−σi+1(M2)2) . If || ˜ M2−M2|| <  , then ||˜ Uk−Uk||F<√8k2||M2||F+2 αM2. Proof. Consider ˜ M2˜ M2> = ˜ U˜ S2˜ U> and M2M> 2 = US2U> . Then || ˜ M2˜ M2>− M2M2>||F≤ 2 ||M2||F + 2. Take now the matrix of the first k columns of U and ˜ U , that are eigenvectors of M2M2> and ˜ M2˜ M2> , obtaining Uk = [ u1, .., uk ] and ˜ Uk = [ ˜u1, .., ˜uk ]. From Theorem 2.2.2 we have that, for any i = 1 , ..., k , holds ||ui−˜ui|| ≤ 23 22||M2||F+2 min(σi−1(M2)2−σi(M2)2, σi(M2)2−σi+1(M2)2) ≤23 22||M2||F+2 αM2 from which the thesis follows. The following results, taken from Yu et al. (2015) and Chen et al. (2012), present perturbation bounds on the eigenvectors and on the singular vectors of symmetric matrices. Theorem 2.2.2 (Cor. 1, pg. 4 Yu et al. 2015) . Consider A and ˜ A two symmetric matrices in Rd×d , with eigenvalues λ1≥... ≥λd and ˜ λ1≥... ≥˜ λd . Fix a j∈ { 1 , ..., d} and assume that min ( λj−1−λj, λj−λj+1 ) > 0, where we 50 define λ0 = ∞ and λd+1 = −∞ . If v∈Rd (resp. ˜v ) is an eigenvector of A (resp. ˜ A), associated to λi(resp. ˜ λi), then ||v−˜v|| ≤ 23 2||A−˜ A||F min(λj−1−λj, λj−λj+1) Theorem 2.2.3 (Thm. 3.2, Chen et al. 2012) . Let B∈Rk×k be a matrix, with SVD B = Udiag (( σ1, ..., σk )) V> with σ1> σ2> ... > σk> 0, and let ˜ B=B+ ∆Bbe a perturbed matrix, with SVD ˜ B=˜ Udiag((˜σ1, ..., ˜σk)) ˜ V>. Define: αB= min i6=j|σi−σj|>0, B=√2||∆B||F αB , γB=||B||F αB (1 + r1−1 k) Then, if B≤1 2γB+p1+4γ2 B (2.7) The following upper bound holds: ||U−˜ U||F≤√2B q1−2γBB+p1−2 B−4γBB (2.8) The following corollary is essentially a rewriting of the previous theorem. Corollary 2.2.1. In the same setting of Theorem 2.2.3, if there exists an  > 0such that ||∆B|| <  ≤α2 B √2 2||B||F(1 + q1−1 k) + rα2 B+ 4||B||2 F(1 + q1−1 k)2! then ||U−˜ U||F≤2√2 αB. Proof. Note that if  satisfies the hypothesis of the corollary, then (2.7) is satisfied and hence we have (2.8): ||U−˜ U||F≤√2B q1−2γBB+p1−2 B−4γBB≤√2B √1−2γBB 51 Now we plug in the last equation the bound of (2.7), to get ||U−˜ U||F≤√2B r1−2γB 2γB+√1+4γ2 B =√2Bs2γB+p1+4γ2 B p1+4γ2 B ≤√2Bs2γB p1+4γ2 B + 1 ≤2B 2.3 Experiments In this section we test the algorithm presented in this chapter against other decomposition methods. Experimental setting: All the experiments in this section have been run on a MacBook Pro with a 2.7 GHz Intel Core i5 processor and 8 GB of RAM memory. All the algorithms have been implemented in Python 2.7 (interpreted, not compiled), using the numpy (Walt et al., 2011) library for all linear algebra operations, including Singular Value Decomposition, for which we used numpy’s non-randomized SVD. 2 SVTD and the methods from Anandkumar et al. (2012a,b, 2014) have been implemented by this thesis author. For ALS we have used the implementation provided by scikit-tensor. 3 All the implementations written by the author of this thesis, as well as the code of the implementations of the competing methods, have been publicly disclosed and are freely accessible.4 We test SVTD on the task of decomposing a tensor of moments obtained from 2https://docs.scipy.org/doc/numpy/reference/generated/numpy.linalg.svd. html 3https://github.com/mnick/scikit-tensor 4https://github.com/mruffini/SpectralMethod.git 52 applicable in real-world contexts. For example, the estimators provided by Anandkumar et al. (2012a) and Anandkumar et al. (2012b) are not usable in practice, because they are extremely sensitive to the noise. More robust estimators have been introduced by Zou et al. (2013), however without theoretically assessing their convergence rate, or experimentally testing their performance on real data. In this chapter, we will consider two classic topic models, namely the singletopic model and LDA, we will provide improved estimators for their moments – in Section 3.2 for the single-topic model and in Section 3.3 for LDA – and present a theorem that relates their sample accuracy to the sample size and to the lengths of the documents. In Section 3.4 we will experimentally show that the proposed estimators outperform those from existing literature in terms of convergence speed. Section 3.4.2 will be dedicated to use the provided estimators, together with SVTD, to learn from real-world text corpora the topic models studied in this chapter and to compare their learning performance with those of traditional methods based on Markov-Chain Monte Carlo (MCMC); we will show that the proposed approach has significantly better performance in terms of both speed and quality of the learned model. 3.1 Learning Topic Models with Methods of Moments In Chapter 1, we have seen an example of application of methods of moments to learn latent variable models. We have seen that for any model admitting a parametrization in terms of centers and weights ( M, ω ), the following two-steps approach allows to learn asymptotically converging estimators of the model parameters: 1. Recover a set of estimators ˜ M1 , ˜ M2 and ˜ M3 whose expectation exhibit 59 the following relations with the model parameters: E[˜ M1] = M1= k X i=1 ωiµi,(3.1) E[˜ M2] = M2= k X i=1 ωiµi⊗µi,(3.2) E[˜ M3] = M3= k X i=1 ωiµi⊗µi⊗µi.(3.3) 2. Plug the retrieved estimates into a decomposition algorithm – like for example SVTD from Chapter 2 – to retrieve from those estimates an estimated pair of model parameters (˜ M, ˜ω). In this chapter we will focus on learning topic models with methods of moments, concentrating on the single-topic model and on LDA, and following the two-steps approach described above. As the second step, namely the decomposition part, has been extensively treated in Chapter 2, we will focus here on the first part, the moment estimation procedure. Once we will have unbiased moment estimators, we will be able to retrieve asymptotically converging estimates of the model parameters, decomposing the moments for example with SVTD. 3.2 Moments Estimators for the Single-Topic Model In this section we recall the single-topic model for which we introduce a new estimator of the moments; we then provide a sample accuracy bound for this estimator and we compare it with existing methods. We consider a corpus of n text documents and a set of k topics; each document is deemed to belong to only one topic. The vocabulary appearing in the corpus consists of d words, from which it is immediate to label all the words of the vocabulary with a number between 1and d . The generative process works as follows: 60 • First, a (hidden) topic Y∈ { 1 , ..., k} is drawn, according to a given probability distribution; we define, for any j∈ { 1 , ..., k} the probability of drawing the topic jas follows: ωj=P(Y=j),and ω= (ω1, . . . , ωk)>. • Once the topic has been chosen, all the words of the documents are generated according to a multinomial distribution; for each i∈ { 1 , ..., d} , µj,i will be the probability of generating the word iunder topic j: P(Drawing word i|Y=j) = µj,i, . Also we will denote by µj = ( µj,1, ..., µj,d )the vectors containing the probabilities of the various words to appear under topic j . It is a common practice to identify a topic with the probability distribution of the words under that topic, i.e. with each of the vectors µ1, . . . , µk . We will denote with M the matrix whose columns coincide with the topics: M= [µ1|, ..., |µk]. A practical encoding of the words in a document consists of identifying the tth word of a text with Twords with a d−tuple Xt∈Rd, defined as: (Xt)h=(1if the word is h, 0otherwise. In fact, if Xt is the t th word of a document of T words, we can define a vector X whose coordinate h represents the number of times the word h has appeared in the document: X = PT t=1 Xt. It is common to call X abag of words representation of a document. We can see that, if the topic is j , each coordinate of X is distributed as a binomial distribution with parameter T and µj,i: Distr((X)i|Y=j) = B(T, µj,i). Remark 3.2.1. The single-topic model is a powerful tool for text mining; assume to have a corpus of texts X and to have a single-topic model with parameters ( M, ω )that accurately describes it. Then, it is possible to infer, for each text x of the corpus, the latent topic that best describes that text, using the following formula: P(Y=j|X=x) = P(X=x|Y=j)ωj Pk i=1 P(X=x|Y=i)ωi .(3.4) 61 This formula also enables us to cluster the texts of a corpus, grouping together those that deal with the same topic. It is immediate to observe that the single-topic model admits a parametrization similar to the one provided in Chapter 1 for naive Bayes models, in terms of a vector of weights ω and a matrix of centers (here, the topics) M . We now consider a corpus of ndocuments X={x(1), ..., x(n)} where each vector x(i) is a bag of words representation of the document i , whose length is ti: x(i)= ti X t=1 x(i) t. Any learning algorithm for the single-topic model will aim at recovering from a dataset X , an estimate of the parameter ( M, ω )of a single topic model that is approximately generating the data. We know from Chapter 1, that, if we assume the matrix of the topics M to be full rank, it will be enough to recover a set of estimators ˜ M1 , ˜ M2 and ˜ M3 whose expectation will respect the relations described at Equations 3.1,3.2 and 3.3. The following theorem provides these estimators. Theorem 3.2.1. Fix a value n∈N , and let x(1), ..., x(x) be n sample documents generated according to a single-topic model with parameters ( M, ω ). Define the vector ˜ M1∈Rd , and the symmetric tensors ˜ M2∈Rd×d and ˜ M3∈Rd×d×dwhose entries are as follows, for h≤l≤m: (˜ M1)h=Pn i=1(x(i))h Pn i=1 ti , (˜ M2)h,l =Pn i=1(x(i))h(x(i)−χh=l)l Pn i=1(ti−1)ti , (˜ M3)h,l,m =χh<l<m Pn i=1(x(i))h(x(i))l(x(i))m Pn i=1(ti−2)(ti−1)ti +χ(h=l<m)∨(h<l=m)Pn i=1(x(i))h(x(i)−1)l(x(i))m Pn i=1(ti−2)(ti−1)ti +χh=l=mPn i=1(x(i))h(x(i)−1)l(x(i)−2)m Pn i=1(ti−2)(ti−1)ti , 62 where χ is the indicator function and ti is the number of words appearing in document i . Then, the estimators ˜ M1 , ˜ M2 and ˜ M3 respect the relations described at Equations 3.1,3.2 and 3.3. Proof. We will prove the statements only for EPn i=1(x(i))h(x(i))l Pn i=1(ti−1)ti= k X j=1 ωjµj,jµj,l. Similar arguments hold for the other equations. It is easy to see, by conditional independence, that E((x(i))h(x(i))l) = k X j=1 ωjE((x(i))h(x(i))l|Y=j) but the conditioned ( x(i) ) h and ( x(i) ) l are components of a multinomial distribution and so k X j=1 ωjE((x(i))h(x(i))l|Y=j) = k X j=1 ωj(t2 i−ti)µj,hµj,l, which implies the thesis. Notice that, because M2 and M3 are symmetric, the previous theorem defines all the entries of these tensors. Given a sample, we are able to calculate the three estimators ˜ M1 , ˜ M2 and ˜ M3 . It is immediate to see that limn→∞ ˜ Mi=Mifor i= 1,2,3. The following theorem provides a sample accuracy bound for the estimators of Theorem 3.2.1. Theorem 3.2.2. Let ˜ M2 and ˜ M3 be the empirical estimates of M2 and M3 obtained using Theorem 3.2.1, and let ( t1, ..., tn )be a vector containing the lengths of the various documents of the corpus. Define T1= n X i=1 ti, T2= n X i=1 (ti−1)ti, T3= n X i=1 (ti−2)(ti−1)ti, W(n) 2=Pn i=1(ti(ti−1))2 T2 2 , W(n) 3=Pn i=1(ti(ti−1)(ti−2))2 T2 3 . 63 Then, for any pair  > 0and 0≤δ < 1, such that qW(n) 2(1 −||M2||2 F) + r2W(n) 2log(1 δ)< , it holds that P(||M2−˜ M2||F< )>1−δ. Also, for any pair  > 0and 0≤δ < 1, such that qW(n) 3(1 −||M3||2 F) + r2W(n) 3log(1 δ)< , it holds that P(||M3−˜ M3||F< )>1−δ. Remark 3.2.2. We briefly comment on the meaning of the theorem by focusing on M2 (similar arguments hold for M3 ) and analyzing the case where all the documents have the same length t ( ti = t for all i ). Then the bound simplifies to: r1 n(1 −||M2||2 F) + r1 nlog(2 δ). It is interesting to notice that the worst-case accuracy of the bound is  = O (1 /√n ). An interpretation for this fact is that, even if the documents in the corpus are very long (large t ), it is impossible to accurately learn the model with just a few samples, as in particular we may not even see all the topics. Remark 3.2.3 (Alternative estimates of the moments) . The simplest estimation of the low-order moments for the single-topic model is provided by Anandkumar et al. (2012b), who, for each document i∈ { 1 , ..., n} consider three randomly selected words, x(i) 1, x(i) 2, x(i) 3,and then show that Pn i=1(x(i) 1)h n−−−→ n→∞ (M1)h,Pn i=1(x(i) 1)h(x(i) 2)l n−−−→ n→∞ (M2)h,l, Pn i=1(x(i) 1)h(x(i) 2)l(x(i) 3)m n−−−→ n→∞ (M3)h,l,m. This method only uses three words per document, and has mainly illustrative purposes, as noticed by the authors. A method more similar to the one 64 proposed in Theorem 3.2.1 is described by Zou et al. (2013). Both the method by Zou et al. (2013) and that in Theorem 3.2.1 average the estimators with the document lengths, taking into consideration all the words in each document. However, in the method by Zou et al. (2013), the averaging is done for each document and then they are averaged together with the same weight; for example, Zou et al. (2013) calculate the off-diagonal entries of ˜ M2 as follows: (˜ M2)h,l =1 n n X i=1 (x(i))h(x(i))l (ti−1)ti . This calculation is a simple average of many estimators giving the same weight to all documents, namely 1 /n . Instead, in Theorem 3.2.1, we propose the following different formula: (˜ M2)h,l =Pn i=1(x(i))h(x(i))l Pi(ti−1)ti = n X i=1 (x(i))h(x(i))l (ti−1)ti (ti−1)ti Pj(tj−1)tj . We can see that here we perform a weighted average, where the weight of the sample i is (ti−1)ti Pj(tj−1)tj , giving in practice more weight to longer documents, which are supposed to be the most reliable; we will experimentally see in Section 3.4 that the proposed approach is less sensitive to noise, leading to improved results. If all the documents have the same length, the two estimates will produce the same number. 3.2.1 Proof of Theorem 3.2.2 We want to express the elements of the matrix ˜ M2−M2 in an appropriate way and then express a bound using McDiarmid’s inequality (McDiarmid 1998 and Lemma 3.2.1). We consider the set of all the documents in a corpus: ˜ X= (x(1), ..., x(n)). It is easy to see that ˜ M2can be expressed as a function of ˜ X: ˜ M2(X) = n X i=1 wi˜ M2 (i)(3.5) where wi = ti(ti−1) T2 , ti is the length of the i th document, T2 = Pn i=1 ti ( ti− 1), and ˜ M2 (i)are independent matrices defined as follows: (˜ M2 (i))(u,v)=(x(i))u(x(i)−χu=v)v ti(ti−1) .(3.6) 65 Notice that, for any i , E ( ˜ M2 (i) ) = M2. We now define the following function: Φ( ˜ X) = || ˜ M2(˜ X)−M2||F and observe that, given two samples differing only by one element ˜ X= (x(1), ..., x(l), ..., x(n) i) ˜ X0= (x(1), ..., x(l)0, ..., x(n) i) we obtain the following inequality: |Φ( ˜ X)−Φ( ˜ X0)| ≤ || ˜ M2(˜ X)−˜ M2(˜ X0)||F= =||wl(˜ M2 (l)−˜ M2 (l)0 )||F where ˜ M2 (l)0 is calculated plugging x(l)0 in formula (3.6) . Now, observing that || ˜ M2 (l)||F≤1and || ˜ M2 (l)0 ||F≤1, we obtain: ||wl(˜ M2 (l)−˜ M2 (l)0 )||F≤2wl The inequality above enables us to apply McDiarmid’s inequality, stating that P(|| ˜ M2−M2||F>E(|| ˜ M2−M2||F) + )≤e−2 2Pn i=1 w2 i=e−2 2W(n) 2=e−t2, where we used the notation W(n) 2=Pn i=1 w2 i, and defined t= q2W(n) 2 . We now provide a bound for E(|| ˜ M2−M2||F) . Using Jensen’s inequality we have E(|| ˜ M2−M2||F)≤qE(|| ˜ M2−M2||2 F) = =qE(|| ˜ M2||2 F)−||M2||2 F=v u u tX u,v E(( n X i=1 wi(˜ M2 (i))(u,v))2)−||M2||2 F where we have used Equation (3.5). This last term is equal to v u u tX u,v E( n X i=1 w2 i(˜ M2 (i))2 (u,v)) + X u,v E(X i6=j wjwi(˜ M2 (i))(u,v)(˜ M2 (j))(u,v))−||M2||2 F 66 and using the fact that E(˜ M2 (i) (u,v)˜ M2 (j) (u,v))=(M2)2 (u,v), this equals v u u t n X i=1 w2 iE(|| ˜ M2 (i)||2 F) + X i6=j wjwi||M2||2 F−||M2||2 F. Now using that || ˜ M2 (i)||F≤1, we can bound this from above by v u u t n X i=1 w2 i+||M2||2 F(X i6=j wjwi−1) = v u u t n X i=1 w2 i(1 −||M2||2 F). where in the last equality we used the fact that Pi6=jwjwi = 1 −Pn i=1 w2 i . So, using the notation W(n) 2 = Pn i=1 w2 i , we have E ( || ˜ M2−M2||F ) ≤qW(n) 2(1 −||M2||2 F), from which we obtain P(|| ˜ M2−M2||F>qW(n) 2(1 −||M2||2 F) + tq2W(n) 2)≤e−t2. In conclusion, we can state that if e−t2=δwe get, for any δ∈(0,1] P(|| ˜ M2−M2||F> )≤δ where =qW(n) 2(1 −||M2||2 F) + r2W(n) 2log(1 δ) A similar argument works for M3. Lemma 3.2.1 (McDiarmid’s inequality, McDiarmid 1998.) . Let X1, ..., Xm be independent random variables all taking values in the set C . Furthermore, let f : Cm→R be a function of X1, ..., Xm satisfying for all i and for all x1, ..., xm, x0 i∈ C , |f(x1, ..., xi, ..., xm)−f(x1, ..., x0 i, ..., xm)| ≤ ci. Then for all  > 0, P(f−E[f]≥)≤exp(−22 Pm i=1 c2 i ). 67 3.3 Extension to Latent Dirichlet Allocation In this section we extend the results of the previous section to a more complex latent variable model, the latent Dirichlet allocation or, for short, LDA. The obvious criticism of the single-topic model is that each document can deal with a unique topic, a hypothesis that is commonly considered unrealistic. To overcome this issue, more complex models have been introduced, one of them being LDA (Griffiths and Steyvers, 2004; Blei et al., 2003). In its simplest form, LDA assumes that each document deals with a multitude of topics, in proportions that are governed by the outcome of a Dirichlet distribution. More precisely, considering our text corpus with n documents with a vocabulary of d words, the generative process for each text is the following: • First a vector of topic proportions is drawn from a Dirichlet distribution with parameter α∈Rk + , Dir ( α ); we recall that Dirichlet distribution is distributed over the simplex ∆k−1={v∈Rk:∀i, vi∈[0,1], and Xvi= 1}, and has the following density function, for h∈∆k−1: P(h) = Γ(α0)Qk i=1 hαi−1 i Qk i=1 Γ(αi). Where α0 = Pαi . From a practical point of view, this step consists of drawing a vector of parameters h∈ ∆ k−1 such that hi represents the proportion of the topic iin the document. • Once the topic proportions (also named mixture of topics) have been chosen, each word of the document is generated according to the following procedure: first a (hidden) topic of the word, say Y∈ { 1 , ..., k} , is drawn, according to the probabilities defined by h (so we will have probability hj of drawing topic j ) and then we will generate the word itself according to a multinomial distribution; for each i∈ { 1 , ..., d} , µj,i will be the probability of generating the word i under the topic j . Again, we will denote with µj = ( µj,1, ..., µj,d )the topics of the model, and we will store them as columns of a matrix M= [µ1|, ..., |µk]. 68 (left chart), while the running times of LDA are larger (right chart). From the coherence chart, we can see that k∈ { 2 , 3 , 4 } are all good numbers of topics for the moment-based approaches; so, we keep k = 3 and perform two additional analysis, focusing only on the models learned with SVTD and method of moments. First, we plot in Figure 3.3 the topic assignment for the various texts of the corpus, with the single-topic model (top figure) using Equation (3.4) for the assignment, and for LDA (bottom figure), using the approach described in Remark 3.3.2. The x− axis represents the chapter of the book: the first 34 are Hell, 35 to 67 are Purgatory, and the last 33 are Heaven, while the areas represent how much each chapter belongs to each of the topics. It is interesting to observe that, both with the LDA and single-topic models, each of the three topics is clearly dominant in one of the three areas of the corpus (Hell, Purgatory and Heaven): topic 1, is clearly dominant in Purgatory’s chapters, topic 2 in Hell, while topic 3 dominates Heaven. To see that this makes sense, we print in Table 3.1 the most relevant words for each topic, for the two models, where the relevance (Sievert and Shirley, 2014) is an indicator of how much a word characterizes a topic. Formally, the relevance of a word wwith respect to a topic µand is defined as r(w, µ) = λlog P(w|µ) + (1 −λ) log P(w|µ) P(w),(3.8) where P ( w|µ )(resp. P ( w )) is the probability of sampling w with topic µ (resp. in the overall corpus) and the weight parameter was set to λ = 0 . 7. Again, the topics are similar between the LDA and single-topic models, and are coherent with the topic assignment results. For example, the most relevant words for topic 3 are Cristo, luce, lume, meaning Christ and light. The similarity of the topics between the LDA and single-topic models is expected from the analysis of the coherence, where the LDA and single-topic models gave very similar scores. An interpretation of this is the fact that Divina Commedia is close to following a single-topic model, with each chapter dealing with a single topic. State of the Union Addresses Every year, the president of United States of America presents a speech to a joint session of the United States Congress, where he outlines his governative agenda, the national priorities and legislative projects. We considered the set of n = 65 state of the union addresses presented between 1945 and 2005, and we perform the same analysis performed for the Divina Commedia corpus. 75 (a) (b) Figure 3.2: Figure 3.2a contains the topic coherence of a single-topic model and an LDA learned with method of moments (resp. ST SVTD and LDA SVTD) and an LDA learned with MCMC (LDA MC), in function of the number of topics k ; Figure 3.2b contains an analysis of the running times. Both the figures refer to the Divina Commedia corpus. 76 Figure 3.3: The topic assignment for the single-topic model and LDA learned with method of moments for the Divina Commedia. 77 single-topic model (SVTD) Topic 1: disse, saprai, morta, torre, maestro (Transl.) said, will know, dead, tower, master Topic 2: vidi, serpente, greve, maestro, sovra (Transl.) I saw, snake, heavy, master, above Topic 3: luce, Cristo, creata, lume, vicine (Transl.) light, Christ, created, light, near LDA (SVTD) Topic 1: saprai, morta, torre, saggio, disse (Transl.) will know, dead, tower, wise, said Topic 2: vidi, cotai, greve, serpente, maestro (Transl.) I saw, so many, heavy, snake, master Topic 3: luce, creata, vicine, Cristo, lume (Transl.) light, created, near, Christ, light Table 3.1: The most relevant words for each topic for the Divina Commedia, learned by method of moments with SVTD setting k = 3, both for the single-topic model and for LDA. 78 Again, we keep the 70% most frequent words, obtaining a total vocabulary of k = 1184 words, and analyze topic coherence (Figure 3.4a) and running times (in Figure 3.4b) for method of moments with SVTD — using LDA ("LDA SVTD") and single-topic model ("ST SVTD") — and MCMC — only for LDA ("LDA MC"). Again, the performance of MCMC degrades as the model increases, while moment-based methods, both when learning LDA and single-topic models, keeps providing meaningful results, always using smaller running times. From now on we will only focus on the methods leaned with the moment-based approach. Overall, the single-topic model presents a better coherence and smaller running times than LDA. We set k = 18, which is also good for both the models and present in Figure 3.4c the topic assignment for the two models, where the areas represent how much each document deals with each topic. Also, Table 3.2 presents the most relevant words for each topic according to the LDA and single-topic models. The topics make sense and look similar across the two models. However, unlike the Divina Commedia case, they are not identical. For example, topic 8 for the single-topic model looks like a mixture of topic 7 and 8 in LDA. Looking at the topic assignments in Figure 3.4c, we can see that speeches from the same president share similar topic assignments: for example, topic 15 is dominant for G.W. Bush, and mainly deals with terrorism and Iraq. Cold-war presidents have a strong predominance of topics involving the Soviet Union, space missions and the Vietnam war. The two models are often coherent, with some notable exceptions, like president Kennedy: LDA assigns him to a mixture of topics that properly describe the challenges of cold war (LDA topics: 12, 13, 17, 18), while the single-topic model provides a simpler characterization with speeches assigned to topics 18 (again a cold war topic) and 14 (cold war, with a focus on Europe and foreign politics). 3.5 Conclusions In this chapter, we have presented an application of methods of moments to learn two well-known topic models: the single-topic model and the LDA, analyzing the theoretical properties of the proposed approach in Sections 3.2 and 3.3. Furthermore, we have applied the proposed approach in conjunction with SVTD – presented in Chapter 2 – to learn the topics of two real-world text corpora, comparing its performance with that of the standard MCMC- 79 (a) (b) (c) Figure 3.4: Figure 3.4a: the topic coherence of a single-topic model and an LDA learned with method of moments, and an LDA learned with MCMC, in function of the number of topics k ; Figure 3.4b: an analysis of the running times. Figure 3.4c: the topic assignment for the two models learned by SVTD setting k= 18. All the figures refer to the state of the union corpus. 80 single-topic model (SVTD) Topic 1: dollars, 1947, 1945, estimated, reconversion Topic 2: 21st, century, affordable, children, Medicare Topic 3: class, work, cold, people, worked, working Topic 4: years, people, energy, elected, congress, peace Topic 5: 21st, challenge, children, century, parents Topic 6: challenge, children, working, challenges, work Topic 7: produced, care, health, kids, people Topic 8: Vietnam, plan, recommend, deficit, numbers Topic 9: highway, Vietnam, recommend, program, federal Topic 10: Hussein, Saddam, intelligence, aids, weapons Topic 11: applause, program, government, federal, people Topic 12: benefits, democratic, economic, great, life Topic 13: federal, government, programs, Hussein, intelligence Topic 14: alliance, Atlantic, people, free, Europe Topic 15: applause, terrorists, Iraq, Iraqi, terror Topic 16: strikes, bargaining, collective, labor, management Topic 17: space, soviet, disarmament, military, defense Topic 18: disarmament, space, defense, soviets, military LDA (SVTD) Topic 1: dollars, 1947, 1945, estimated, reconversion Topic 2: 21st, college, affordable, children, child Topic 3: class, cold, worked, cuts, talk Topic 4: regulations, plan, government, reducing, inflation Topic 5: Vietnam, south, 21st, tonight, principle Topic 6: challenge, children, working, work, challenges Topic 7: Vietnam, south, tonight, north, conflict Topic 8: companies, plan, deficit, invest, care Topic 9: highway, maintenance, postal, planning, program Topic 10: Hussein, Saddam, seniors, aids, intelligence Topic 11: applause, Medicare, Hussein, seniors, Saddam Topic 12: controls, demands, labor, study, initiative Topic 13: percent, family, people, America, tonight Topic 14: produced, care, kids, health, renew Topic 15: applause, Iraq, terrorists, terrorist, seniors Topic 16: collective, strikes, bargaining, management, labor Topic 17: soviet, soviets, military, peace, disarmament Topic 18: space, disarmament, civil, defense, Latin Table 3.2: The most relevant words for each topic for the state of the union corpus, learned by SVTD setting k = 18, both for the single-topic model and for LDA. 81 based approach. In all the experiments, the proposed approach outperforms the MCMC-based one in terms of both coherence of the learned topics and running times. 82 Chapter 4 Methods of Moments for Clustering and an Application to Healthcare Analytics 4.1 Introduction Healthcare analytics is a natural field of application for machine learning. On a daily basis, hospitals and healthcare institutions produce millions of data points providing clinical information on the status of their patients. Machine learning can help in finding patterns in these data, helping doctors in making data-driven decisions. Latent variable models find a natural field of applications in this context. For example, imagine to assign to each patient a latent variable, indicating his true (unobservable) medical status, and that all the data that a hospital collects about the patient are random variables whose distribution depends on the latent condition of the patient. This strategy provides a generic modeling framework to use latent variable models to study and synthesize the statuses of patients visiting a hospital, enabling also to predict the future evolution of patient latent statuses, given their observable data. In this chapter we will use this modeling framework with the objective of clustering patients into groups with homogeneous clinical profiles. 83 4.1.1 Clustering Patients Clustering patients is a strategic activity for modern healthcare systems. First, similar patients share the need for similar cares, so the system can design specific guidelines to treat and prescribe diagnostic patterns rather than single diagnostics. Also, clear and tested clusters based on comorbidities help clinicians to decide treatments on specific patients. Third, characterizing patient patterns helps the system in planning resources and in performing fair comparisons between institutions. In this chapter we aim at providing a technique for clustering patients into homogeneous groups. We want this technique to rely on generic, widely available data – so to be easily usable in several different hospitals – to be able to run in nearly real time and to be simple to use – so that its implementations could be seamlessly used by doctors or hospital professionals. In general, these professionals have little or no training in data science; their organizations often have a statistics department, but asking the department for analysis usually takes weeks, which hinders intuition and innovation, and leads in most cases to abandoning the analysis because of more pressing day-to-day matters. Our goal is to propose an algorithm that would be largely autonomous, requiring no ad-hoc tuning before every analysis required by the user, and efficient so that intuitions can be explored almost in real time, even for large populations. Despite the increasing availability of Electronic Healthcare Records (EHR), this data is in general heterogeneous, differing in content and structure between various healthcare systems; this hinders the development of algorithms that can be re-used on several hospitals as well as the reproducibility of research in different contexts. At the same time, hospitals can benefit from the existence of standard, widely used procedures, as this reduces the development costs and provides trusted, out-of-the-box methods ready to be used on their EHR. A patient clustering method that aims to be used on several healthcare systems should thus be based on data available in most of the hospitals. The most universal EHR are probably patient ICD records, in their older and more recent versions, respectively ICD9 (Geraci et al., 1997) and ICD10 (World Health Organization, 2004). ICD-based EHR contain information about patients diagnostics registered by the hospital. A clustering algorithm able to leverage on such data will be general enough to be universally applied 84 as follows: ˆ M1= n X i=1 x(i) n,(4.6) ˆ M2= n X i=1 x(i)⊗x(i) n,(4.7) ˆ M3= n X i=1 x(i)⊗x(i)⊗x(i) n(4.8) It is trivial to see that the raw-moments are good estimators for M1 and for the off-diagonal entries of M2 and M3 , because we have that, for each triple of mutually distinct i, j and h, E[( ˆ M1)i] = (M1)i,(4.9) E[( ˆ M2)i,j]=(M2)i,j,(4.10) E[( ˆ M3)i,j,h] = (M3)i,j,h.(4.11) However, the relations above fail if at least two of i, j and h coincide; that means that the raw moments, do not suffice to estimate the off diagonal entries of M2 and M3 ; unfortunately, it is enough to spend some time playing with the estimates above to realize that no trivial variations of the raw moments allow to retrieve unbiased estimators for the diagonal entries of M2 and M3 . This challenging scenario led to the introduction of several indirect techniques to retrieve unbiased estimators of the moments at Equations (4.3) , (4.4) and (4.5) . Jain and Oh (2014) for example follow an optimization-based approach: first they estimate the raw moments, then they discard their diagonal entries, which are treated as missing entries. A tensor/matrix completion technique based on alternating least square is then used to fill these missing entries. This approach, however, only works when the number of features is significantly higher than the number of clusters k ; furthermore, it requires the storage of the full three dimensional tensor M3 in memory, reducing the scalability of the algorithm (depending on a factor d3 for both memory and time requirements, where d is the number of features). Another method has been proposed by Anandkumar et al. (2012b) – and subsequently refined (Anandkumar et al., 2014) – and it is based on the so-called multi-view 91 approach. Here, the features are first split into three views, Xa, Xb and Xc , like in the following example: X= (X1, . . . , Xda | {z } Xa , Xda+1, . . . , Xda+db | {z } Xb , Xda+db+1, . . . , Xda+db+dc | {z } Xc ). After that, a number of linear transformations are performed on the crossmoments between the views – including matrix inversions, compositions and singular value decompositions – to retrieve consistent estimators of the moments. This approach, which requires to have at least d≥3kfeatures, is known to be extremely unstable under random perturbations. Furthermore, the definition of the views – i.e. the decision of which features to put in each view – is a non-trivial task, that – when only limited data is available – meaningfully impacts the output parameters. These limitations make the multi-view approach to clustering hardly applicable in the medical setting, where the stability of a learned model represents a key requirement. 4.3.2 A New, Approximate Approach All the existing techniques for estimating mixtures of independent Bernoulli variables present some drawback, whether in terms of efficiency, or in terms of poor robustness to perturbations. In this section we will present a new approach that aims at overcoming the limitations listed above. Our approach relies on the observation that the raw moments provide unbiased estimators for the desired moments (4.3) , (4.4) and (4.5) for most of their entries – namely all the off-diagonal entries – and only the diagonal entries present a certain kind of bias. In the following theorem we show that this bias of the raw moments is small. Theorem 4.3.1. Let ˆ M1 , ˆ M2 and ˆ M3 be the raw moments defined at Equations (4.6) , (4.7) and (4.8) . Define the values of the conditional second and third order moments for an observable variable: µ(2) j,i =E[X2 i|Y=j], µ(3) j,i =E[X3 i|Y=j]. 92 If µj,i ∈[0,1] ∀i, j, we have for all i6=j: |(M2)i,i −(˜ M2)i,i| ≤ k X j=1 ωjµ(2) j,i −(M1)2 i, |(M3)i,i,l −(˜ M3)i,i,l| ≤ k X j=1 ωjµ(2) j,i µj,l −(M2)2 i,l (M1)l , |(M3)i,i,i −(˜ M3)i,i,i| ≤ k X j=1 ωjµ(3) j,i −(M1)3 i. Proof. First, recall that because each µj,i ∈[0,1], we have that µ(2) j,i ≥µ2 j,i, µ(3) j,i ≥µ3 j,i. We now prove each claimed equation one by one. 1. |(M2)i,i −(˜ M2)i,i| ≤ Pk j=1 ωjµ(2) j,i −(M1)2 i. The thesis is a consequence of the following chain of inequalities: (˜ M2)i,i =E[x2 i] = k X j=i ωjµ(2) j,i ≥ k X j=i ωjµ2 j,i = = (M2)i,i ≥( k X j=i ωjµj,i)2= (M1)2 i, where we have applied the Jensen inequality. 2. |(M3)i,i,l −(˜ M3)i,i,l| ≤ Pk j=1 ωjµ(2) j,i µj,l −(M2)2 i,l (M1)l. We have (˜ M3)i,i,l = k X j=1 ωjµ(2) j,i µj,l ≥ k X j=1 ωjµ2 j,iµj,l = = (M3)i,i,l ≥(M2)2 i,l (M1)l , from which again we get the desired inequality. 3. |(M3)i,i,i −(˜ M3)i,i,i| ≤ Pk j=1 ωiµ(3) j,i −(M1)3 i. The proof of this point is identical to that of point 2. 93 The theorem above says that if we are learning a mixture of independent Bernoulli variables, the expected value of the bias of the raw moments is small. Starting from this observation, we propose the following approximate approach: 1. First, use the raw moments as input to SVTD, to retrieve a pair ( ˆ M, ˆω ) of model parameters – which, will be biased as a consequence of the bias in the input moments. 2. Then, we plug these estimated parameters as initializers for EM, with the objective of improving them, obtaining a model that locally maximizes the likelihood. This approach is an heuristic, but presents several advantages over existing techniques: first, it allows an efficient and optimized implementation of SVTD – that we will call Approximate Singular Value-based Tensor Decomposition (ASVTD): this implementation, instead of taking as input the moments, takes as input a dataset, and embeds the calculations of the moments with the inner steps of SVTD, obtaining, as we will see in Section 4.3.2, improved computational performance. The second advantage will be that, despite the lack of theoretical guarantees, this approach will lead to high-quality model parameters, with EM converging fast to surprisingly good local optima, as we will experimentally see in Section 4.5. Algorithmic Details: Implementing ASVTD Our approach consists of using the raw moments as input to SVTD, obtaining a pair of approximate estimates ( ˆ M, ˆω )that are then updated with EM, until when convergence is reached. The usage of the raw moments allows to modify the structure of SVTD in order to reduce its complexity, by embedding the moment calculation in the inner steps of SVTD (we refer the reader to Chapter 2 and Algorithm 1 for details on SVTD). This improved implementation will lead exactly the same results as SVTD inputted with the raw moments, but with an improved efficiency. Pure SVTD works with all the explicit slices of the d×d×d tensor M3 , which may be computationally demanding, especially when the number of features 94 is high. Using the raw moments, enable us to avoid the explicit usage of the slices of M3 , working with matrices with a lower dimension, improving the complexity of the algorithm. Given a dataset X={x(1), ..., x(n)} we define ¯x∈Rn×d the matrix whose i th row is the vector x(i) . This matrix, together with the number of latent states kwill be the input of ASVTD. Algorithm 2 Approximate - SVTD Require: The sample ¯x∈Rn×d, the number of latent states k≤d 1: Compute ˆ M2=¯x>¯x n∈Rd×d 2: Decompose ˆ M2as ˆ M2=UkSkU> kwith a SVD. 3: Define the whitening matrix E = UkS1/2 k and calculate its pseudoinverse E†= (Sk)−1/2U> k. 4: Project ¯xon Rn×k:¯z= ¯x(E†)> 5: Initialize αmin =−∞ and O=Ikas the k×kidentity matrix. 6: for i= 1 →ddo 7: Compute Hi:= ¯z>diag((x(1) i,...,x(n) i))¯z N 8: Compute the singular values of Hi ,( s1, ..., sk )and the left singular vectors Oi. 9: if mini6=j(|si−sj|)> αmin then 10: Set: αmin = mini6=j(|si−sj|), and O=Oi 11: end if 12: end for 13: for i= 1 →ddo 14: Obtain the ith row of ˆ Mas the diagonal entries of O>HiO 15: end for 16: Obtain ˆωsolving (Pix(i) j/n)j=1..d = ( ˆ Mˆω)j=1..d 17: Return (ˆ M, ˆω) Comparing SVTD (Algorithm 1) and its approximate implementation (Algorithm 2), we notice that the main differences are in the loop from row 6 to 12 of Algorithm 2. In fact, standard SVTD computes the matrices Hi , whitening the ith slice of M3: Hi=E†M3,i(E†)>; 95 this operation is pretty expensive, as it requires O ( d2k )operations, and is repeated d times, for a total cost of O ( d3k ). Instead, in ASVTD, we never compute explicitly ˜ M3 , but we compute directly Hi , exploiting the fact that, in this case Hi=E†¯x>diag((x(1) i, ..., x(n) i))¯x(E†)> n. So, at row 4, we whiten the matrix of the observed samples, and we use it during all the algorithm; the calculation of each Hi now costs only O ( k2n ), which in many cases is a substantial improvement (especially when the number of the features is high). Notice that there is a second difference between the implementation of ASVTD and that of SVTD, that is the fact that ASVTD has explicitly implemented the feature selection process described at remark 2.1.2. In fact, SVTD requires, at step 3, to isolate a feature, for which to calculate the matrix O that will be used to diagonalize the various matrices Hr , and retrieve consequently the rows of the matrix M . This procedure is explicitly implemented in ASVTD in the loop from row 6 to 12, where the feature that maximizes the difference between the two nearest singular values is selected. We now analyze the complexity requirements of ASVTD. It is easy to see that the steps from 1 to 4 have a time complexity of O ( d2n )for step 1, O ( d2k ) for step 2, using randomized techniques (Halko et al., 2011) and O ( ndk )for step 4. In the loop from step 6 to 12 we have the calculation of Hi , costing O ( k2n ), and a k×k SVD, costing O ( k3 ), giving a total time complexity of O ( d2n + dk2n + dk3 )in the realistic cases where d, k < n . Also the memory requirements are mild, as the only storage is for the matrices Hi , costing O ( dk2 ), ˆ M2 , costing O ( d2 )and ¯x , for O ( dn ). The total memory is thus O(dk2+d2+dn). 4.4 Putting it All Together We are now ready to merge all the elements presented till now, and to show how to use the presented learning technique to cluster a dataset of independent binary vectors. Starting from a dataset X , our proposed approach consists of the following flow: First, estimate the raw moments ˆ M1 , ˆ M2 , ˆ M3 , as in Equations (4.6) , (4.7) and (4.8) and retrieve the model parameters ( ˆ M, ˆω ) 96 with SVTD (or, directly use ASVTD for an optimized implementation). Then, apply EM to improve the quality of the estimated parameters. Last, use the clustering formula described at Equation (4.2) to group the observed samples into kclusters. Remark 4.4.1 (Tuning the clustering results) . The runs of EM performed after the parameter retrieval guarantee that the retrieved mixture model is (locally) optimal in terms of likelihood. Additional fine-tuning is possible re-running the algorithms in different configurations, for example modifying the number of clusters, adding/excluding certain features, or performing additional clustering within one of the clusters. The interpretation technique provided in the Section 4.6 allows a user to visually inspect results and add expert considerations on the discovered patterns. Other types of manual fine-tuning (like manually assign a patient to a different cluster) may be possible, at the cost of adding human bias to the results of the model. 4.5 Experiments In the previous section we have described an approach to cluster a dataset of high-dimensional binary vectors into k groups. In this section we want to experimentally compare the clustering accuracy of the proposed method with that of state-of-the-art methods. We proceed as follows: First we generate a synthetic dataset, distributed as a mixture of independent Bernoulli, registering for each sample, the cluster to which it belongs (i.e. the latent variable generating the observation); the synthetic parameters ( M, ω )have been generated as exponentially distributed random numbers, normalized to be between 0 and 1. Then, we cluster the samples in an unsupervised way, and we compare the obtained clusters with the theoretical ground-truth, registered when generating the data. We then repeat this procedure for various model and sample sizes. In order to analyze the clustering accuracy, we use the Adjusted Rand Index from Hubert and Arabie (1985) between the theoretical ground-truth partition and the one obtained with the clustering algorithm. We recall that the adjusted rand index is an indicator that compares whether two partitionings of a dataset are or not similar; an adjusted rand index of 1 indicates that two clusterings are identical, while a random labeling should have a value close to 0. Our comparison will be performed between several different algorithms: 97 1. The approach described in this chapter: in particular, we will use Algorithm 2 to recover a set of approximate parameters that will be then refined with EM; last, Equation (4.2) will be used to perform clustering. EM will be run until convergence, stopping the algorithm when the norm of the variation on the estimated ω between an iteration and the next will be less than 0.01. 2. With formula (4.2) , where the parameters are retrieved using the threeviews method of moments from Anandkumar et al. (2012b) (3V-MoM in the charts). Here, we obtained the views by randomly splitting the features into three groups. For this case, we test both, the scenario where EM is used after the parameter retrieval (to get improved parameters) and scenario where not. 3. As above, with formula (4.2) , where the parameters are retrieved with the three-views method of moments, but using the variation from Anandkumar et al. (2014) (3V-TPM in the charts) and obtaining the views following the procedure of the previous point. Also for this case, we test both, the scenario where EM is used after the parameter retrieval and scenario where not. 4. K-Means. 5. Spectral Clustering from von Luxburg (2007), using a linear kernel ( ”SC-lin” in the figures). 6. PCA clustering, where k-means is used to cluster the sample where the dimensionality has been reduced using a PCA. The results are displayed in figure 4.1. The top three figures represent the experiment where EM is not run after the multi-view clusterings from Anandkumar et al. (2012b, 2014), while the three figures below represent the experiment where EM is used. In the leftmost figures we fixed the number of features d = 99 and the number of latent states k = 12, varying the sample size from n = 100 to n = 10000. In the central figures, the sample size n = 10000 and the number of features d = 99 are fixed, while the number of latent states varies from k = 2 to k = 33. In the rightmost figure, the sample size n = 10000 and the number of latent states k = 4 are fixed, while the number of features varies from d = 12 to d = 99. It is interesting to notice that all the reference methods (K-means, Spectral Clustering and 98 Figure 4.1: Adjusted Rand Index of the compared methods, when EM is not used after the multi-view methods (top three figures) and when is used (bottom three figures). 99 PCA) are outperformed by methods of moments; also, it seems that the intuition of using a mixed method of moments + EM approach provides good results, as ASVTD + EM, despite the lack of theoretical guarantees, performs better than the pure (i.e. without EM) multi-view methods of moments from Anandkumar et al. (2012b, 2014). If we plug some EM iterations after the multi-view approaches (three figures below), we can see an improvement in their learning performance, behaving similarly to ASVTD + EM. However, while ASVTD does not need any preprocessing of the data, multi-view methods of moments do require to split the features into conditionally independent views, a task that may require several trial and errors when dealing with unbalanced real-world datasets. (a) Method Time ASVTD + EM 1.3 sec. 3V-TPM + EM 3.68 sec. 3V-MoM + EM 0.77 sec. KMeans 0.76 sec. SC - lin 7.48 sec. PCA 0.38 sec. (b) Figure 4.2: The average clustering time spent for each method. We now briefly discuss the running times. For each run of the experiment described in the previous paragraph we registered the time employed by each of the clustering methods. We then average all these records, in order to get, for each method, the average time needed to perform the clustering. Results are displayed in Table 4.2b. It is immediate to see that Spectral Clustering method is much slower than the competing techniques. This is a consequence of dealing with an n×n affinity matrix, that requires a number of operations quadratic in the sample size. PCA and K-means are pretty fast, but we have seen that they perform poorly on binary data. Looking at methods of moments, 3V-TPM + EM seems to be the slowest method, consequence of a worst scalability on the 100 Cluster Most Relevant Diagnostics Cluster Size 1 Essential hypertension; Dyslipidemia; Cardiac arrhythmias; Diabetes mellitus; Obesity; 7290 2 Diabetes mellitus; Atherosclerosis; Acute pulmonary heart disease; Retinal disorders; Hypertensive heart and renal disease; 2915 3 Chronic pulmonary heart disease; Diseases of endocardial structures; Diseases of endocardium; Hypertensive heart disease; Cardiac arrhythmias; 4480 4 Bacterial infection; Disorders of urethra - urinary tractk; Acute renal failure; Hypertensive heart - renal disease; Disorders of fluid, electrolyte, acid-base balance; Diseases of lung; 2936 5 Hypertensive renal disease; Chronic and/or acute renal failure; Diabetes mellitus; Anemia; 5533 Table 4.1: The most relevant diseases for each cluster for the Heart failure dataset. correspond to patients in need of coronary intervention (heart surgery or interventional cardiology), again with strong presence of metabolic anomalies. Cluster 2 is similar, but including myocardial infarction. Cluster 3 includes nephrology patients, who are also taken to tertiary hospitals when they need transplant or are in very advanced phase, and who tend to develop arteriopathy in the long term; interestingly, diabetes mellitus shows up strongly in this cluster, as it is the leading cause of entrance to dialysis programs. Cluster 4 has a surprising behavior: on a first hand, no clear signal comes out from the disease-frequency chart, besides the ever-present hypertension, dyslipidemia and a small signal of colo-rectum cancer. However, if we look at the table of high relevant diseases, we can see that the most relevant diagnostics for this cluster are neoplasms. Oncological problems are large constituents of tertiarism; they are characterized by a large set of codes (almost 100 for neoplasms, by organ of origin mostly), reason why it is not surprising the fact that we do not find them in the disease-frequency plot, as there are many distinct diagnostics indicating oncological diseases; however, the fact that the most relevant diagnostics for this cluster are neoplasms allows us to 107 Cluster Most Relevant Diagnostics Cluster Size 1 Ischemic heart disease; Essential hypertension; Angina pectoris; Dyslipidemia; Chronic ischemic heart disease; 4892 2 Acute myocardial infarction; Chronic ischemic heart disease; Nondependent abuse of drugs; Essential hypertension; Dyslipidemia; 3982 3 Hypertensive renal disease; Chronic renal failure; Chronic ischemic heart disease; Diabetes mellitus; Acute myocardial infarction; 1043 4 Malignant neopl. of rectum, rectosigmoid junction, and anus; Secondary malignant neopl. of respiratory and digestive systems; Malignant neopl. of trachea, bronchus, and lung; Malignant neopl. of stomach; Diseases of white blood cells; 3133 5 Chronic renal failure; Hypertensive renal disease; Disorders involving the immune mechanism; Anemia; Disorders of urethra and urinary tractk; 819 6 Diseases of endocardial structures; Chronic pulmonary heart disease; Heart failure; Diseases of endocardium; Diseases of lung; 2442 Table 4.2: The most representative diseases for each cluster for the Tertiarism dataset. 108 consider this family of diagnostics as characterizing this cluster. Cluster 5 groups kidney patients without arteriopathy, so similar to the first and second clusters but without previous infarction. Cluster 6 includes patients with cardiac valvular disease; normally they need heart surgery or interventional cardiology, but their associated complications are quite different from those in Clusters 1 and 2. MIMIC dataset Cluster Most Relevant Diagnostics Cluster Size 1 Coronary atherosclerosis; Essential hypertension; Dyslipidemia; Mitral valve disorders; Acute myocardial infarction; 16120 2 Chronic kidney disease; Hypertensive renal disease; Congestive heart failure; Encounter for radiotherapy; Diabetes mellitus; 9504 3 Septicemia; Alcoholic fatty liver; Abscess of liver; Other anaphylactic reaction; Hyperosmolality and/or hypernatremia; 12559 4 Motor vehicle traffic accident; Accidental fall; Closed fracture; Closed fracture of cervical vertebra;6 Open wound; 10065 5 Single liveborn; Need for prophylactic vaccination; Observation for suspected infectious condition; Extreme immaturity; Perinatal jaundice; 8112 Table 4.3: The most representative diseases for each cluster for the MIMIC dataset. The clusters obtained with the MIMIC dataset are plotted in Figures 4.5a and 4.5b, while Table 4.3 contains the most relevant diseases for the each cluster. Again, the clusters are neat, and clearly characterized under the clinical point of view. Cluster 1 is characterized by patients suffering of Dyslipidemia and hearth-related issues, Cluster 2 is characterized by kidney-related problems, while Cluster 3 seems to contain infections and liver-related issues. Cluster 4 contains patients who suffered traumatic events (like accidents and fractures) while Cluster 5 is essentially characterized by new-born patients. 109 (a) (b) Figure 4.5: 4.5b Disease-frequency chart for the MIMIC dataset. 4.5a The corresponding heatmap. 110 4.7 Conclusions We have presented an efficient method for clustering high dimensional binary data, based on applying methods of moments to learn mixtures of independent Bernoulli variables. Under the clinical perspective, our method is able to find interesting and potentially useful patterns even in the simplest format of EHR, namely, diagnostic codes only. A strong point noted by clinicians on this clustering approach is that it provides a fresh look, without prejudice, based on an aseptic algorithm. A natural follow-up consists in including additional medical information to the features, like demographics, lab results, vital signs or medications. Also, we believe that including higherlevel diagnostic groups among the features may improve the clarity of some patterns; these are more clearly defined in the more recent coding scheme ICD10 than in ICD9. 111 112 Part II Hierarchical Methods of Moments 114 Chapter 5 A Method of Moments Robust to Model Misspecification 5.1 Introduction In the previous chapters, we have presented several results showing how methods of moments can be used to learn from data latent variable models. In Chapters 3 and 4 we have presented practical applications of these methods, showing that they represent a promising framework, that can be successfully applied on complex, noisy real-world data, with performance that is often superior to those of existing, classic techniques. Without doubt, efficiency is one of the competitive advantages of methods of moments: requiring a single pass through the data – to calculate the moments – and working with small, low-dimensional tensors – thanks to the whitening step – they allow to deal with high dimensional massive datasets, returning appealing results in relatively short time. At the same time, if the structure of the model generating the data is known, methods of moments often have the guarantee to recover a model that, asymptotically with the sample size, converges to the one generating the data. Consider for example a corpus of texts generated by a single topic model, then methods of moments – using the procedure described at Chapter 3 – enable us to learn a model that asymptotically approaches the one generating the texts we are observing. These guarantees have an intrinsic theoretical interest – opening a new learning perspective on several models, for which 115 previously no accurate learning techniques were known – but it is important to understand how they translate to the reality, and if they ensure that a good model will be returned by a method of moments, even with real world data. Real-world data in fact, may be generated by no finitely specified model, with an unknown structure, and will likely present outliers; in few words, real world data will always present model misspecifications. Any learning technique for latent variable models that aims at being competitive on real-world data, should be able to return the optimal model describing the data, according to some definition of optimality. This for example is what happens with the likelihood-based techniques, that aim at returning the model that (locally) maximizes the likelihood of the observed data. How do methods of moments behave in this setting? Do the guarantees that hold in theory, where the structure of the model generating the data is known, hold also when model misspecifications are present? This kind of misspecification can happen for example when the number of latent states plugged into a learning algorithm is not enough to accurately describe the data we are observing. For example, we are given a corpus of texts dealing with k topics and we run a leaning algorithm to learn l < k topics. In this setting, we expect to retrieve a model with l topics that optimally describes the data (according to some definition of optimality). Surprisingly, currently no theory describes the behavior of methods of moments in this setting, and consequently no guarantees of any kind are provided. In contrast, the model obtained by likelihood-based methods like EM is in this case reasonable and desirable: when asked for a small number of latent variables EM yields a model which is easy to interpret and can be useful for data visualization and exploration. An important application of low-dimensional learning can be found in mixture models, where latent class assignments provided by a simple model can be used to split the training data into disjoint datasets to which EM is applied recursively to produce a hierarchical clustering (Steinbach et al., 2000; Savaresi and Boley, 2001). The tree produced by such clusterings procedure provides a useful aid in data exploration and visualization. In this chapter, we analyze the behavior of methods of moments when the number of requested latent states is not enough to accurately describe the data; we will show that most of the existing decomposition methods have no guarantees to return in this setting a meaningful model (Section 5.2). We 116 5.3.2 The Misspecified Setting Algorithm 3 requires as inputs the low order moments M1 , M2 , M3 along with the desired number of latent states l to recover. If l = k , it will return the exact model parameters ( M, ω ); we will now see that it will also provide meaningful results when l < k . In this setting, Algorithm 3 returns a pair ( ˆ M, ˆω ) ∈Rd×l×Rl such that the matrix D = ( ˆ Mˆ Ω1/2 ) † is optimal for the optimization problem min D∈DlX i6=j d X r=1 (DM3,rD>)2 i,j!1/2 .(5.9) Analyzing the space of feasible solutions (Theorem 5.3.1) and the optimization function (Theorem 5.3.2), we will obtain theoretical guarantees on what SIDIWO returns when l < k , showing that the trivial solutions are not feasible, and that, in the space of feasible solutions, SIDIWO’s optima will approximate the true model parameters according to an intuitive geometric interpretation. The role of the constraints (II) The first step consists in analyzing the space of feasible solutions Dl when l < k . The observations outlined in Remark 5.3.1 still hold in this setting: the zero solution and the matrices laying in the orthonormal complement of M are not feasible. Furthermore, the following theorem shows that other undesirable solutions will be avoided. Theorem 5.3.1. Let D∈ Dl with rows d1, ..., dl , and let Ir,s denote the r×s identity matrix. The following facts hold under the hypotheses of Lemma 5.3.1: 1. For any row di , there exists at least one column of M such that hdi, µji 6 = 0. 2. The columns of any ˆ M satisfying ˆ Mˆ Ω1/2 = D† are a linear combination of those of M , laying in the best-fit l -dimensional subspace of the space spanned by the columns of M. 3. Let π be any permutation of { 1 , ..., d} , and let Mπ and Ω π be obtained by permuting the columns of M and Ωaccording to π . If hµi, µji 6 = 0 for any i, j, then ((MπΩ1/2 π)Ik,l)†/∈ Dl, and similarly Il,k(MπΩ1/2 π)†/∈ Dl. 123 Proof. Let us recall the notation we are going to use. Consider the matrix M2and its SVD: M2=USU>. For any l≤k , define El = UlS1/2 l∈Rd×l , where Ul and Sl are U and S truncated at the l th singular vector (recall: U∈Rd×k and S∈Rk×k ). We know that there exists an orthonormal matrix Osuch that MΩ1/2=EO. Let us prove the various points of the theorem. 1. Consider any matrix D∈ Dl . Then we will have, for an orthonormal Ol, D= (ElOl)†=O> lS−1/2 lU> l. To prove the statement, it is enough to show that the matrix C = DMΩ1/2has rank l. To see this, explicitly represent C: C=DMΩ1/2=O> lS−1/2 lU> lEO =O> lS−1/2 lU> lUS1/2O=O> lIl,kO the fact that Oand Olare orthogonal proves the claim. 2. Consider again any matrix D∈ Dl, then D†=ˆ Mˆ Ω1/2= (ElOl) = UlS1/2 lOl. The columns of Ul are the left singular vectors of M Ω 1/2 , that span the best fit l -dimensional subspace of the space generated by the columns of M. 3. To prove this we will proceed by contradiction. Assume that ( M Ω 1/2Ik,l ) †∈ Dl; this means that there exists an orthonormal matrix Olsuch that MΩ1/2Ik,l =ElOl=EIk,lOl. But MΩ1/2=EO, so EOIk,l =EIk,lOl. This would imply that Il,kOIk,l =Ol 124 and so, for some P∈Rk−l×k−l O=Ol0 0P. Observe now that the matrix Z = Ω 1/2M>M Ω 1/2 has all the entries that are different from zero, by the hypothesis that hµi, µji 6 = 0 for any i, j. However, we have that Z= Ω1/2M>MΩ1/2=O>SO =O> l0 0P>Sl0 0Sl,k Ol0 0P =O> lSlOl0 0P>Sl,kP where Sl,k is the diagonal matrix with the last k−l singular values. So Zhas some zero entry. This contradiction proves the claim. The proof of the fact that Il,k(MπΩ1/2 π)†/∈ Dlis identical. The second point of Theorem 5.3.1 states that the feasible solutions will lay in the best l -dimensional subspace approximating the one spanned by the columns of M . This has two interesting consequences: if the columns of M are not orthogonal, point 3 guarantees that ˆ M cannot simply be a sub-block of the original M , but rather a non-trivial linear combination of its columns laying in the best l-dimensional subspace approximating its column space. Consider for example a single-topic model from Chapter 3 with k topics; in this case, when asked to recover l < k topics, Algorithm 3 will not return a subset of the original k topics, but a matrix ˆ M whose columns gather the original topics via a non trivial linear combination: the original topics will all be represented in the columns of ˆ Mwith different weights. When the columns of M are orthogonal, this space coincides with the space of the l columns of M associated with the l largest ωi ; in this setting, the matrix ( Mπ Ω 1/2 π ) Ik,l (for some permutation π ) is a feasible solution and minimizes Problem (5.9). Thus, Algorithm 3 will recover the top ltopics. 125 Interpreting the optima. Let ˆ M be such that D = ( ˆ Mˆ Ω1/2 ) †∈ Dl is a minimizer of Problem (5.9) . In order to better understand the relation between ˆ M and the original matrix M , we will show that the cost function of Problem (5.9) can be written in an equivalent form, that unveils a geometric interpretation. Theorem 5.3.2. Let d1, ..., dl denote the rows of D∈ Dl and introduce the following optimization problem min D∈DlX i6=j sup v∈VM k X h=1hdi, µhihdj, µhiωhvh(5.10) where VM = {v∈Rk : v = α>M, where kαk2≤ 1 } . Then this problem is equivalent to (5.9). Proof. Recall the considered problem: min D∈DlX i6=j sup v∈VM k X h=1hdi, µhihdj, µhiωhvh(5.11) where VM={v∈Rk:v=α>M, where kαk2≤1} Consider any v∈ VM , then it admits the following representation, for some αwith kαk2≤1: v= [hα, µ1i, ..., hα, µki]>. 126 This allows the following chain of equalities on the cost function: X i6=j sup v∈VM k X h=1hdi, µhihdj, µhiωhvh=X i6=j sup α:kαk2≤1 k X h=1hα, µhihdi, µhihdj, µhiωh =X i6=j sup α:kαk2≤1 d X r=1 αr k X h=1 µh,rhdi, µhihdj, µhiωh =X i6=j sup α:kαk2≤1 d X r=1 αr(DM3,rD>)i,j =X i6=j sup α:kαk2≤1hα, ti,ji =X i6=jkti,jk2 Where the vector ti,j is defined as ti,j = ((DM3,1D>)i,j, ..., (DM3,dD>)i,j) and the last equality has been obtained from the fact that, for any vector w∈Rk, we have kwk= sup α:kαk2≤1hα, wi This last equation proves our statement; in fact, X i6=jkti,jk2=X i6=j ( d X r=1 (DM3,rD>)2 i,j)1/2. We now provide an interpretation of this theorem. First, observe that the cost function in Equation (5.10) prefers matrices D such that the vectors ui = [ hdi, µ1√ω1i, ..., hdi, µk√ωki ], i∈ [ l ], have disjoint support. This is a consequence of the supv∈VM , and requires that, for each j , the entries hdi, µj√ωji are close to zero for at least all but one of the various di . Consequently, each center will be almost orthogonal to all but one row of the optimal D ; however the number of centers is greater than the number of rows of D , so the same row dimay be nonorthogonal to various centers. 127 For illustration, consider again the single-topic model: a solution D to Problem (5.10) would have rows that should be as orthogonal as possible to some topics and as aligned as possible to the others; in other words, for a given topic j , the optimization problem is trying to set hdi, µj√ωji = 0 for all but one of the various di . Consequently, each column of the output ˆ M of Algorithm 3 should be in essence aligned with some of the topics and orthogonal to the others. It is worth mentioning that the constraint set Dl forbids the trivial solutions such as the zero matrix, the pseudo-inverse of any subset of l columns of M Ω 1/2 , and any subset of l rows of ( M Ω 1/2 ) † (which all have an objective value of 0). We remark that Theorem 5.3.2 does not require the matrix M to be full rank k : we only need it to have at least rank greater or equal to l , in order to guarantee that the constraint set Dlis well defined. 5.3.3 An optimal solution when l= 2. While Problem (5.7) can be solved in general using an extension of the Jacobi technique (Cardoso and Souloumiac, 1996; Bunse-Gerstner et al., 1993), we provide a simple and efficient method for the case l = 2. This method will then be used to perform hierarchical topic modeling in Section 5.4. When l = 2, Equation (5.9) can be solved optimally with few simple steps; in fact, the following theorem shows that solving (5.9) is equivalent to minimizing a continuous function on the compact one-dimensional set I = [ − 1 , 1], which can easily be done by griding I . Using this in Step 3 of Algorithm 3, one can efficiently compute an arbitrarily good approximation of the optimal matrix D∈ D2. Theorem 5.3.3. Consider the continuous function F ( x ) = c1x4 + c2x3√1−x2 + c3x√1−x2 + c4x2 + c5 , where the coefficients c1, ..., c5 are functions of the entries of M2 and M3 . Let a be the minimizer of F on [ − 1 , 1], and consider the matrix Oa=√1−a2a −a√1−a2. Then, the matrix D= (E2Oa)†is a minimizer of Problem (5.9) when l= 2. 128 Proof. First, observe that the set of 2 × 2orthonormal matrices can be parametrized as Oa=√1−a2a −a√1−a2,for a∈[−1,1].(5.12) The set D2can thus be rewritten in function of a, as D2={D:D= (E2Oa)†for a∈[−1,1]}. and Problem (5.7) can be rewritten as min a∈[−1,1] d X r=1 2(O> aH2,rOa)2 1,2 where H2,r =E† 2M3,rE†> 2, for r ={1, ..., d}(5.13) and where we used the fact that O> aH2,rOa is symmetric. We can then write (O> aH2,rOa)2 1,2=c(r) 1a4+c(r) 2a3√1−a2+c(r) 3a√1−a2+c(r) 4a2+c(r) 5 where the coefficients can be written as c(r) 1= 4h2−f2, c(r) 2=−4fh, c(r) 3= 2fh, c(r) 4=f2−4h2, c(r) 5=h2 with h = ( H2,r ) 1,2 and f = ( H2,r ) 1,1− ( H2,r ) 2,2 . Letting cj = Pd r=1 c(r) j for j∈ { 1 , ..., 5 } it follows that optimizing Problem (5.7) is equivalent to minimizing the following smooth real function F(a) = c1a4+c2a3√1−a2+c3a√1−a2+c4a2+c5. 5.4 Case Study: Hierarchical Topic Modeling In this section, we show how SIDIWO can be used to efficiently recover hierarchical representations of latent variable models. Given a latent variable model with k states, our method allows to recover a pair ( ˆ M, ˆω )from estimate of the moments M1 , M2 and M3 , where the l columns of ˆ M offer a synthetic 129 representation of the k original centers. We will refer to these l vectors as pseudo-centers: each pseudo-center is representative of a group of the original centers. Consider the case l = 2. A dataset X of n samples can be split into two smaller subsets according to their similarity to the two pseudo-centers. Formally, this assignment is done using Maximum A Posteriori (MAP) to find the pseudo-center giving maximum conditional likelihood to each sample – as described in Remark 3.3.2 for the example of the single-topic model. The splitting procedure can be iterated recursively to obtain a divisive binary tree, leading to a hierarchical clustering algorithm. While this hierarchical clustering method can be applied to any latent variable model that can be learned with the tensor method of moments (e.g. Latent Dirichlet Allocation), we present it here for the single-topic model for the sake of simplicity. We consider a corpus X of n texts encoded as in Section 3.2 and we split X into two smaller corpora according to their similarity to the two pseudocenters in two steps and use MAP assignment to assign each text x to a pseudo-center. This process is summarized in Algorithm 4. Once the corpus Algorithm 4 Splitting a corpus into two parts Require: A corpus of texts X={x(1), ..., x(n)}. 1: Estimate ˜ M1,˜ M2and ˜ M3. 2: Recover l= 2 pseudo-centers with Algorithm 3 . 3: for i∈[n]do 4: Assign the text x(i) to the cluster Cluster ( i ) = argmaxjP ( X = x(i)|Y = j, ˆω, ˆ M ), where P ( X|Y = j, ˆω, ˆ M )is the multinomial distr. associated to the j-th pseudo-center (Equation (3.4)). 5: end for 6: return The cluster assignments Cluster. X has been split into two subsets X1 and X2 , each of these subsets may still contain the full set of topics but the topic distribution will differ in the two: topics similar to the first pseudo-center will be predominant in the first subset, the others in the second. By recursively iterating this process, we obtain a binary tree where topic distributions in the nodes with higher depth are expected to be more concentrated on fewer topics. In the next sections, we assess the validity of this approach on both synthetic 130 Adj. Rand Idx Method Mean St. dev. Run. Time ALS 0.70 0.17 1.9 sec. TPM 0.93 0.06 1.2 sec. SVD 0.52 0.13 0.1 sec. Rand. Proj. 0.72 0.06 16 min. SVTD 0.85 0.1 0.2 sec SIDIWO 0.98 0.01 0.4 sec. Table 5.1: Table 5.1 reports the average and standard deviation over 10 runs of the clustering accuracy for the various methods, along with average running times. and real-world data. Experimental setting: The experiments in this section have been performed in Python 2.7, using numpy (Walt et al., 2011) library for linear algebra operations, with the exception of the implementation of the method from Kuleshov et al. (2015), for which we used the author’s Matlab implementation: 2 . All the experiments were run on a MacBook Pro with an Intel Core i5 processor. The implementation of the described algorithms have been publicly disclosed.3 5.4.1 Experiment on Synthetic Data In order to test the ability of SIDIWO to recover latent structures in data, we generate a dataset distributed as a single topic model (with a vocabulary of 100 words) whose 8topics have an intrinsic hierarchical structure depicted in Figure 5.1a. In this figure, topics are on the x -axis, words on the y -axis, and green (resp. red) points represents high (resp low) probability. We see for example that the first 4 topics are concentrated over the 1st half of the vocabulary, and that topics 1 and 2 have high probability on the 2https://github.com/kuleshov/tensor-factorization 3https://github.com/mruffini/Hierarchical-Methods-of-Moments. 131 (a) (b) Figure 5.1: Figure 5.1a provides a visualization of the topics used to generate the sample. Figure 5.1b represents the hierarchy recovered with the proposed method. 132 latent variable models with a very simple structure, which imposes hypotheses on the data that are systematically violated. The paragraphs above explain why the guarantees that are typically provided by methods of moments tend to lose part of their value when it comes to ensuring that a meaningful model is learned, especially when dealing with real-world data. At the same time, guarantees ensuring that the output of a method of moments meaningfully describes the data, may be provided by introducing a data-oriented interpretation of these methods, linking geometrically the output of a method with the data that are provided as input. Having a clear intuition on what the output of a method will be with respect to the data, is in fact a key step to ensure that this output makes sense even in the challenging setting where few data is available or model misspecifications are present. In this chapter we present a variation of methods of moments that aims at overcoming the limitations listed above, while maintaining the efficiency properties typical of moment-based algorithms. Our approach leverages on transforming methods of moments from model-learning algorithms - i.e. methods to learn a specific latent variable model from data - to task-specific algorithms - i.e. methods aimed at directly performing a specific task - focusing in this chapter on one task: hierarchical clustering. To do this, in Section 6.2 we rewrite the method of moments as an optimization problem – leveraging on the cost function introduced by SIDIWO in Chapter 5 – and we show that if the moments are calculated in a simple, standardized way independent of the specific latent variable model, an intuitive relation between the optima and the input data can be found. Furthermore, this relation automatically suggests a clustering rule to split data into clusters, which, as we will see later, is particularly suitable for high-dimensional binary data (Section 6.3). This relation is geometric, and can be used to split the data into clusters only leveraging on geometric considerations, introducing in this way a model-free, geometry-based bisecting algorithm, that will be used as a building block of a divisive hierarchical clustering algorithm, that we will call Data-centric Simultaneous Diagonalization based on Whitening and Optimization (D-SIDIWO). This geometry-based approach substantially differs from the one traditionally followed by methods of moments and model-based clustering. A traditional approach would have first learned a model with a method of moments and 139 then used that model to assign the samples to the cluster corresponding to the latent state that maximizes the conditional likelihood, via a Maximum A Posteriori (MAP) assignment. This is the approach we followed in Chapter 4, where we used a naive Bayes model and in Chapter 5, where we used SIDIWO to recursively learn a mixture model with two latent states which would then used to bisect a dataset. Beside the novel perspective on methods of moments, D-SIDIWO has two benefits. First, a model-specific formulation of the moments – which limits the applicability of methods of moments to models with a simple structure – is not required. Second, it is grounded on a data-oriented interpretation of the results, where the entities that are used to cluster the data, have a clear and meaningful relation with the input data, even if the model that is generating the data is unknown, or the sample size is relatively small. While removing the model-dependency on the moment-based algorithm, our approach does not exclude to retrieve a latent variable model - in particular a mixture model - from the results of clustering. In Section 6.4 we will apply this method to high-dimensional healthcare records, the same used in Chapter 4. D-SIDIWO in fact looks particularly suitable for this kind of datasets, as its hierarchical approach has two major advantages. First, users (doctors or data scientists) do not have to select the number of clusters, a non-trivial task, especially when this number is high and the population is heterogeneous. Second, it allows an easy and natural way to navigate trough a high number of clusters that are organized in meaningful hierarchical trees. We will see that the proposed approach provides a superior stability while providing best-in-class quality of the clusters, outperforming both existing methods of moments and traditional clustering algorithms. Also, we analyze the results of our technique under the qualitative point of view, obtaining meaningful clinical results. 6.2 A data-centric Interpretation of SIDIWO SIDIWO – see Chapter 5 – is a decomposition algorithm to solve Equations (6.1) , (6.2) and (6.3) and learn the parameters of a latent variable model. Starting from the values of the input moments M1 , M2 , M3 and the number of latent states of the model k , SIDIWO recovers the parameters ( M, ω )of 140 the desired model by solving the following constrained optimization problem: min D∈DkX i6=j d X r=1 (DM3,rD>)2 i,j!1/2 ,(6.4) Dk={D:D= (EOk)†for some Oks.t. OkO> k=Ik}, where Ik is the k×k identity matrix, and recovers the parameters of the model from the relation MΩ1/2=EO. In this section, we present an analysis of SIDIWO under a data-centric point of view. To do this, we analyze the optimization problem (6.4) solved by SIDIWO and show that, if the moments are calculated in simple, standardized way, the optima present a meaningful relation with the input data. This relation is then used in Section 6.3 to introduce a method to split data into clusters. For ease of explanation, we focus on the special case where k = 2. While extensions to the case k≥ 2are immediate, the studied example is an instrumental building block of the top-down bisecting clustering algorithm we are going to propose. Given a dataset {x(i)}n i=1 of independent samples, we call raw moments the following quantities: ˆ M2= n X i=1 x(i)⊗x(i) n∈Rd×d,(6.5) ˆ M3= n X i=1 x(i)⊗x(i)⊗x(i) n∈Rd×d×d.(6.6) Plugging these moments into SIDIWO using k = 2, the cost function in Equation (6.4) will become min D∈D2 d X r=1 (Dˆ M3,rD>)2 1,2!1/2 ,(6.7) D2={D:D= (E2O2)†for some O2s.t. O2O> 2=I2}, where E2∈Rd×2 is the whitening matrix deduced from the truncated SVD of ˆ M2 . Given a feasible solution D∈R2×d it is possible to express it terms of 141 its rows: D = [ d1|d2 ] > . The following theorem, provides a relation between d1,d2and the input data, which is analyzed and interpreted in Section 6.3. Theorem 6.2.1. Let d1 and d2 denote the rows of a feasible D∈ D2 . Then, the optimization problem at Equation (6.7) is equivalent to the following one: min D∈D2 sup v∈Vn n X h=1 vhhd1, x(h)ihd2, x(h)i where VM = {v∈Rn : vh = hα, x(h)i,where kαk2≤ 1 } . Also, for any D= [d1|d2]>∈ D2the following relation holds: (Pn ihdj,x(i)i2 n= 1, j = 1,2 Pn ihd1,x(i)ihd2,x(i)i n= 0. Proof of Theorem 6.2.1 The statement of Theorem 6.2.1 is a consequence of the following two lemmas. Lemma 6.2.1. Let D = [ d1|d2 ] >∈ D2 be a feasible solution. Then the following relation holds:     Pn ihd1,x(i)i2 n= 1 Pn ihd2,x(i)i2 n= 1 Pn ihd1,x(i)ihd2,x(i)i n= 0 Proof. We first recall the definition of D2: D2={D:D= (E2O2)†for some O2s.t. O2O> 2=I2}, It is enough to prove that for any feasible matrix D∈ D2 the following relation holds: Dˆ M2D>=I2(6.8) where I2 is the 2 × 2identity matrix. To prove this, we consider the SVD of ˆ M2,ˆ M2=USU>,(6.9) where U∈Rd×l is the matrix whose columns are the singular vectors and S∈Rl×l is a diagonal matrix with the singular values in the diagonal entries. 142 l is such that l≤d and is the rank of ˆ M2 . It is obvious from Equation (6.9) that E†ˆ M2(E†)>=Il where E=US1/2and E†is its Moore-Penrose pseudoinverse: E†= (E>E)−1E>. The matrix E2 that we use in the definition of D2 can thus be obtained by keeping only the top two columns of E: E2=US1/2Il,2=EIl,2 where Il,2 is the l× 2identity matrix. Now, consider any D = ( E2O2 ) †∈ D2 : D=(E2O2)† =(O> 2E> 2E2O2)−1O> 2E> 2 =O> 2I2,lS−1Il,2O2O> 2E> 2 =O> 2I2,lS−1Il,2E> 2 =O> 2I2,lS−1E> =O> 2I2,lS−1(S1/2)U> =O> 2I2,l(S−1/2)U> =O> 2I2,lE† From this, we can observe that Dˆ M2D>=O> 2I2,lE†ˆ M2(E†)>Il,2O2=I2. which proves the thesis. Lemma 6.2.2. Consider Algorithm 3, applied to the moments defined in Equations (6.5) and (6.6). Then, the cost function min D∈D2 d X r=1 (Dˆ M3,rD>)2 1,2!1/2 (6.10) is equivalent to min D∈D2 sup v∈Vn n X h=1 vhhd1, x(h)ihd2, x(h)i where VM={v∈Rn:vh=hα, x(h)i,where kαk2≤1}. 143 Proof. Define the vector tas follows: t= ((Dˆ M3,1D>)1,2, ..., (Dˆ M3,dD>)1,2) and observe that problem (6.10) is trying to minimize the euclidean norm of t. From the fact that, for any vector w∈Rd, we have kwk= sup α:kαk2≤1hα, wi we obtain nktk2=nsup α:kαk2≤1hα, ti =nsup α:kαk2≤1 d X r=1 αr(Dˆ M3,rD>)1,2 = sup α:kαk2≤1 d X r=1 αr n X h=1 (x(h))rhd1, x(h)ihd2, x(h)i = sup α:kαk2≤1 n X h=1hα, x(h)ihd1, x(h)ihd2, x(h)i = sup v∈Vn n X h=1 vhhd1, x(h)ihd2, x(h)i where VM={v∈Rn:vh=hα, x(h)i,where kαk2≤1} and (x(h))ris the rth entry of x(h). From this we obtain the thesis. 6.3 A Hierarchical Clustering Algorithm Theorem 6.2.1 shows an interesting interpretation of the optimization problem solved by SIDIWO. Introduce two vectors w1 and w2 defined as follows: wi= [hdi, x(1)i, ..., hdi, x(n)i], i = 1,2 then, the cost function of SIDIWO is pushing them to have disjoint support, preferring solutions where each sample is nearly orthogonal to d1 or to d2 . At 144 the same time, the constraint is pushing each of the vectors di to be aligned to the points to which it is not nearly-orthogonal. Each vector di can be seen as a linear discriminator, that is optimized in order to be as orthogonal as possible to a certain set of points of the dataset, with the constraint of being the most aligned as possible to some of them. We can thus group the points into two clusters: those that are represented by d1 and those that are represented by d2 . d2 will be optimized to be orthogonal to the first cluster, d1 to the second. This automatically suggests a clustering rule for our points: Cluster(x(i)) = argmax 1,2 (|hd1, x(i)i|,|hd2, x(i)i|)(6.11) Using these observations we are able to modify SIDIWO and deduce from it a bisecting algorithm. The adapted algorithm will take as input a dataset {x(i)}n i=1 , calculate the raw moments and from them deduce the discriminator vectors d1 and d2 to be used to perform clustering. We call the proposed method D ata-centric SIDIWO, D-SIDIWO and we describe it in details in Algorithm 5. Algorithm 5 D-SIDIWO Require: A dataset {x(i)}n i=1 1: Get the raw moments ˆ M2and ˆ M3as (6.5) and (6.6). 2: Compute a SVD of ˆ M2 truncated at the 2nd singular vector: ˆ M2≈ U2S2U> 2. 3: Define the whitening matrix E2=U2S1/2 2∈Rd×2. 4: Find the matrix D= [d1|d2]>∈ D2optimizing (6.7) 5: for i∈[n]do 6: Cluster(x(i)) = argmax(|hd1, x(ii|,|hd2, x(i)i|) 7: end for 8: return The cluster assignment Equation (6.11) provides a splitting procedure that makes particularly sense for all data types where the angle between two vectors is a good indicator of their difference; this includes points on the simplex, on the sphere or on the hypercube, which is the case for binary data. In this last case for example, it makes sense to consider two points similar if they share several non-zero entries; similar points will thus provide similar values for the inner product with diand will finish in the same cluster. 145 The solution of problem (6.7) can be found easily, following the approach described in Theorem 5.3.3 of Chapter 5. In fact, it is sufficient to observe that D∈ D2 if and only if D = ( E2O ) † , where O is an orthogonal matrix, admitting thus the following parametrization: O=O(a) = √1−a2a −a√1−a2, for a ∈[−1,1]. The variable a is the only decision variable in problem (6.7) that can be thus optimized by griding on [−1,1]. Algorithm 5 is a method to split a dataset into two parts. Recursively iterating this procedure we obtain a top-down hierarchical clustering algorithm that can be used to find hierarchical trees of arbitrary depth. Starting from the full dataset, each iteration of D-SIDIWO generates two new leaves, on which D-SIDIWO is recursively called. A user can decide when to stop the splitting procedure: a simple heuristic may consist in halting the method when a certain maximum depth of the tree is reached. Comparison with other methods of moments Despite the core engine of D-SIDIWO is the same of the SIDIWO-based hierarchical method of moments described in Chapter 5, the approach that we are taking here to perform clustering is radically different. In the approach of Chapter 5 at each iteration, we would have used SIDIWO to learn a mixture model with two states - using the traditional approach to method of moments described in Chapter 1 - which is then used to bisect the dataset via a MAP assignment. Like all model-based methods of moments, also this approach requires to work with model-specific estimates of the moments, and tends to suffer of the limitations described in the introduction of this chapter. D-SIDIWO instead uses a generic, standardized definition to estimate the moments, and directly recovers a set of discriminator vectors with a clear relation with respect to the input data. Then, these vectors are used to group the samples of a dataset into two clusters. In this way no model-specific estimators are required, making the approach easier to implement, and, as we will see in the experiment section, more stable. 146 Traditional methods of moments typically benefit of the application of few iterations of EM (Dempster et al., 1977) - a step that is often necessary to get reliable results (see for example what done in Chapter 4). This approach can be performed also with D-SIDIWO, recovering, after each binary split, a mixture model with two components, whose centers are the average of the points in each cluster and the mixing weights are the clusters proportions. This mixture can then be refined with EM. We will see in the next section that, while the performance of D-SIDIWO is good enough to not require such further refinement, the subsequent application of EM increases the quality of the retrieved clusters, with a slight increase in the running times. Without ever incurring in clusters with poor quality, a user can threshold between short running times and even-better clusters, using or not EM after D-SIDIWO. 6.4 Experiments In this section we experimentally evaluate the performance of D-SIDIWO. Instead of using synthetic data, we directly use real-world high-dimensional binary data – in particular, the electronic healthcare records introduced in Chapter 4 – focusing again on the task of patients clustering. We will use these datasets to compare qualitatively and quantitatively the performance of D-SIDIWO with those of existing approaches to clustering.1 6.4.1 MIMIC Dataset Like in Chapter 4, we consider MIMIC III dataset (Johnson et al., 2016), focusing on the diagnostic ICD9 records, performing an analogous pre-processing of the data. We recall that ICD9 is a hierarchical coding of the form ddd.dd, with the .dd part being optional: the first 3 digits represent a general diagnostic while extra digits make the diagnostic more precise. We kept only the first three digits of the ICD-9 codes, which are those with more consensus among doctors, obtaining a vocabulary of 696 codes. Furthermore, we further refine the collected data by keeping the 90% most frequent diseases (corresponding to the 222 top diseases) and discarding the records with less than 3 diagnostics. After this processing, MIMIC dataset will contain 51181 patients. The dataset is then mapped into a matrix with binary entries, using a bag-of-words approach: the entry ( i, j )of the output matrix is 1if the 1The experimental setting is identical to that of the previous chapters. 147 patient i presents the disease j , otherwise a zero. Similarly to what we did in Chapter 4, we aim at grouping together patients with similar clinical profiles by clustering the rows of the retrieved matrix. Evaluation method We compare D-SIDIWO on the clustering task against other techniques from both MoMs and clustering literature. First, we will perform a comparison on the predictive power of the retrieved clusters. We will run D-SIDIWO (running it until a given maximum depth, considering the clustering induced on the leaves) to cluster the samples of a dataset into k groups, and do the same with the competing methods. Then, we will create a dataset containing, as only information, the cluster to which each sample is assigned, and perform a train/test split. We will then use a logistic regression to predict if a patient length of stay is going to be higher than a week or not (an information that is available in MIMIC dataset). The accuracy of the prediction will be measured on the test set, as a metric indicating the predictive power of the retrieved clusters. During this experiment, we register the running time of each method during each iteration. The second comparison will be on the stability of the clustering methods. Consider a clustering algorithm, and run it over a dataset S1 = S ∪ Sa , obtaining a clustering that we will call C1 . Now, assume to perturb the original dataset, by removing Sa , and including a new set Sb of different samples, independently generated: S2 = S ∪Sb . Then re-run the clustering algorithm obtaining a second clustering C2 . If a clustering algorithm is stable under such kind of perturbations, the partitions induced by C1 and C2 on S are expected to be similar. We run this test on our dataset, by randomly taking |S| = 40944 and |Sa| = |Sb| = 5118 (respectively, the 80% and 10% of the total sample size). For each of the tested methods, we generate two clusterings, one on S1 and one on S2 , and we compare them on S = S1∩S2 , expecting them to be similar. We use the adjusted Rand index (Hubert and Arabie, 1985) to compare the two partitions: an index close to 1 will indicate consistent clusterings, and thus stability of the method. All the experiments will be run 5 times and the standard deviation of the results will be reported. 148