matrix - MATLAB Naive Bayes object storing -


after using:

nb = naivebayes.fit(training, class) 

to create naive bayes classifier object, want save n-by-d of these objects in matrix. have tried following

arrayofnaivebayes(2,3) = nb; 

but get: "error using naivebayes/subsasgn (line 9) naivebayes class not support subscripted assignments."

how possible fill matrix of naive bayes classifiers in matlab?

note using fitnaivebayes or fitcnb resuts in same problem both return same kind of object.

thank you

try use cell array.

first, initialize cell array. if numbers of elements want store, e.g. n x d, use

arrayofnaivebayes = cell(n,d); 

if not know size beforehand, can start empty cell array:

arrayofnaivebayes = {}; 

then if later have generated classifier object nb , want store under indices (2, 3), use

arrayofnaivebayes{2,3} = nb; 

to access value later, use same syntax arrayofnaivebayes{2,3}.

for more information, see matlab's documentation of cell arrays.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -