2
여기 I 가지는 문제는 로그 가능도 비율이 처음 감소하고 증가 시작이다로지스틱 회귀 그라디언트 강하 Matlab의
function [theta] = LR(D)
% D is the data having feature variables and class labels
% Now decompose D into X and C
%Note that dimensions of X = , C =
C = D(:,1);
C = C';
size(C)
X = D(:,2:size(D,2));
size(X)
alpha = .00001;
theta_old = zeros(1,34);
theta_new = .001.*ones(1,34);
count = 1;
for count = 1:100000
theta_old = theta_new;
theta_new = theta_new + alpha*(C-sigmoid(X*theta_new')')*X;
llr = sum(LLR((X*theta_new').*(C')))
end
thetaopt = theta_new
end
function a = LLR(z)
a= 1.*log(1.0 + exp(-z));
end
function a = sigmoid(z)
a = 1.0 ./ (1.0 + exp(-z));
end
코드를이다. Gradient Descent 알고리즘이나 코드에 문제가 있습니까?
레이블은 D (:, 1) 0/1 또는 -1/1입니다. 우리가 체중 (theta_new) 그라디언트, llr, 매 10 iter를 보여줄 수 있습니다, 당신이 iter 100000 번 이후로 모델 overfitting 것, 그것은 많이입니다. 그래디언트가 일정 값에 도달하면 종료해야합니다 (예 : 1e-4). – michaeltang
정규화를 시도 할 수 있습니다, 12 정규화, grad = (C-sigmoid (X * theta_new ')') * X + thread_new – michaeltang