Latent Dirichlet Allocation (LDA)

Similar documents
Latent Dirichlet Allocation Introduction/Overview

Text Mining for Economics and Finance Latent Dirichlet Allocation

Topic Modelling and Latent Dirichlet Allocation

Study Notes on the Latent Dirichlet Allocation

Applying LDA topic model to a corpus of Italian Supreme Court decisions

Bayesian Nonparametrics for Speech and Signal Processing

Document and Topic Models: plsa and LDA

Lecture 13 : Variational Inference: Mean Field Approximation

16 : Approximate Inference: Markov Chain Monte Carlo

CS Lecture 18. Topic Models and LDA

Topic Models and Applications to Short Documents

Recent Advances in Bayesian Inference Techniques

Latent Dirichlet Allocation (LDA)

Applying hlda to Practical Topic Modeling

Generative Clustering, Topic Modeling, & Bayesian Inference

Evaluation Methods for Topic Models

Information retrieval LSI, plsi and LDA. Jian-Yun Nie

Distributed ML for DOSNs: giving power back to users

A graph contains a set of nodes (vertices) connected by links (edges or arcs)

AN INTRODUCTION TO TOPIC MODELS

Lecture 19, November 19, 2012

Latent Dirichlet Allocation Based Multi-Document Summarization

STA 4273H: Statistical Machine Learning

Gaussian Mixture Model

Pachinko Allocation: DAG-Structured Mixture Models of Topic Correlations

Introduction to Machine Learning

Fast Inference and Learning for Modeling Documents with a Deep Boltzmann Machine

Time-Sensitive Dirichlet Process Mixture Models

Collaborative topic models: motivations cont

Topic Modeling: Beyond Bag-of-Words

Dirichlet Enhanced Latent Semantic Analysis

STA 4273H: Statistical Machine Learning

Bayesian Methods for Machine Learning

Mixed-membership Models (and an introduction to variational inference)

Kernel Density Topic Models: Visual Topics Without Visual Words

Latent Dirichlet Allocation

PROBABILISTIC LATENT SEMANTIC ANALYSIS

Probabilistic Latent Semantic Analysis

Mixtures of Multinomials

Topic Models. Material adapted from David Mimno University of Maryland INTRODUCTION. Material adapted from David Mimno UMD Topic Models 1 / 51

27 : Distributed Monte Carlo Markov Chain. 1 Recap of MCMC and Naive Parallel Gibbs Sampling

Text mining and natural language analysis. Jefrey Lijffijt

Benchmarking and Improving Recovery of Number of Topics in Latent Dirichlet Allocation Models

Latent Dirichlet Alloca/on

Learning the Semantic Correlation: An Alternative Way to Gain from Unlabeled Text

Gaussian Models

13: Variational inference II

CS145: INTRODUCTION TO DATA MINING

Non-Parametric Bayes

Variational Bayesian Dirichlet-Multinomial Allocation for Exponential Family Mixtures

Lecture 22 Exploratory Text Analysis & Topic Models

STA 4273H: Statistical Machine Learning

Topic Models. Brandon Malone. February 20, Latent Dirichlet Allocation Success Stories Wrap-up

28 : Approximate Inference - Distributed MCMC

Pattern Recognition and Machine Learning

Collapsed Variational Bayesian Inference for Hidden Markov Models

Chapter 8 PROBABILISTIC MODELS FOR TEXT MINING. Yizhou Sun Department of Computer Science University of Illinois at Urbana-Champaign

A Unified Posterior Regularized Topic Model with Maximum Margin for Learning-to-Rank

Latent Dirichlet Allocation and Singular Value Decomposition based Multi-Document Summarization

CS839: Probabilistic Graphical Models. Lecture 7: Learning Fully Observed BNs. Theo Rekatsinas

Chapter 4 Dynamic Bayesian Networks Fall Jin Gu, Michael Zhang

Bayesian Nonparametric Models

Expectation Maximization (EM)

Behavioral Data Mining. Lecture 2

Unsupervised Activity Perception in Crowded and Complicated Scenes Using Hierarchical Bayesian Models

