Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HMM-FirstOrderHiddenMarkovModelTest文件bug错误 #1530

Closed
1 task done
Viserion-nlper opened this issue Aug 15, 2020 · 2 comments
Closed
1 task done

HMM-FirstOrderHiddenMarkovModelTest文件bug错误 #1530

Viserion-nlper opened this issue Aug 15, 2020 · 2 comments
Labels

Comments

@Viserion-nlper
Copy link

Viserion-nlper commented Aug 15, 2020

Describe the bug
A clear and concise description of what the bug is.
在我跟踪使用hmm对玩具医疗模型分析时,得出prob并非0.015,分析问题发现bug如下
Code to reproduce the issue
Provide a reproducible test case that is the bare minimum necessary to generate the problem.

 for(int cur_s = 0; cur_s < max_s; ++cur_s) {
            score[cur_s] = this.start_probability[cur_s] + this.emission_probability[cur_s][observation[0]];
        }
如这里最后observation[0]在t=2时刻时是体寒状态observation[0]值为2然而.emission_probability[cur_s][2]中却是第三个状态的值问题原因在于0下标  导致2下标指向了第三个状态值/**
     * 显状态
     */
    enum Feel
    {
        normal,
        dizzy,
        cold,
    }
我在Feel声明时调换了 dizzy和cold顺序 使其与emission_probability状态矩阵对应得出prob概率值为0.015(之前概率结果为0.0097199995

Describe the current behavior
A clear and concise description of what happened.
一个小小的BUG
Expected behavior
A clear and concise description of what you expected to happen.
提交
System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04):windows
  • Python version:3.6
  • HanLP version:1.78

Other info / logs
Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.
testPredict

  • I've completed this form and searched the web for solutions.
@hankcs
Copy link
Owner

hankcs commented Aug 15, 2020

【自动回复】您好,感谢反馈。
由于未按要求填写,本issue被暂时标记为无效。

如果您提的是bug或feature request,请按issue模板认真修改,然后耐心等待下周末处理。

否则,咨询类的问题GitHub概不受理。请先搜索一下,99.9%的问题已经反复回答过了,人类的本质是复读机。如果您确信您提了个新问题,那么欢迎写清楚前因后果发在论坛而不是GitHub上。

如果您不修改的话,恐怕没有人能够回复您,我们也会错失一次改进的机会或者一次友好的讨论。开源项目维护不易,只能在周末受理友好的提问,造成不便还望海涵。

@hankcs
Copy link
Owner

hankcs commented Aug 15, 2020

Hi, 感谢提出。

我没看出来问题,显状态的下标与图4-11是对应的。

hankcs com 2020-08-15 at 10 09 40 AM

enum Status
{
Healthy,
Fever,
}
/**
* 显状态
*/
enum Feel
{
normal,
cold,
dizzy,
}

static float[][] emission_probability = new float[][]{
{0.5f, 0.4f, 0.1f},
{0.1f, 0.3f, 0.6f},
};

比如 Healthy -> cold 对应 emission_probability[0][1] = 0.4 ,与上图是一致的。如果调换了 dizzy和cold顺序,反而不一致。单独仓库里的UnitTest testPredict 也能通过。唯一有bug的是,如果你先运行testGenerate,里面的toLog函数会将这些概率矩阵转为对数形式,影响testPredict的运行。为了解决这个问题,我添加了一个备份机制,请参考上面的commit。

如果还有问题,欢迎重开issue。

@hankcs hankcs closed this as completed Aug 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants