Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Mixture of Unigram Model and Infinite Mixture of Unigram Model in Python. (混合ユニグラムモデルと無限混合ユニグラムモデル)

NotificationsYou must be signed in to change notification settings

KentoW/mixture-of-unigram-model

Repository files navigation

概要

混合ユニグラムモデル(mixture of unigram model)をPythonで実装
無限混合ユニグラムモデル(infinite mixture of unigram model)をPythonで実装

mixture_of_unigram_model.pyの使い方(混合ユニグラムモデル)

# Sample code.frommixture_of_unigram_modelimportMUMalpha=0.01# 初期ハイパーパラメータalphabeta=0.01# 初期ハイパーパラメータbetaK=10# トピック数N=1000# 最大イテレーション回数converge=0.01# イテレーション10回ごとに対数尤度を計算し,その差分(converge)が小さければ学習を終了するmum=MUM("data.txt")mum.set_param(alpha,beta,K,N,converge)mum.learn()mum.output_model()

infinite_mixture_of_unigram_model.pyの使い方(無限混合ユニグラムモデル)

# Sample code.frominfinite_mixture_of_unigram_modelimportIMUMalpha=0.01# 初期ハイパーパラメータalphabeta=0.01# 初期ハイパーパラメータbetaN=1000# 最大イテレーション回数converge=0.01# イテレーション10回ごとに対数尤度を計算し,その差分(converge)が小さければ学習を終了するimum=IMUM("data.txt")imum.set_param(alpha,beta,N,converge)imum.learn()imum.output_model()

入力フォーマット

1単語をスペースで分割した1行1文書形式
先頭に#(シャープ)記号を入れてコメントを記述可能

# 文書1単語1 単語2 単語3 ...# 文書2単語10 単語11 単語11 ......

例としてWiki.pyを使用して収集した アニメのあらすじ文章をdata.txtに保存

出力フォーマット

必要な情報は各自で抜き取って使用してください.

modelmixture_of_unigram_model        # 学習の種類@parametercorpus_filedata.txt                    # トレーニングデータのPATHhyper_parameter_alpha1.834245        # ハイパーパラメータalphahyper_parameter_beta0.089558        # ハイパーパラメータbetanumber_of_topic10          # トピック数number_of_iteration121     # 収束した時のイテレーション回数@likelihood         # 尤度initial likelihood-1389.55970144last likelihood-1382.11395248@vocaburary         # 学習で使用した単語vtarget_word出産target_word拓きtarget_word土target_word吉日target_word遂げる...@counttopic_document_freq1109     # トピック分布に必要な情報 左の数字から順に トピックID, そのトピックが割り当てられた文書の数topic_document_freq2167topic_document_freq352...topic_word_sum118137   # 単語生成確率分布に必要な情報 左の数字から順に トピックID, そのトピックが割り当てられた単語の数topic_word_freq1の1111    # 単語生成確率分布に必要な情報 左の数字から順に トピックID, 単語v, そのトピックが割り当てられた単語vの数topic_word_freq1に761topic_word_freq1を621topic_word_freq1は589...topic_word_sum227892topic_word_freq2の1762topic_word_freq2に1378topic_word_freq2を1138topic_word_freq2た995...@data       # 訓練データと各文書に割り当てられたトピック(state)# state 4 # comment今日 は いい 天気 ...

About

Mixture of Unigram Model and Infinite Mixture of Unigram Model in Python. (混合ユニグラムモデルと無限混合ユニグラムモデル)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp