{"action":"created","issue":{"url":"https://api.github.com/repos/Itseez/opencv/issues/5916","labels_url":"https://api.github.com/repos/Itseez/opencv/issues/5916/labels{/name}","comments_url":"https://api.github.com/repos/Itseez/opencv/issues/5916/comments","events_url":"https://api.github.com/repos/Itseez/opencv/issues/5916/events","html_url":"https://github.com/Itseez/opencv/pull/5916","id":124641732,"number":5916,"title":"ml: fix NormalBayesClassifier bulk prediction","user":{"login":"berak","id":854416,"avatar_url":"https://avatars.githubusercontent.com/u/854416?v=3","gravatar_id":"","url":"https://api.github.com/users/berak","html_url":"https://github.com/berak","followers_url":"https://api.github.com/users/berak/followers","following_url":"https://api.github.com/users/berak/following{/other_user}","gists_url":"https://api.github.com/users/berak/gists{/gist_id}","starred_url":"https://api.github.com/users/berak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/berak/subscriptions","organizations_url":"https://api.github.com/users/berak/orgs","repos_url":"https://api.github.com/users/berak/repos","events_url":"https://api.github.com/users/berak/events{/privacy}","received_events_url":"https://api.github.com/users/berak/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-03T10:26:50Z","updated_at":"2016-01-03T10:30:16Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Itseez/opencv/pulls/5916","html_url":"https://github.com/Itseez/opencv/pull/5916","diff_url":"https://github.com/Itseez/opencv/pull/5916.diff","patch_url":"https://github.com/Itseez/opencv/pull/5916.patch"},"body":"see issue #5911\r\n"},"comment":{"url":"https://api.github.com/repos/Itseez/opencv/issues/comments/168485946","html_url":"https://github.com/Itseez/opencv/pull/5916#issuecomment-168485946","issue_url":"https://api.github.com/repos/Itseez/opencv/issues/5916","id":168485946,"user":{"login":"berak","id":854416,"avatar_url":"https://avatars.githubusercontent.com/u/854416?v=3","gravatar_id":"","url":"https://api.github.com/users/berak","html_url":"https://github.com/berak","followers_url":"https://api.github.com/users/berak/followers","following_url":"https://api.github.com/users/berak/following{/other_user}","gists_url":"https://api.github.com/users/berak/gists{/gist_id}","starred_url":"https://api.github.com/users/berak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/berak/subscriptions","organizations_url":"https://api.github.com/users/berak/orgs","repos_url":"https://api.github.com/users/berak/repos","events_url":"https://api.github.com/users/berak/events{/privacy}","received_events_url":"https://api.github.com/users/berak/received_events","type":"User","site_admin":false},"created_at":"2016-01-03T10:30:16Z","updated_at":"2016-01-03T10:30:16Z","body":"do we need a regression test ?\r\n\r\n``\r\nTEST(ML_NB, regression_5911)\r\n{\r\n    int N=12;\r\n    Ptr<ml::NormalBayesClassifier> nb = cv::ml::NormalBayesClassifier::create();\r\n\r\n    // data:\r\n    Mat_<float> X(N,4);\r\n    X << 1,2,3,4,  1,2,3,4,   1,2,3,4,    1,2,3,4,\r\n         5,5,5,5,  5,5,5,5,   5,5,5,5,    5,5,5,5,\r\n         4,3,2,1,  4,3,2,1,   4,3,2,1,    4,3,2,1;\r\n    \r\n    // labels:\r\n    Mat_<int> Y(N,1);\r\n    Y << 0,0,0,0, 1,1,1,1, 2,2,2,2;\r\n    nb->train(X, ml::ROW_SAMPLE, Y);\r\n\r\n    // single prediction:\r\n    Mat R1,P1;\r\n    for (int i=0; i<N; i++)\r\n    {\r\n        Mat r,p;\r\n        nb->predictProb(X.row(i), r, p);\r\n        R1.push_back(r);\r\n        P1.push_back(p);\r\n    }\r\n\r\n    // bulk prediction:\r\n    Mat R2,P2;\r\n    nb->predictProb(X, R2, P2);\r\n\r\n    EXPECT_EQ(sum(R1 == R2)[0], 255 * R2.total());\r\n    EXPECT_EQ(sum(P1 == P2)[0], 255 * P2.total());\r\n}\r\n``\r\n"}}