Problem with Precision floating point operation in C

前端 未结 6 1939
执笔经年
执笔经年 2021-01-31 21:03

For one of my course project I started implementing \"Naive Bayesian classifier\" in C. My project is to implement a document classifier application (especially Spam) using huge

6条回答
  •  借酒劲吻你
    2021-01-31 21:38

    This happens often in machine learning. AFAIK, there's nothing you can do about the loss in precision. So to bypass this, we use the log function and convert divisions and multiplications to subtractions and additions, resp.

    SO I decided to do the math,

    The original equation is:

    Problem

    I slightly modify it:

    enter image description here

    Taking logs on both sides:

    enter image description here

    Let,

    enter image description here

    Substituting,

    enter image description here

    Hence the alternate formula for computing the combined probability:

    enter image description here

    If you need me to expand on this, please leave a comment.

提交回复
热议问题