Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8890881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:36:11+00:00 2026-06-14T22:36:11+00:00

I get this error: Warning: TRAINING can only contain non-negative integers when ‘Distribution’ is

  • 0

I get this error:

Warning: TRAINING can only contain
non-negative integers when
'Distribution' is set to 'mn'. Rows of
TRAINING with invalid values will be
removed. 
> In NaiveBayes.fit at 317
??? Error using ==>

??? Error using ==>
NaiveBayes.fit>mnfit at 647
At least one valid observation in each
class is required.

Error in ==> NaiveBayes.fit at 496
            obj =  mnfit(obj,training,
            gindex);

This is what I have:

training_data = Testdata; 
target_class = TestDataLabels;

%# train model
nb = NaiveBayes.fit(training_data, target_class, 'Distribution', 'mn');

%# prediction
class1 = nb.predict(UnseenTestdata); 

%# performance
cmat1 = confusionmat(UnseenTestDataLabels, class1);
acc1 = 100*sum(diag(cmat1))./sum(cmat1(:));
fprintf('Classifier1:\naccuracy = %.2f%%\n', acc1);
fprintf('Confusion Matrix:\n'), disp(cmat1)

The dataset is 4940201×42 if anyone is wondering.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:36:12+00:00Added an answer on June 14, 2026 at 10:36 pm

    You’ve got two problems.

    First, for multinomial distributions, MATLAB wants your data to have non-negative integer values. And second, it seems like for at least some of your classes, you don’t have any valid observations. This might be because of NAN’s, INF’s, or just non-positive values in the rows of Testdata.

    Actually, as the error says – “invalid rows will be removed”… so I bet invalid rows were removed…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When i try to submit the form below i get this error WARNING: Can't
I get this warning in my error logs and wanted to know how to
I'm trying to install berta (v 0.6.3b) and I get this error: Warning: session_start()
When I run the command rake:install , I get this error message: WARNING: 'require
Any idea why I get this error: Warning: Missing argument 1 for person::__construct(), called
Using tanzaku in wordpress and get this error Warning: split() [function.split]: REG_EMPTY in /public/wp-content/themes/tanzaku/functions.php
i get this error: Warning: Unknown: Your script possibly relies on a session side-effect
I get this error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
I'm trying to initialize a session but i get this error: Warning: session_start() [function.session-start]:
I get this error WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED The rest of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.