Skip to content

Commit 3d90536

Browse files
committed
edit scientific_details_of_algorithms/lda_topic_modeling/LDA-Science.ipynb
1 parent 49276c6 commit 3d90536

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

scientific_details_of_algorithms/lda_topic_modeling/LDA-Science.ipynb

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"cell_type": "markdown",
1919
"metadata": {},
2020
"source": [
21-
"# Introduction\n",
21+
"## Introduction\n",
2222
"***\n",
2323
"\n",
2424
"Amazon SageMaker LDA is an unsupervised learning algorithm that attempts to describe a set of observations as a mixture of distinct categories. Latent Dirichlet Allocation (LDA) is most commonly used to discover a user-specified number of topics shared by documents within a text corpus. Here each observation is a document, the features are the presence (or occurrence count) of each word, and the categories are the topics. Since the method is unsupervised, the topics are not specified up front, and are not guaranteed to align with how a human may naturally categorize documents. The topics are learned as a probability distribution over the words that occur in each document. Each document, in turn, is described as a mixture of topics.\n",
@@ -70,7 +70,7 @@
7070
"cell_type": "markdown",
7171
"metadata": {},
7272
"source": [
73-
"# Setup\n",
73+
"## Setup\n",
7474
"\n",
7575
"***\n",
7676
"\n",
@@ -114,7 +114,7 @@
114114
"cell_type": "markdown",
115115
"metadata": {},
116116
"source": [
117-
"## The LDA Model\n",
117+
"### The LDA Model\n",
118118
"\n",
119119
"As mentioned above, LDA is a model for discovering latent topics describing a collection of documents. In this section we will give a brief introduction to the model. Let,\n",
120120
"\n",
@@ -143,11 +143,11 @@
143143
"cell_type": "markdown",
144144
"metadata": {},
145145
"source": [
146-
"# Data Exploration\n",
146+
"## Data Exploration\n",
147147
"\n",
148148
"---\n",
149149
"\n",
150-
"## An Example Dataset\n",
150+
"### An Example Dataset\n",
151151
"\n",
152152
"Before explaining further let's get our hands dirty with an example dataset. The following synthetic data comes from [1] and comes with a very useful visual interpretation.\n",
153153
"\n",
@@ -312,7 +312,7 @@
312312
"cell_type": "markdown",
313313
"metadata": {},
314314
"source": [
315-
"## Generating Documents\n",
315+
"### Generating Documents\n",
316316
"\n",
317317
"LDA is a generative model, meaning that the LDA parameters $(\\alpha, \\beta)$ are used to construct documents word-by-word by drawing from the topic-word distributions. In fact, looking closely at the example documents above you can see that some documents sample more words from some topics than from others.\n",
318318
"\n",
@@ -340,7 +340,7 @@
340340
"cell_type": "markdown",
341341
"metadata": {},
342342
"source": [
343-
"## Topic Mixtures\n",
343+
"### Topic Mixtures\n",
344344
"\n",
345345
"For the documents we generated above lets look at their corresponding topic mixtures, $\\theta \\in \\mathbb{R}^K$. The topic mixtures represent the probablility that a given word of the document is sampled from a particular topic. For example, if the topic mixture of an input document $w$ is,\n",
346346
"\n",
@@ -446,7 +446,7 @@
446446
"cell_type": "markdown",
447447
"metadata": {},
448448
"source": [
449-
"# Training\n",
449+
"## Training\n",
450450
"\n",
451451
"***\n",
452452
"\n",
@@ -457,7 +457,7 @@
457457
"cell_type": "markdown",
458458
"metadata": {},
459459
"source": [
460-
"## Topic Estimation using Tensor Decompositions\n",
460+
"### Topic Estimation using Tensor Decompositions\n",
461461
"\n",
462462
"Given a document corpus, Amazon SageMaker LDA uses a spectral tensor decomposition technique to determine the LDA model $(\\alpha, \\beta)$ which most likely describes the corpus. See [1] for a primary reference of the theory behind the algorithm. The spectral decomposition, itself, is computed using the CPDecomp algorithm described in [2].\n",
463463
"\n",
@@ -483,7 +483,7 @@
483483
"cell_type": "markdown",
484484
"metadata": {},
485485
"source": [
486-
"## Store Data on S3\n",
486+
"### Store Data on S3\n",
487487
"\n",
488488
"Before we run training we need to prepare the data.\n",
489489
"\n",
@@ -534,7 +534,7 @@
534534
"cell_type": "markdown",
535535
"metadata": {},
536536
"source": [
537-
"## Training Parameters\n",
537+
"### Training Parameters\n",
538538
"\n",
539539
"Particular to a SageMaker LDA training job are the following hyperparameters:\n",
540540
"\n",
@@ -622,7 +622,7 @@
622622
"cell_type": "markdown",
623623
"metadata": {},
624624
"source": [
625-
"## Inspecting the Trained Model\n",
625+
"### Inspecting the Trained Model\n",
626626
"\n",
627627
"We know the LDA parameters $(\\alpha, \\beta)$ used to generate the example data. How does the learned model compare the known one? In this section we will download the model data and measure how well SageMaker LDA did in learning the model.\n",
628628
"\n",
@@ -706,7 +706,7 @@
706706
"cell_type": "markdown",
707707
"metadata": {},
708708
"source": [
709-
"# Inference\n",
709+
"## Inference\n",
710710
"\n",
711711
"***\n",
712712
"\n",
@@ -813,7 +813,7 @@
813813
"cell_type": "markdown",
814814
"metadata": {},
815815
"source": [
816-
"## Inference Analysis\n",
816+
"### Inference Analysis\n",
817817
"\n",
818818
"Recall that although SageMaker LDA successfully learned the underlying topics which generated the sample data the topics were in a different order. Before we compare to known topic mixtures $\\theta \\in \\mathbb{R}^K$ we should also permute the inferred topic mixtures\n"
819819
]
@@ -1020,7 +1020,7 @@
10201020
"cell_type": "markdown",
10211021
"metadata": {},
10221022
"source": [
1023-
"## Stop / Close the Endpoint\n",
1023+
"### Stop / Close the Endpoint\n",
10241024
"\n",
10251025
"Finally, we should delete the endpoint before we close the notebook.\n",
10261026
"\n",
@@ -1040,7 +1040,7 @@
10401040
"cell_type": "markdown",
10411041
"metadata": {},
10421042
"source": [
1043-
"# Epilogue\n",
1043+
"## Epilogue\n",
10441044
"\n",
10451045
"---\n",
10461046
"\n",

0 commit comments

Comments
 (0)