Haupthseminar: Machine Learning. Chinese Restaurant Process, Indian Buffet Process

Replicated Softmax: an Undirected Topic Model. Stephen Turner

Text Mining. Dr. Yanjun Li. Associate Professor. Department of Computer and Information Sciences Fordham University

Welcome to CAMCOS Reports Day Fall 2011

Latent Dirichlet Allocation

Latent Dirichlet Bayesian Co-Clustering

Language Information Processing, Advanced. Topic Models

Latent Variable Models Probabilistic Models in the Study of Language Day 4

Content-based Recommendation

Latent variable models for discrete data

EMERGING TOPIC MODELS CAMCOS REPORT FALL 2011 NEETI MITTAL

Spatial Bayesian Nonparametrics for Natural Image Segmentation

Language as a Stochastic Process

Scaling Neighbourhood Methods

Mixtures of Gaussians. Sargur Srihari

Design of Text Mining Experiments. Matt Taddy, University of Chicago Booth School of Business faculty.chicagobooth.edu/matt.

Machine Learning Techniques for Computer Vision

STA 4273H: Statistical Machine Learning

Markov Chain Monte Carlo

Part 1: Expectation Propagation

Bayesian Learning. HT2015: SC4 Statistical Data Mining and Machine Learning. Maximum Likelihood Principle. The Bayesian Learning Framework

Learning Sequence Motif Models Using Expectation Maximization (EM) and Gibbs Sampling

LDA with Amortized Inference

Machine Learning Overview

Collaborative Topic Modeling for Recommending Scientific Articles

Graphical Models for Collaborative Filtering

topic modeling hanna m. wallach

Unsupervised Activity Perception in Crowded and Complicated Scenes Using Hierarchical Bayesian Models

STA 414/2104: Machine Learning

More on HMMs and other sequence models. Intro to NLP - ETHZ - 18/03/2013

Understanding Comments Submitted to FCC on Net Neutrality. Kevin (Junhui) Mao, Jing Xia, Dennis (Woncheol) Jeong December 12, 2014

STA414/2104. Lecture 11: Gaussian Processes. Department of Statistics

Gentle Introduction to Infinite Gaussian Mixture Modeling

Intelligent Systems:

COMS 4721: Machine Learning for Data Science Lecture 18, 4/4/2017

Transcription:

Latent Dirichlet Allocation (LDA) A review of topic modeling and customer interactions application 3/11/2015 1

Agenda Agenda Items 1 What is topic modeling? Intro Text Mining & Pre-Processing Natural Language Processing & Topics 3 Application - Customer Incident Routing 2 Introduction into Latent Dirichlet Allocation (LDA) 4 Demo in R LDA Graphical Model The Dirichlet Distribution 5 Wrap up Generative Process 6 Questions Gibbs Sampling Maximum Likelihood Estimates 3/11/2015 2

Quick Text Mining Introduction 3/11/2015 3

What is topic modeling? Intro Text Mining & Pre-Processing Unstructured text Text data preparation Structured text Text analytics Initial text corpus in natural language Words and grammar parsing Text corpus for analysis, with metadata, indices, TDM Analyze structured text Text and natural language processing Source: Adaptive from Miller (2005) 3/11/2015 4

What is topic modeling? Text mining and other terms Source: Wikipedia Corpus: is a large and structured set of texts Stop words: words which are filtered out before or after processing of natural language data (text) Unstructured text: information that either does not have a pre-defined data model or is not organized in a pre-defined manner. Tokenizing: process of breaking a stream of text up into words, phrases, symbols, or other meaningful elements called tokens (see also lexical analysis) Natural language processing: field of computer science, artificial intelligence, and linguistics concerned with the interactions between computers and human (natural) languages Term document (or document term) matrix: is a mathematical matrix that describes the frequency of terms that occur in a collection of documents Supervised learning: s the machine learning task of inferring a function from labeled training data Unsupervised learning: find hidden structure in unlabeled data Stemming: the process for reducing inflected (or sometimes derived) words to their word stem, base or root form generally a written word form 3/11/2015 5

