kardosdrur
commited on
Commit
·
3f888da
1
Parent(s):
4fefa96
Added script for producing deployment
Browse files- produce_app.py +25 -0
produce_app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import numpy as np
|
2 |
+
import topicwizard
|
3 |
+
from sklearn.datasets import fetch_20newsgroups
|
4 |
+
from sklearn.feature_extraction.text import CountVectorizer
|
5 |
+
from turftopic import KeyNMF
|
6 |
+
|
7 |
+
print("Fetching data")
|
8 |
+
newsgroups = fetch_20newsgroups(
|
9 |
+
subset="all",
|
10 |
+
remove=("headers", "footers", "quotes"),
|
11 |
+
)
|
12 |
+
texts = newsgroups.data
|
13 |
+
labels = list(np.array(newsgroups.target_names)[newsgroups.target])
|
14 |
+
|
15 |
+
model = KeyNMF(
|
16 |
+
20,
|
17 |
+
vectorizer=CountVectorizer(
|
18 |
+
stop_words="english",
|
19 |
+
max_features=8000,
|
20 |
+
ngram_range=(1, 2),
|
21 |
+
),
|
22 |
+
)
|
23 |
+
topic_data = model.prepare_topic_data(texts)
|
24 |
+
|
25 |
+
topicwizard.easy_deploy(topic_data, dest_dir=".")
|