0
$\begingroup$

I try to solve a problem with 3 features and 6 classes(label). The training dataset is 700 rows * 3 columns. I use one-Vs-all method, but I do not why the prediction accuracy is too small, just 24%. This is how I do the prediction:

function p = predictOneVsAll(all_theta, X)
m = size(X, 1);
num_labels = size(all_theta, 1);
% You need to return the following variables correctly 
p = zeros(size(X, 1), 1);
% Add ones to the X data matrix
X = [ones(m, 1) X];
[m, p] = max(sigmoid(X * all_theta'), [], 2);
end

And the One-Vs-all

% You need to return the following variables correctly 
all_theta = zeros(num_labels, n + 1);

% Add ones to the X data matrix
X = [ones(m, 1) X];

initial_theta = zeros(n+1, 1);
options = optimset('GradObj', 'on', 'MaxIter', 20);
for c = 1:num_labels,
 [theta] = ...
     fmincg (@(t)(lrCostFunction(t, X, (y == c), lambda)), ...
             initial_theta, options);
 all_theta(c,:) = theta';
end
$\endgroup$
  • $\begingroup$ You have to move your question to other stack exchange, this platform is not programming question. Please read the rules here stats.stackexchange.com/help/on-topic . $\endgroup$ – Ankish Bansal Jan 11 at 15:34
  • $\begingroup$ Are your features continuous or categorical? $\endgroup$ – mdewey Jan 11 at 16:26
  • $\begingroup$ acontinious from 0-100 $\endgroup$ – user233759 Jan 11 at 17:23

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.