【问题标题】:The precision and recall of fasttext classification is Nonefasttext分类的准确率和召回率是None
【发布时间】:2019-07-28 20:26:51
【问题描述】:

我使用data 进行分类。我没有拆分数据。以下是我的代码:

classifier = fasttext.supervised('cooking.stackexchange.txt', 'model', 
label_prefix='__label__')
result = classifier.test('cooking.stackexchange.txt')
print('P@1: ', result.precision)
print('R@1: ', result.recall)

结果是:南,南

为什么会显示这个?有什么问题吗?(我在windows10上用fasttext)

【问题讨论】:

    标签: fasttext


    【解决方案1】:

    假设您安装了最新版本的 fasttext,请尝试以下操作:

    import fastText.FastText as fasttext
    
    def print_results(N, p, r):
        print("N\t" + str(N))
        print("P@{}\t{:.3f}".format(1, p))
        print("R@{}\t{:.3f}".format(1, r))
    
    classifier = fasttext.train_supervised('cooking.stackexchange.txt', epoch=5)
    result = classifier.test('cooking.stackexchange.txt')
    print_results(*result)
    
    # =>
    # Read 0M words
    # Number of words:  16568
    # Number of labels: 736
    # Progress: 100.0% words/sec/thread:   58127 lr:  0.000000 loss:  9.808085 ETA:   0h 0m
    # N 15404
    # P@1   0.162
    # R@1   0.070
    

    Here's another example 来自 fasttext github 项目。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-06-19
      • 2022-12-17
      • 2018-02-18
      • 2018-08-16
      • 2018-06-02
      • 2016-01-09
      • 2020-03-26
      相关资源
      最近更新 更多