Use fastText trained model from Python

You can use the wrapper provided by gensim.

gensim: models.wrappers.fasttext – FastText Word Embeddings

Model learning:

$ fasttext skipgram -input data.txt -output model
$ ls model*
model.bin  model.vec

gensim installation:

$ pip install gensim

How to use:

>>> from gensim.models.wrappers.fasttext import FastText
>>> model = FastText.load_fasttext_format('model')
>>> model['Sales']
array([-0.03654   ,  0.19302   ,  0.2026    ,  0.14026   ,  0.06685   ,
        0.10969   , -0.095857  , -0.20964   , -0.27291   , -0.33750001,
        ...
        0.47084001, -0.030295  , -0.003683  , -0.10061   ,  0.17308   ], dtype=float32)
>>> m.most_similar('Sales')
[('Sales position', 0.7841936945915222),
 ('Teleapo', 0.7670873403549194),
 ('Dive', 0.7659018039703369),
 ('Telephone sales', 0.7384717464447021),
 ...]

The model learning itself can be done from the wrapper of gensim, but it seems that there is not much merit, so it is omitted.

Recommended Posts

Use fastText trained model from Python
Use thingsspeak from python
Use fluentd from python
Use MySQL from Python
Use MySQL from Python
Use mecab-ipadic-neologd from python
Use django model from interpreter
Use e-Stat API from Python
Use Stanford Core NLP from Python
Read and use Python files from Python
Forcibly use Google Translate from python
Use kabu Station® API from Python
Use the Flickr API from Python
Use Google Analytics API from Python
Use PostgreSQL data type (jsonb) from Python
Use machine learning APIs A3RT from Python
Use a scikit-learn model trained in PySpark
I want to use jar from python
Use Google Cloud Vision API from Python
[TensorFlow] Extract features from trained model Inception-v3
Deploy Python face recognition model on Heroku and use it from Flutter ②
Deploy Python face recognition model on Heroku and use it from Flutter ①
sql from python
MeCab from Python
Firebase: Use Cloud Firestore and Cloud Storage from Python
Study from Python Hour7: How to use classes
We have released a trained model of fastText
[Bash] Use here-documents to get python power from bash
I want to use ceres solver from python
Wrap C ++ with Cython for use from Python
Use the nghttp2 Python module from Homebrew from pyenv's Python
Use Tor to connect from urllib2 [Python] [Mac]
Python: Use zipfile to unzip from standard input
Use R density ratio estimation package densratio from Python
Touch MySQL from Python 3
Use config.ini in Python
Operate Filemaker from Python
[Python] Use JSON with Python
Use dates in Python
Access bitcoind from python
Changes from Python 3.0 to Python 3.5
Changes from Python 2 to Python 3.0
Python from or import
Use Valgrind in Python
Use mecab with Python3
Run python from excel
Install python from source
Use DynamoDB with Python
Execute command from Python
I wanted to use the Python library from MATLAB
Operate neutron from Python!
[Python] format methodical use
Use python with docker
Operate LXC from Python
Use LiquidTap Python Client ②
Manipulate riak from python
Force Python from Fortran
Use profiler in Python
Execute command from python
[Python] Read From Stdin
Use LiquidTap Python Client ①