Title: Programming to achieve rate regression, data set given.
Emmm, there are few datasets, I'm using Newton's iteration. Also given in the formula book, the proof is not very complicated, omitted.
x = Load ("Input.txt");
y = Load ("output.txt");
theta = Zeros (3, 1);
m = Size (x, 1);
x = [x, ones (Size (x, 1), 1)];
%y
for i = 0:10 first
= Zeros (3, 1);
Second = zeros (3, 3);
For j = 1:m
xx = (x (j,:)) ';
First = First-xx * (Y (j, 1)-(exp (theta ' * xx)/(1 + exp (theta ' * xx))));
Second = second + xx * xx ' * (exp (theta ' * xx)/((1 + exp (theta ' * xx)) * (1 + exp (theta ' * xx))));
End
theta = THETA-INV (second) * FIRST;
End for
i = 1:m
if y (i) = = 1
plot (x (I, 1), X (I, 2), ' X ');
Hold on;
else
plot (x (I, 1), X (I, 2), ' O ');
Hold on;
End
End
% Three paragraphs not original, I paste myself from http://blog.csdn.net/icefire_tyh/article/details/52068844
% To verify that my results are the same as the big Guy's.
%ply =-(0.1 * THETA (1) + theta (3))/theta (2);
%pry =-(0.9 * THETA (1) + theta (3))/theta (2);
%line ([0.1 0.9], [ply pry]);