diff --git a/ch08/Topic_Modeling_Clustering.ipynb b/ch08/Topic_Modeling_Clustering.ipynb index 0e8ef87..4aabd78 100644 --- a/ch08/Topic_Modeling_Clustering.ipynb +++ b/ch08/Topic_Modeling_Clustering.ipynb @@ -162,8 +162,7 @@ "height": 527 }, "id": "FdsLNCg0ddwW", - "outputId": "c28d0aed-a2d9-418b-a4f1-74b5fada5042", - "scrolled": false + "outputId": "c28d0aed-a2d9-418b-a4f1-74b5fada5042" }, "outputs": [], "source": [ @@ -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": [ @@ -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_" @@ -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)" ] }, @@ -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": { @@ -817,6 +797,7 @@ }, "outputs": [], "source": [ + "from numpy import triu\n", "from gensim.corpora import Dictionary\n", "\n", "dict_gensim_para = Dictionary(gensim_paragraphs) " @@ -1081,8 +1062,7 @@ "cell_type": "code", "execution_count": null, "metadata": { - "id": "Zvr8KcafddxL", - "scrolled": false + "id": "Zvr8KcafddxL" }, "outputs": [], "source": [ @@ -1115,8 +1095,7 @@ "cell_type": "code", "execution_count": null, "metadata": { - "id": "aXzMrPQTddxM", - "scrolled": false + "id": "aXzMrPQTddxM" }, "outputs": [], "source": [ @@ -1209,8 +1188,7 @@ "cell_type": "code", "execution_count": null, "metadata": { - "id": "GB23o18CddxT", - "scrolled": false + "id": "GB23o18CddxT" }, "outputs": [], "source": [ @@ -1292,8 +1270,7 @@ "cell_type": "code", "execution_count": null, "metadata": { - "id": "WYcY-h91ddxU", - "scrolled": false + "id": "WYcY-h91ddxU" }, "outputs": [], "source": [ @@ -1315,7 +1292,7 @@ "provenance": [] }, "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "blueprints", "language": "python", "name": "python3" }, @@ -1329,7 +1306,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.10" + "version": "3.12.8" }, "toc": { "base_numbering": 1, diff --git a/ch08/requirements.txt b/ch08/requirements.txt index 429151f..52f8e02 100644 --- a/ch08/requirements.txt +++ b/ch08/requirements.txt @@ -1,2 +1,3 @@ gensim>3.7 pyLDAvis +scipy<1.13 \ No newline at end of file