Train num_labels one-vs-all logistic regression classifiers
This commit is contained in:
parent
9117809537
commit
cf0d25440c
1 changed files with 16 additions and 14 deletions
|
@ -49,18 +49,20 @@ X = [ones(m, 1) X];
|
|||
% initial_theta, options);
|
||||
%
|
||||
|
||||
for c = 1:num_labels
|
||||
|
||||
% Train a one-vs all classifier for this class c
|
||||
|
||||
initial_theta = zeros(n + 1, 1);
|
||||
options = optimset('GradObj', 'on', 'MaxIter', 50);
|
||||
|
||||
[theta] = fmincg(@(t)(lrCostFunction(t, X, (y == c), lambda)),
|
||||
initial_theta, options);
|
||||
|
||||
all_theta(c,:) = theta';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
% =========================================================================
|
||||
|
||||
|
||||
end
|
||||
|
|
Reference in a new issue