使用fastText进行文本分类
2017-07-10 01:10
1171 查看
fastText文本分类学习笔记
先下载,然后make,得到可执行c文件
文本分类,linux命令行:
./fasttext supervised -input train.txt -output model
训练集train.txt的输入格式为:
标签是以字符串label作为前缀的单词,后面的数字对应类别。我们可以将训练数据处理成这种形式,训练自己的文本分类模型。
一旦模型被训练,您可以通过使用以下方法计算测试集上的k的精度和召回率来对其进行评估:
$ ./fasttext test model.bin test.txt k
参数k可选,默认为1
为了预测获得一个文本的k个最可能的标签,使用:
$ ./fasttext predict model.bin test.txt k
其中test.txt包含要按行分类的文本。 这样输出为每一行的k个最可能的标签。
如果要计算句子或段落的向量表示,请使用:
$ ./fasttext print-sentence-vectors model.bin < text.txt
这假设text.txt文件包含您要获取向量的段落,一段为一行。 该程序将在文件中每行输出一个向量表示。
参数的命令以及可用的参数及其默认值:
$ ./fasttext supervised
Empty input or output path.
The following arguments are mandatory:
-input training file path 输入文件路径
-output output file path 输出文件路径
The following arguments are optional:
-verbose verbosity level [2]
The following arguments for the dictionary are optional:
-minCount minimal number of word occurences [5]
-minCountLabel minimal number of label occurences [0]
-wordNgrams max length of word ngram [1] 几元语言模型
-bucket number of buckets [2000000]
-minn min length of char ngram [3] 单词的最小长度
-maxn max length of char ngram [6] 单词的最大长度
-t sampling threshold [0.0001]
-label labels prefix [label] 标签前缀的选择
The following arguments for training are optional: 训练集可选参数
-lr learning rate [0.05]
-lrUpdateRate change the rate of updates for the learning rate [100]
-dim size of word vectors [100]
-ws size of the context window [5]
-epoch number of epochs [5]
-neg number of negatives sampled [5]
-loss loss function {ns, hs, softmax} [ns]
-thread number of threads [12]
-pretrainedVectors pretrained word vectors for supervised learning []
-saveOutput whether output params should be saved [0]
先下载,然后make,得到可执行c文件
$ gitclone https://github.com/facebookresearch/fastText.Git $ cdfastText $ make
文本分类,linux命令行:
./fasttext supervised -input train.txt -output model
训练集train.txt的输入格式为:
标签是以字符串label作为前缀的单词,后面的数字对应类别。我们可以将训练数据处理成这种形式,训练自己的文本分类模型。
一旦模型被训练,您可以通过使用以下方法计算测试集上的k的精度和召回率来对其进行评估:
$ ./fasttext test model.bin test.txt k
参数k可选,默认为1
为了预测获得一个文本的k个最可能的标签,使用:
$ ./fasttext predict model.bin test.txt k
其中test.txt包含要按行分类的文本。 这样输出为每一行的k个最可能的标签。
如果要计算句子或段落的向量表示,请使用:
$ ./fasttext print-sentence-vectors model.bin < text.txt
这假设text.txt文件包含您要获取向量的段落,一段为一行。 该程序将在文件中每行输出一个向量表示。
参数的命令以及可用的参数及其默认值:
$ ./fasttext supervised
Empty input or output path.
The following arguments are mandatory:
-input training file path 输入文件路径
-output output file path 输出文件路径
The following arguments are optional:
-verbose verbosity level [2]
The following arguments for the dictionary are optional:
-minCount minimal number of word occurences [5]
-minCountLabel minimal number of label occurences [0]
-wordNgrams max length of word ngram [1] 几元语言模型
-bucket number of buckets [2000000]
-minn min length of char ngram [3] 单词的最小长度
-maxn max length of char ngram [6] 单词的最大长度
-t sampling threshold [0.0001]
-label labels prefix [label] 标签前缀的选择
The following arguments for training are optional: 训练集可选参数
-lr learning rate [0.05]
-lrUpdateRate change the rate of updates for the learning rate [100]
-dim size of word vectors [100]
-ws size of the context window [5]
-epoch number of epochs [5]
-neg number of negatives sampled [5]
-loss loss function {ns, hs, softmax} [ns]
-thread number of threads [12]
-pretrainedVectors pretrained word vectors for supervised learning []
-saveOutput whether output params should be saved [0]
相关文章推荐
- 文本分类(六):使用fastText对文本进行分类--小插曲
- 使用fastText进行文本分类及源码分析时的一点感受
- 文本分类(六):使用fastText对文本进行分类--小插曲
- 文本分类(六):使用fastText对文本进行分类--小插曲
- FastText 文本分类使用心得
- 使用spark mllib 随机森林算法对文本进行多分类
- 【机器学习实验】使用朴素贝叶斯进行文本的分类
- 使用 全连接神经网络 和 词袋模型 进行文本分类的example
- #259 – 对使用OpenType 字体的文本进行排版(Setting Typography Properties for Text Rendered with an OpenType Font)
- Python使用jieba分词并用weka进行文本分类
- fastText、TextCNN、TextRNN……这里有一套NLP文本分类深度学习方法库供你选择
- 【NLP】使用朴素贝叶斯进行文本的分类
- Python 文本分类:使用scikit-learn 机器学习包进行文本分类
- FastText 词向量与文本分类
- 分别使用CountVectorizer与TfidfVectorizer, 并且去掉停用词的条件下,对文本特征进行量化的朴素贝叶斯分类性能测试
- 基于keras的fasttext短文本分类
- 界 | Facebook人工智能实验室开源文本分类专用工具fastText
- 使用weka进行文本分类的例子
- 【机器学习实验】使用朴素贝叶斯进行文本的分类
- 使用TfidfVectorizer并且不去掉停用词的条件下,对文本特征进行量化的朴素贝叶斯分类性能测试