Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 13 additions & 36 deletions ch08/Topic_Modeling_Clustering.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@
"height": 527
},
"id": "FdsLNCg0ddwW",
"outputId": "c28d0aed-a2d9-418b-a4f1-74b5fada5042",
"scrolled": false
"outputId": "c28d0aed-a2d9-418b-a4f1-74b5fada5042"
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -304,8 +303,7 @@
"base_uri": "https://localhost:8080/"
},
"id": "5aC7LQMHddwZ",
"outputId": "5981f3f3-d0f7-4458-b0c7-4eda85804eee",
"scrolled": false
"outputId": "5981f3f3-d0f7-4458-b0c7-4eda85804eee"
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -463,7 +461,7 @@
"outputs": [],
"source": [
"from sklearn.decomposition import LatentDirichletAllocation\n",
"\n",
"# task runs for a while... (15min on my machine)\n",
"lda_para_model = LatentDirichletAllocation(n_components = 10, random_state=42)\n",
"W_lda_para_matrix = lda_para_model.fit_transform(count_para_vectors)\n",
"H_lda_para_matrix = lda_para_model.components_"
Expand Down Expand Up @@ -499,9 +497,9 @@
},
"outputs": [],
"source": [
"import pyLDAvis.sklearn\n",
"import pyLDAvis.lda_model\n",
"\n",
"lda_display = pyLDAvis.sklearn.prepare(lda_para_model, count_para_vectors, count_para_vectorizer, sort_topics=False)\n",
"lda_display = pyLDAvis.lda_model.prepare(lda_para_model, count_para_vectors, count_para_vectorizer, sort_topics=False)\n",
"pyLDAvis.display(lda_display)"
]
},
Expand All @@ -513,28 +511,10 @@
},
"outputs": [],
"source": [
"lda_tsne_display = pyLDAvis.sklearn.prepare(lda_para_model, count_para_vectors, count_para_vectorizer, sort_topics=False, mds='tsne')\n",
"lda_tsne_display = pyLDAvis.lda_model.prepare(lda_para_model, count_para_vectors, count_para_vectorizer, sort_topics=False, mds='tsne')\n",
"pyLDAvis.display(lda_tsne_display)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "IYHW0BxPddwd"
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "naHnuA-Mddw8"
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {
Expand Down Expand Up @@ -817,6 +797,7 @@
},
"outputs": [],
"source": [
"from numpy import triu\n",
"from gensim.corpora import Dictionary\n",
"\n",
"dict_gensim_para = Dictionary(gensim_paragraphs) "
Expand Down Expand Up @@ -1081,8 +1062,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "Zvr8KcafddxL",
"scrolled": false
"id": "Zvr8KcafddxL"
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -1115,8 +1095,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "aXzMrPQTddxM",
"scrolled": false
"id": "aXzMrPQTddxM"
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -1209,8 +1188,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "GB23o18CddxT",
"scrolled": false
"id": "GB23o18CddxT"
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -1292,8 +1270,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "WYcY-h91ddxU",
"scrolled": false
"id": "WYcY-h91ddxU"
},
"outputs": [],
"source": [
Expand All @@ -1315,7 +1292,7 @@
"provenance": []
},
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "blueprints",
"language": "python",
"name": "python3"
},
Expand All @@ -1329,7 +1306,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
"version": "3.12.8"
},
"toc": {
"base_numbering": 1,
Expand Down
1 change: 1 addition & 0 deletions ch08/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
gensim>3.7
pyLDAvis
scipy<1.13