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.
本文介绍了一种使用逻辑回归算法进行手写数字1到10识别的方法。通过加载并绘制数据集,实现向量化正则化的逻辑回归,并预测数据集中的数字。文章详细解释了如何通过最大概率确定最终预测结果。
1050

被折叠的 条评论
为什么被折叠?



