English 中文(简体)
如何代表从书状中得出的Log-Likelihood比率参数
原标题:How to represent the parameters of Log-Likelihood Ratio from a text corpus

有几个包罗象票价比()的包裹,但是,为了理解正在做的事情,我提出这个问题。 我正在设法理解如何代表<条码>关于从书状中抽取“栅栏”和“复合字”的测试。 为了论证起见,本卷是:

>>> corpus = "Tom bougt hod dog. Jimmy ate hot dog. They like hot dog.".split()

现在,我想理解一下,如何将《LLR》换成文中的话,并找到可能复杂的字句,这里是hot dog。 我发现<代码>LLR的方程式,并写上了<3>x”的功能,但我不知道<代码>a, b, c, d。 这是我迄今为止所尝试的:

import math
def loglikelihoodratio(a, b, c, d):
    result = 2 * (a * math.log(a) + b * math.log(b) + c * math.log(c)
                  + d * math.log(d)
                  - (a + b) * math.log(a + b) - (a + c) * math.log(a + c)
                  - (b + d) * math.log(b + d) - (c + d) * math.log(c + d)
                  + (a + b + c + d) * math.log(a + b + c + d))
    return result

<代码>a、b、c、d? 你的友好帮助确实受到赞赏。

Edit: I got the equation from a book which is mentioned in the comments below. Here is a snapshot of the equation. Equation of LLR

问题回答

a、b、c、d摘自应急表。 Say,我们有x和 y。

a = 计数(x和 y)

b = 计数(x 发生,而不是发生)

c = 计数(未发生和发生)

d = 计数(不发生,也不发生)

例如,“Tom购买热狗”。 吉米热点狗 他们喜欢热 do 假设你作为背景之窗被判刑,那么你将具备以下共同点。

(Tom, 购买),(Tom, 热), (Tom, dog), (bought, 热), (bought, dog), (hot, dog), ......

• 显示共同风险,以产生a、b、c、d。 然后,可以利用你的职能计算LLR。





相关问题
Get webpage contents with Python?

I m using Python 3.1, if that helps. Anyways, I m trying to get the contents of this webpage. I Googled for a little bit and tried different things, but they didn t work. I m guessing that this ...

What is internal representation of string in Python 3.x

In Python 3.x, a string consists of items of Unicode ordinal. (See the quotation from the language reference below.) What is the internal representation of Unicode string? Is it UTF-16? The items ...

What does Python s builtin __build_class__ do?

In Python 3.1, there is a new builtin function I don t know in the builtins module: __build_class__(...) __build_class__(func, name, *bases, metaclass=None, **kwds) -> class Internal ...

what functional tools remain in Python 3k?

I have have read several entries regarding dropping several functional functions from future python, including map and reduce. What is the official policy regarding functional extensions? is lambda ...

Building executables for Python 3 and PyQt

I built a rather simple application in Python 3.1 using PyQt4. Being done, I want the application to be distributed to computers without either of those installed. I almost exclusively care about ...

热门标签