永利集团304com:逻辑回归

多类型分类(Multiclass Classification)

在多门类分类难点中,大家的练习聚焦有个五个项目,那时能够动用一对多的分类思想将多品类分类难题转化为二元分类难点,该方法也称为一对多分类方法。

永利集团304com 1

大家分别令y=1,y=2和y=3分别代表图中的三角形、矩形和叉。

永利集团304com 2

左数率先个图y=1标记为正向类,则其余的就为负向类,那时大家就能够画出图中的直线作为边界,则记借使函数为hθ,由此及彼,第一个和第七个图的只要函数可个别记为hθ,hθ。

因此,我们能够将假设函数hθ记为:hθ = p,在那之中i=1,2,3,…

最后,大家分别运维hθ,i=1,2,3,…,选出让hθ的值最大的i,那时大家就挑选出了最佳的比如函数,即最棒的分类器。

分类难点(Classification)

在分拣难点中,我们尝试预测离散值输出,举例:判定一封电子邮件是不是为垃圾邮件、判定二遍在线交易是不是为棍骗和推断肿瘤是还是不是为恶性肿瘤等。

咱们先从二元分类难题(即预测结果为0和1)开端商量。大家就要预测的因变量y的取值分为两类:当y=1时,大家将其标识为正向类(Positive
Class);当y=0时,大家将其标识为负向类(Negative Class)。

进而,因变量y可用数学符号记为:y∈{0, 1},当中0表示负向类,1象征正向类。

今昔,大家再来回看一下事先的瘤子预测那几个例子。即使大家有如下数据集,大家依据此前学习的线性回归的知识,能够用一条直线来扶助大家预测肿瘤是不是为劣质肿瘤。

永利集团304com 3

根据那条直线,大家得以将分类器的出口阀值设置为0.5,即:

永利集团304com 4

依据上述操作,数据集右边的数码都为正向类,左侧的数额都为负向类。

这时候,大家延长数据集的横轴并累加多个陶冶多少。

永利集团304com 5

依附此前的推断,数据聚集存在某二个值使得即便函数h的值恰好为阀值。当数码聚焦的值抢先那几个一定的值时,大家皆可判别这几个肿瘤为良性;反之,我们皆可看清这一个肿瘤为劣质。

永利集团304com 6

永利集团304com,那正是说大家就可以看清这么些新增的教练多少的输出值为1,即为良性肿瘤吗?那本来是不可能的,难道大家以为肿瘤越大其越为良性?因而,在这几个一定的例证中,大家利用线性回归来进展预测分明是八个不胜不好的做法。

除开,大家在分拣难点中动用线性回归还有大概会产出三个珠璧交辉的场景。家喻户晓,在分拣难题中因变量y∈{0,
1}。若我们应用线性回归,则大家的比如函数hθ恐怕会冒出hθ﹥1或许hθ
﹤0的动静;若大家运用就要学习的逻辑回归,则我们的举个例子函数hθ其取值范围为0
≤ hθ ≤ 1。

Question:Which of the following statements is true?A. If linear
regression doesn’t work on a classification task as in the previous
example shown in the video, applying feature scaling may help.B. If the
training set satisfies 0 ≤ y ≤ 1 for every training example , y, then
linear regression’s prediction will also satisfy 0 ≤ hθ ≤ 1 for all
values of x.C. If there is a feature x that perfectly predicts y, i.e.
if y = 1 where x ≥ c and y = 0 whenever x ﹤c (for some constant c),
then linear regression will obtain zero classification error.D. None of
the above statements are true.

综述,大家简单选出D这几个正确答案。

补给笔记
填补笔记
Multiclass Classification: One-vs-all

Now we will approach the classification of data when we have more than
two categories. Instead of y = {0,1} we will expand our definition so
that y = {0,1…n}.

Since y = {0,1…n}, we divide our problem into n+1 (+1 because the
index starts at 0) binary classification problems; in each one, we
predict the probability that ‘y’ is a member of one of our classes.

永利集团304com 7

We are basically choosing one class and then lumping all the others into
a single second class. We do this repeatedly, applying binary logistic
regression to each case, and then use the hypothesis that returned the
highest value as our prediction.

The following image shows how one could classify 3 classes:

永利集团304com 8

To summarize:

Train a logistic regression classifier hθ for each class to predict the
probability that y = i .

To make a prediction on a new x, pick the class that maximizes hθ

Classification

To attempt classification, one method is to use linear regression and
map all predictions greater than 0.5 as a 1 and all less than 0.5 as a

  1. However, this method doesn’t work well because classification is not
    actually a linear function.

The classification problem is just like the regression problem, except
that the values we now want to predict take on only a small number of
discrete values. For now, we will focus on the binary classification
problem
in which y can take on only two values, 0 and 1. (Most of what
we say here will also generalize to the multiple-class case.) For
instance, if we are trying to build a spam classifier for email, then x
may be some features of a piece of email, and y may be 1 if it is a
piece of spam mail, and 0 otherwise. Hence, y∈{0,1}. 0 is also called
the negative class, and 1 the positive class, and they are sometimes
also denoted by the symbols “-” and “+.” Given x, the corresponding y is
also called the label for the training example.

分拣难点建立模型(Hypothesis Representation)

后面,我们已经介绍部分有关逻辑回归的学问,现在大家初始正式学习逻辑回归。

前边我们介绍过逻辑回归模型其函数值始终在0~1之间,由此大家付出其数学表明式为:hθ,在那之中g代表逻辑函数,其表明式为:

永利集团304com 9

其函数图为:

永利集团304com 10

该数学表明式中的 z = θTX,在那之中X为特征向量。因而,大家可将表明式改写成:

永利集团304com 11

有关逻辑函数hθ的函数值大家得以知道为在自变量x和参数θ分别获得某些值的动静下y=0照旧y=1的可能率,即hθ
= P或然hθ = P。

是因为逻辑回归模型其值非1即0,大家可得如下表明式: hθ = P + hθ = P = 1

据此,大家能够依据上述表明式在已知y=0的概率下,可求得y=1的可能率。

增加补充笔记

发表评论

电子邮件地址不会被公开。 必填项已用*标注