What is topic modeling? Document & information retrieval The idea is how do we take this unstructured text, index it in such a way that allows us to integrate the structure analytics back to the core information to move, sort, search, process, categorize, etc. by document. Common IR goals: Ad-hoc retrieval Filtering/Sorting Browsing Source: http://www.jisc.ac.uk/reports/value-and-benefits-oftext-mining 3/11/2015 6

What is topic modeling? Pre-Processing for Topic Modeling Base Corpus Clean the Corpus Generate Term Doc Matrix Lower case Remove number, punctuation, etc. Steaming Remove stop words Tokenize Word length Apply constraints (sparsity, etc.) packages <- c('tm', 'NLP', 'SnowballC', 'opennlp', 'opennlpmodels.en', 'RWeka') Pre-processing The input data for topic models is a document-term matrix. The rows in this matrix correspond to the documents and the columns to the terms. The number of rows is equal to the size of the corpus and the number of columns to the size of the vocabulary Mapping from the document to the term frequency vector involves tokenizing the document and then processing the tokens for example by converting them to lower-case, removing punctuation characters, removing numbers, stemming, removing stop words and omitting terms with a length below a certain minimum Each term in a collection's vocabulary the index maps in which document the term was posted (inverted indices or lists) 3/11/2015 7

Topic Modeling 3/11/2015 8

Introduction into Latent Dirichlet Allocation (LDA) Probabilistic modeling 1 Treat data as observations that arise from a generative probabilistic process that includes hidden variables: For documents, the hidden variables reflect the thematic structure of the collection. 2 Infer the hidden structure using posterior inference: What are the topics that describe this collection? 3 Situate new data into the estimated model: How does this query or new document fit into the estimated topic structure? 3/11/2015 9

Introduction into Latent Dirichlet Allocation (LDA) Generative Model & The Posterior Distribution Each doc is a random mixture of corpus-wide topics and each word is drawn from one of those topics. This assumes topics exists outside of the doc collection. Each topic is a distribution over fixed vocabulary. Generative Process: First, choose a distribution over topics (drawn from a Dirichlet distribution where yellow, pink, green, and blue have some probabilities) Then, repeatedly draw a word (color) from each distribution Next, lookup what each word topic it belongs to by the color Finally, choose the word from that distribution Posterior Distribution: Conditional distribution of all latent variables given the observations which are in this case are each of the words of the documents. However, we actually only observe the docs and therefore must infer the underlying topic structure. Goal is to infer the underlying topic structure, given documents being considered/observed What are the topics generated under these assumptions? What are the distribution over terms that generated these topics? For each document, what is the distributions over topics associated with that document? For each word, which topic generated each word Conditional distribution of all of these latent variables given the observations which are the words in the documents 3/11/2015 10

Introduction into Latent Dirichlet Allocation (LDA) Intro to Latent Dirichlet Allocation (LDA) What is Latent Dirichlet Allocation (LDA)? A generative probabilistic model for collections of discrete data such as text corpora. LDA is a threelevel hierarchical Bayesian model, in which each item of a collection is modeled as a finite mixture over an underlying set of latent topics. Each observed word originates from a topic that we do not directly observe. Each topic is, in turn, modeled as an infinite mixture over an underlying set of topic probabilities. What is used for? The fitted model can be used to estimate the similarity between documents as well as between a set of specified keywords using an additional layer of latent variables which are referred to as topics. How is it related to text mining and other machine learning techniques? Topic models can be seen as classical text mining or natural language processing tools. Fitting topic models based on data structures from the text mining usually done by considering the problem of modeling text corpora and other collections of discrete data. One of the advantages of LDA over related latent variable models is that it provides well-defined inference procedures for previously unseen documents (LSI uses a singular value decomposition) 3/11/2015 11

