Skip to content

Commit

Permalink
update code of cross-validation over various labeled data size
Browse files Browse the repository at this point in the history
  • Loading branch information
sli41 committed Apr 25, 2017
1 parent 72ef567 commit 7a1e719
Show file tree
Hide file tree
Showing 7 changed files with 2,145 additions and 649 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"from copy import deepcopy\n",
"from wordcloud import WordCloud \n",
"from Semi_EM_NB import Semi_EM_MultinomialNB\n",
"\n",
"from os import path\n",
"from PIL import Image\n",
"\n",
"from nltk.corpus import stopwords\n",
"from nltk.tokenize import RegexpTokenizer\n",
Expand Down Expand Up @@ -110,11 +111,13 @@
" feature_names = np.asarray(vectorizer.get_feature_names())\n",
" nrows, ncols = 5, 4\n",
" fig, axes = plt.subplots(figsize=(50, 40), nrows=nrows, ncols=ncols)\n",
" d = path.dirname(__file__)\n",
" circle_mask = np.array(Image.open(path.join(d, \"circle.png\")))\n",
" for i, category in enumerate(categories):\n",
" topK = np.argsort(classifier.coef_[i])[-K:]\n",
" text = \" \".join(feature_names[topK])\n",
" print(\"%s: %s\" % (category, text))\n",
" wordcloud = WordCloud().generate(text)\n",
" wordcloud = WordCloud(background_color=\"white\", mask=circle_mask,).generate(text)\n",
" axes[i//ncols, i%ncols].imshow(wordcloud, cmap=plt.cm.cool_r, interpolation='bilinear')\n",
" axes[i//ncols, i%ncols].axis(\"off\")\n",
" axes[i//ncols, i%ncols].set_title(category, fontweight=\"bold\", size=24)\n",
Expand Down
Loading

0 comments on commit 7a1e719

Please sign in to comment.