【问题标题】:Using Jaccard Coefficient for measuring string similarity使用 Jaccard 系数测量字符串相似度
【发布时间】:2016-09-13 03:32:43
【问题描述】:

我得到了一个测试和一个训练数据集,应该用于字符串相似度测量。这里我给出了数据集的几行,

Brandon Bass ||| what the hell is Brandon bass thinking ||| Brandon Bass Has 5 Personal Fouls ||| False
Sac ||| Congrats to Sac Kings fans ||| why yall forcing the kings to stay in sac town smh ||| False
Stella ||| hello Stella can you follow me please ||| STELLA DO U HATE ME ||| False


The data file has 50 entries of the form 
TOPIC ||| TWEET_SENT_1 ||| TWEET_SENT_2 ||| HAVE_SIMILAR_MEANING

TOPIC - Twitter 主题

TWEET_SENT_1 – Tweet sentence 1
TWEET_SENT_2 – Tweet sentence 2
HAVE_SIMILAR_MEANING – a binary label (True – two sentences are similar, false – two sentences are not similar) assigned by a human annotator

我们需要将数据集分成两部分:训练集(35 个样本)和测试集(15 个样本),并且必须使用训练集来调整算法的参数。并使用最佳调整参数在测试集上进行测试。

如果算法是Jaccard系数

如何执行此任务?有人可以让我知道我可以使用的方法。

【问题讨论】:

    标签: similarity information-retrieval


    【解决方案1】:

    Jaccard 相似度是衡量两组(在您的情况下为 n-gram)的相似度。除了您决定两个字符串是否相似的阈值之外,这里不需要进行“调整”。

    例如,如果您有 2 个字符串 abcdeabdcde,则其工作方式如下:

    ngrams (n=2) :  'abcde' & 'abdcde'
       ab bc cd de dc bd
    A  1  1  1  1  0  0
    B  1  0  1  1  1  1
    

    J(A, B) = (A∩B) / (A∪B)

    J(A, B) = (3 / 6) = 0.5

    还有一个 Jaccard 距离,它捕获了两个集合之间的相异性,计算方法是用one 减去 Jaccard 系数(在这种情况下,1 - 0.5 = 0.5

    因此,对于您的问题,我将使用带有标签的训练集来定义您的字符串被视为相似/不同的适当阈值。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-02
      • 2011-08-27
      • 2016-09-05
      • 2022-07-21
      • 1970-01-01
      相关资源
      最近更新 更多