Skip to content

Error in Naive Bayes Classification section #557

Description

@robertjankowski

While learning about Naive Bayes Classification I encountered a problem with bayespost function. When I rewrited this function in my jupyter notebook I got following error

AssertionError: Argument data must have NDArray type, but got ...

I wanted to fix this and change two lines in this function

def bayespost(data):
    logpost = logpy.copy()
    logpost += (logpx * x + logpxneg * (1 - x)).sum(0)
    logpost -= nd.max(logpost)
    post = nd.exp(logpost)  # before was:  post = nd.exp(logpost).asnumpy()
    post /= nd.sum(post)
    return post.asnumpy() # before was:  post

I am also curious if only I got this error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions