word2vec visualization

using vis.py ipython notebook version:

original vis.py

In [1]:
import visword2vec
# 単語で作ったモデル
vis = visword2vec.visWord2Vec("recipe_steps.bin")
# フレーズで作ったモデル
vis_phrase = visword2vec.visWord2Vec("recipe_steps-phrase.bin")
loading
loaded
loading
loaded
In [2]:
def plot_both(word):
    vis.plot(word)
    vis_phrase.plot(word)
In [3]:
plot_both('チョコ')
[ 0.21099427  0.11427726]
[ 0.19734898  0.13841781]
In [4]:
vis_phrase.plot('義理_チョコ')
[ 0.16700684  0.1221358 ]
In [5]:
plot_both('義理')
[ 0.17986007  0.14094272]
[ 0.248188    0.16636363]
In [6]:
plot_both('あつあつ')
[ 0.26638556  0.15453213]
[ 0.2672984   0.13360398]
In [7]:
plot_both('赤味噌')
[ 0.28729394  0.17572656]
[ 0.18505508  0.12923893]

using vis.py ipython notebook version:

original vis.py

In [1]:
import visword2vec
# 単語で作ったモデル
vis = visword2vec.visWord2Vec("recipe_steps.bin")
# フレーズで作ったモデル
vis_phrase = visword2vec.visWord2Vec("recipe_steps-phrase.bin")
loading
loaded
loading
loaded
In [2]:
def plot_both(word):
    vis.plot(word)
    vis_phrase.plot(word)
In [3]:
plot_both('チョコ')
[ 0.21099427  0.11427726]
[ 0.19734898  0.13841781]
In [4]:
vis_phrase.plot('義理_チョコ')
[ 0.16700684  0.1221358 ]
In [5]:
plot_both('義理')
[ 0.17986007  0.14094272]
[ 0.248188    0.16636363]
In [6]:
plot_both('あつあつ')
[ 0.26638556  0.15453213]
[ 0.2672984   0.13360398]
In [7]:
plot_both('赤味噌')
[ 0.28729394  0.17572656]
[ 0.18505508  0.12923893]

 

 

Leave a comment

Your email address will not be published. Required fields are marked *