Skip to content

Instantly share code, notes, and snippets.

@mronian
Last active September 28, 2015 06:34
Show Gist options
  • Save mronian/2903cf1c27e5ef42dbf0 to your computer and use it in GitHub Desktop.
Save mronian/2903cf1c27e5ef42dbf0 to your computer and use it in GitHub Desktop.
Q6b ML Assignment 2
data = importdata('breastCancer.csv',',');
[n,m] = size(data);
epsilon = 1e-1;
%x(1:n,1:m-1) = 0;
y(1:n,1:1) = 0;
a = 0.1;
%t(1:n,1:1) = 0;
w_old = zeros(m-1,1);
t = data(:,1);
x = data(:,2:m);
for i = 1:n
y(i,1) = 1.00/(1+exp(-(x(i,1:m-1)*w_old)));
end
deltaf = transpose(x)*(y-t);
disp(deltaf);
j=1;
while norm(deltaf)>epsilon && j<20
w_old = w_old-a*deltaf;
for i = 1:n
y(i,1) = 1.00/(1+exp(-(x(i,1:m-1)*w_old)));
end
deltaf = transpose(x)*(y-t);
j=j+1;
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment