MachineLearningpart3--Logisticregression
 
Classification
 
Toattemptclassification,onemethodistouselinearregressionandmapallpredictionsgreaterthan0.5asa1andalllessthan0.5asa0.However,thismethoddoesn'tworkwellbecauseclassificationisnotactuallyalinearfunction.
为了尝试分类,一种方法是使用线性回归,并将所有大于0.5的预测值映射为1,所有小于0.5的预测值映射为0。然而,这种方法效果并不好,因为分类实际上不是一个线性函数。
 
Theclassificationproblemisjustliketheregressionproblem,exceptthatthevalueswenowwanttopredicttakeononlyasmallnumberofdiscretevalues.Fornow,wewillfocusonthebinaryclassificationprobleminwhichycantakeononlytwovalues,0and1.(Mostofwhatwesayherewillalsogeneralizetothemultiple-classcase.)Forinstance,ifwearetryingtobuildaspamclassifierforemail,thenmaybesomefeaturesofapieceofemail,andymaybe1ifitisapieceofspammail,and0otherwise.Hence,y∈{0,1}.0isalsocalledthenegativeclass,and1thepositiveclass,andtheyaresometimesalsodenotedbythesymbols“-”and“+.”Given,thecorrespondingisalsocalledthelabelforthetrainingexample.
分类问题就像回归问题一样,只是我们现在要预测的值只具有少量的离散值。现在,我们将重点讨论二元分类问题,在这个问题中,y只能有两个值,即0和1。(我们在这里说的大部分内容也可以推广到多类情况。)例如,如果我们试图建立一个电子邮件的垃圾邮件分类器,那么可能是一封邮件的一些特征,如果是一封垃圾邮件,y可能是1,否则是0。因此,y∈{0,1}。0也被称为负类,1称为正类,它们有时也用符号"-"和"+"来表示。给定,相应的也被称为训练实例的标签。
 
HypothesisRepresentation
Wecouldapproachtheclassificationproblemignoringthefactthatyisdiscrete-valued,anduseouroldlinearregressionalgorithmtotrytopredictygivenx.However,itiseasytoconstructexampleswherethismethodperformsverypoorly.Intuitively,italsodoesn’tmakesenseforhθ​(x)totakevalueslargerthan1orsmallerthan0whenweknowthaty{0,1}.Tofixthis,let’schangetheformforourhypotheseshθ​(x)tosatisfy0≤hθ​(x)≤1.ThisisaccomplishedbypluggingintotheLogisticFunction.