We will use Logistic Regression to recognize the number 1-10.
Loading data,Plotting data.as the picture below:
Vectorizing regularized logistic regression
Then learn the theta:
Predicting:
It is important to understand the final max function ,if you make your data which you want to predict by rows, then you should remember ,like the max function in the picture above ,when finished sigmoid function inside of max function,the result matrix owns ten columns ,which means that every column shows the probability of your data witch you want to predict might be .i.e.the second column show the probability of your data might be 1(note: the first column represent 10).
After get the result Matrix,the max function return the biggest number of each row ,also say the biggest probabilities.