Implement Logistic Regression Classifier with Matlab
Logistic Regression classifier is a linear classifier, roughly of the form P(y|x,w) = sigmoid(x.w) (as compared to sign(x.w) in linear classifier).
The cost function is defined as follows:
where S() - the sigmoid function,theta - current logistic regression parameter,lambda - the regularization term. The code implementation for this representation is straightforward.
One common approach to minimize the cost function is gradient descent.
Based on these helper functions implemented, the training phase could be simplified as:
1. randomly initialize theta
2. call minimize() on the cost function with the initial theta.
3. update theta the finally returned value from minimize()
The prediction function could hence be written as:
No comments:
Post a Comment