Introduction into Latent Dirichlet Allocation (LDA) LDA Graphical Model Dirichlet parameter Per-document topic proportions (d =doc replication) Per-word topic assignment Observed Word (nth word in the dth doc) Topics (Beta= distribution over terms) Topics hyperparameter Plates D = docs N = words K = topics Graphical models Y α θ d Z d,n W d,n N D β d,n K η X 1 X 2 X 3 Y Graphical model representation of LDA. The boxes are plates representing replicates. The outer plate represents documents, while the inner plate represents the repeated choice of topics and words within a document. Nodes are random variables Edges denote possible dependence Observed variables are shaded Plates denote replicated structure X n N 3/11/2015 12

Introduction into Latent Dirichlet Allocation (LDA) Topic Matrix K Z d,n 1 Once we select Z, we know what topic its coming from, then lookup the cell Lookup in beta in the Zdn column the Wdn word and get the words probability from there That is why we have the observed Wdn depend on all the Zdn and beta s 2 Probability of observing this word: V W d,n WHERE Wd,n is the observed word AND Zd,n is an index from 1 to k AND Beta d,k are the topics 3 Joint probability of all the hidden and observed variables according to this model: Comes from a Dirichlet 1 1 1 1. 1 ( ( ( ( (( K topics which is a distribution over words V words in the vocabulary Each topic coming from some distribution that is appropriate over topics (Dirichlet) and is independent In our documents, generate the topic proportion, using alpha Within each doc, we have the words, drawn from the topic assignment from theta d Probability of observing this word, conditioned on Zdn and the Beta s 3/11/2015 13

Introduction into Latent Dirichlet Allocation (LDA) The Dirichlet Distribution 1 The Dirichlet distribution is an exponential family distribution over the simplex, i.e., positive vectors that sum to one 2 The Dirichlet is conjugate to the multinomial. Given a multinomial observation, the posterior distribution of θ is a Dirichlet. 3 The parameter α controls the mean shape and sparsity of θ. Parameter α is a k-vector with components αi >0 4 The topic proportions are a K dimensional Dirichlet. The topics are a V dimensional Dirichlet. 3/11/2015 14

Introduction into Latent Dirichlet Allocation (LDA) Geometric Interpretation of LDA Term A as we draw random variables from theta, I m going to get distributions over 3 elements. θ ~ Dirichlet(1,1,1) = α1 = α2 = α3 = 1, uniform distribution as an example All mass on A All mass on B Term Simplex Topic 2 A B C A B C Topic 3 Doc1 Doc3 Doc2 All mass on C Some point within the space over the distribution of 3 items. The Dirichlet places a distribution over this space. Topic Simplex Doc4 Topic 1 A B C A B C Term B 3 Dimension Dirichlet Term C Dirichlet is parameterized by α, so as α increases the chart gets more peaky. 3/11/2015 15

Introduction into Latent Dirichlet Allocation (LDA) Density Example Important piece of info: 1) The expectations of the posterior (sometimes called M for mean) 2) The sum of the alphas, which determines the peaky-ness of the Dirichlet - If this sum is small, the Dirichlet will be more spread out - If large, the Dirichlet will have more peaks at its expectation (sometimes called S for scaling) 2D view α > 1 When α < 1 (s < k), you get sparsity and on the 3 simplex you get a figure with increased probability at the corners. 0 1 α < 1 3/11/2015 16

Introduction into Latent Dirichlet Allocation (LDA) LDA Inferences K LDA puts posterior topical words together by: 1. Maximizing the word probabilities by dividing the words among the topics. 1. Joint distribution: V Some words assigned, more mass on a smaller set of words 2. In a mixture model, finds cluster of co-occurring words (in the same topic) In LDA, a document will be penalized for having too many topics (hyperparameter) Loosely, this can be thought of as softening the strict definition of co-occurrence" in a mixture model This flexibility leads to sets of terms that more tightly co-occur Likelihood term 1 1 1 1. 1 K topics which is a distribution over words V words in the vocabulary ( ( (( 3/11/2015 17

Introduction into Latent Dirichlet Allocation (LDA) Posterior distribution & model estimation for LDA Approximate posterior inference methods 1 Gibbs sampling 2 The Gibbs sampling algorithm is a typical Markov Chain Monte Carlo (Mcmc) method and was originally proposed for image restoration Define a Markov chain whose stationary distribution is the posterior of interest Collect independent samples from that stationary distribution; approximate the posterior with them The chain is run by iteratively sampling from the conditional distribution of each hidden variable given observations and the current state of the other hidden variables Once a chain has burned in," collect samples at a lag to approximate the posterior. 3 Variational methods (Bayesian inference & Collapsed variational Bayesian inference) Variational methods are a deterministic alternative to MCMC. For many interesting distributions, the marginal likelihood of the observations is difficult to efficiently compute The goal is to optimize the variational parameters to make tight as possible Particle filtering Summary of learning algorithm for Gibbs: Initialize the topic to word assignments z randomly from {1,...,K} For each Gibbs sample: For each word token, the count matrices n^-(a,b) are first decremented by one for the entries that correspond to the current topic assignment. The count matrices are updated by incrementing by one at the new topic assignment. Discard samples during the initial burn-in period After the Markov chain has reached a stationary distribution, i.e., the posterior distribution over topic assignments, samples can be taken at a fixed lag (averaging over Gibbs samples is recommended for statistics that are invariant to the ordering of topics) 3/11/2015 18

Introduction into Latent Dirichlet Allocation (LDA) Maximum likelihood (Ml) estimation Example: Estimated marginal log-likelihoods per number of topics (circles), average likelihoods are connected by lines Empirical Bayes method for parameter estimation: Given a corpus of docs we want to find parameters α and β that maximize the (marginal) log likelihood of the data 3/11/2015 19

Using R & Demo 3/11/2015 20

R implementations of Latent Dirichlet Allocation (LDA) Available packages through CRAN Topic models Provides an interface to the C code for Latent Dirichlet Allocation (LDA) models and Correlated Topics Models (CTM) by David M. Blei and co-authors and the C++ code for fitting LDA models using Gibbs sampling by Xuan-Hieu Phan and co-authors These functions use a collapsed Gibbs sampler to fit three different models: latent Dirichlet allocation (LDA), the mixed-membership stochastic blockmodel (MMSB), and supervised LDA (slda). These functions take sparsely represented input documents, perform inference, and return point estimates of the latent parameters using the state at the last iteration of Gibbs sampling. lda This package implements latent Dirichlet allocation (LDA) and related models. This includes (but is not limited to) slda, corrlda, and the mixed-membership stochastic blockmodel. Inference for all of these models is implemented via a fast collapsed Gibbs sampler writtten in C. Utility functions for reading/writing data typically used in topic models, as well as tools for examining posterior distributions are also included nteresting is the post Finding structure in xkcd comics with Latent Dirichlet Allocation : http://cpsievert.github.io/projects/615/xkcd/ 3/11/2015 21

Application - Customer Incident Routing Text Mining What are the important drivers of incidents? Text mining of incident data to find keywords and themes ext Clustering Incident Routing Solution Incident Tracking Text Classification What are the categories of incidents? How to derive insights and map to known solutions? Text clustering to identify incident groups Text classification to tag each incident to theme clusters 3/11/2015 22

Incident Text Analytics Process Example incident text analytical process Grouped by topics Solutio Solutio n 1 n 2 System monitoring incident Text Pattern & Cluster Modeling Incide nt Store d Cluster 1 Cluster Cluster 2 3 Cluster Cluster 4 5 Cluster 6 Customer reported incident Machine Learnin g Modelin g User Defined Supervis ed paramete rs 3/11/2015 23

References Latent Dirichlet Allocation David M. Blei, Andrew Y. Ng, Michael I. Jordan - Journal of Machine Learning Research 3 (2003) 993-1022 Topic Models lecture David M. Blei, September 1, 2009 found at http://videolectures.net/mlss09uk_blei_tm/ Latent Dirichlet Allocation in R Martin Ponweiser, Institute for Statistics and Mathematics http://statmath.wu.ac.at/, Thesis 2, May 2012 topicmodels: An R Package for Fitting Topic Models, Bettina Grun & Kurt Hornik Text mining Ian H. Witten, Computer Science, University of Waikato, Hamilton, New Zealand 3/11/2015 24

Wrap up & Questions 3/11/2015 25