安装
!pip install fasttext
train_unsupervised 用于学习词向量
# Skipgram model :
model = fasttext.train_unsupervised('data.txt', model='skipgram')
# or, cbow model :
model = fasttext.train_unsupervised('data.txt', model='cbow')
其中 data.txt
是 utf-8
编码的文本文件。
train_supervised 用于文本分类
model = fasttext.train_supervised('data.txt')
其中 data.txt
是多行文本,默认标签的格式为 __label__<真实标签>
Signature
fasttext.train_unsupervised(
input, # training file path (required)
model, # unsupervised fasttext model {cbow, skipgram} [skipgram]
lr, # learning rate [0.05]
dim, # size of word vectors [100]
ws, # size of the context window [5]
epoch, # number of epochs [5]
minCount