[{"data":1,"prerenderedAt":1256},["ShallowReactive",2],{"lang-switch-post-\u002Fen\u002Fplaylists\u002Fmachine-learning-specialization\u002Fw3-lab05-cost-function":3,"post-en-machine-learning-specialization-w3-lab05-cost-function":4},"\u002Fplaylists\u002Fmachine-learning-specialization\u002Fw3-lab05-cost-function",{"id":5,"title":6,"body":7,"cover":1239,"date":1240,"description":1241,"extension":1242,"meta":1243,"navigation":1244,"order":1245,"path":1246,"playlist":1247,"seo":1248,"status":1249,"stem":1250,"tags":1251,"__hash__":1255},"posts\u002Fen\u002Fplaylists\u002Fmachine-learning-specialization\u002Fw3-lab05-cost-function.md","From Loss to Cost: Summing Up Everyone's Error",{"type":8,"value":9,"toc":1232},"minimark",[10,32,37,878,889,893,957,1014,1018,1033,1048,1064,1067,1078,1093,1097,1145,1149,1178,1193,1205,1228],[11,12,13,18,19,23,24,27,28,31],"p",{},[14,15,17],"a",{"href":16},"\u002Fen\u002Fplaylists\u002Fmachine-learning-specialization\u002Fw3-lab04-logistic-loss","The logistic loss"," measures ",[20,21,22],"strong",{},"one"," example's error. The course already draws this distinction: ",[20,25,26],{},"loss"," is about a single example, ",[20,29,30],{},"cost"," is the loss summed (averaged) over the entire training set. Cost is what gradient descent minimizes.",[33,34,36],"h2",{"id":35},"the-full-cost-function","The full cost function",[11,38,39],{},[40,41,44,255],"span",{"className":42},[43],"katex",[40,45,48],{"className":46},[47],"katex-mathml",[49,50,52],"math",{"xmlns":51},"http:\u002F\u002Fwww.w3.org\u002F1998\u002FMath\u002FMathML",[53,54,55,250],"semantics",{},[56,57,58,62,67,71,75,78,81,84,94,119],"mrow",{},[59,60,61],"mi",{},"J",[63,64,66],"mo",{"stretchy":65},"false","(",[59,68,70],{"mathvariant":69},"bold","w",[63,72,74],{"separator":73},"true",",",[59,76,77],{},"b",[63,79,80],{"stretchy":65},")",[63,82,83],{},"=",[85,86,87,91],"mfrac",{},[88,89,90],"mn",{},"1",[59,92,93],{},"m",[95,96,97,100,110],"msubsup",{},[63,98,99],{},"∑",[56,101,102,105,107],{},[59,103,104],{},"i",[63,106,83],{},[88,108,109],{},"0",[56,111,112,114,117],{},[59,113,93],{},[63,115,116],{},"−",[88,118,90],{},[56,120,121,124,126,140,143,146,183,185,187,189,191,203,205,207,209,247],{},[63,122,123],{"fence":73},"[",[63,125,116],{},[127,128,129,132],"msup",{},[59,130,131],{},"y",[56,133,134,136,138],{},[63,135,66],{"stretchy":65},[59,137,104],{},[63,139,80],{"stretchy":65},[59,141,142],{},"log",[63,144,145],{},"⁡",[56,147,148,150,164,166,179,181],{},[63,149,66],{"fence":73},[151,152,153,156],"msub",{},[59,154,155],{},"f",[56,157,158,160,162],{},[59,159,70],{"mathvariant":69},[63,161,74],{"separator":73},[59,163,77],{},[63,165,66],{"stretchy":65},[127,167,168,171],{},[59,169,170],{"mathvariant":69},"x",[56,172,173,175,177],{},[63,174,66],{"stretchy":65},[59,176,104],{},[63,178,80],{"stretchy":65},[63,180,80],{"stretchy":65},[63,182,80],{"fence":73},[63,184,116],{},[63,186,66],{"stretchy":65},[88,188,90],{},[63,190,116],{},[127,192,193,195],{},[59,194,131],{},[56,196,197,199,201],{},[63,198,66],{"stretchy":65},[59,200,104],{},[63,202,80],{"stretchy":65},[63,204,80],{"stretchy":65},[59,206,142],{},[63,208,145],{},[56,210,211,213,215,217,229,231,243,245],{},[63,212,66],{"fence":73},[88,214,90],{},[63,216,116],{},[151,218,219,221],{},[59,220,155],{},[56,222,223,225,227],{},[59,224,70],{"mathvariant":69},[63,226,74],{"separator":73},[59,228,77],{},[63,230,66],{"stretchy":65},[127,232,233,235],{},[59,234,170],{"mathvariant":69},[56,236,237,239,241],{},[63,238,66],{"stretchy":65},[59,240,104],{},[63,242,80],{"stretchy":65},[63,244,80],{"stretchy":65},[63,246,80],{"fence":73},[63,248,249],{"fence":73},"]",[251,252,254],"annotation",{"encoding":253},"application\u002Fx-tex","J(\\mathbf{w},b) = \\frac{1}{m}\\sum_{i=0}^{m-1}\\left[-y^{(i)}\\log\\left(f_{\\mathbf{w},b}(\\mathbf{x}^{(i)})\\right) - (1-y^{(i)})\\log\\left(1-f_{\\mathbf{w},b}(\\mathbf{x}^{(i)})\\right)\\right]",[40,256,259,310],{"className":257,"ariaHidden":73},[258],"katex-html",[40,260,263,268,274,278,283,287,292,295,299,303,307],{"className":261},[262],"base",[40,264],{"className":265,"style":267},[266],"strut","height:1em;vertical-align:-0.25em;",[40,269,61],{"className":270,"style":273},[271,272],"mord","mathnormal","margin-right:0.0962em;",[40,275,66],{"className":276},[277],"mopen",[40,279,70],{"className":280,"style":282},[271,281],"mathbf","margin-right:0.016em;",[40,284,74],{"className":285},[286],"mpunct",[40,288],{"className":289,"style":291},[290],"mspace","margin-right:0.1667em;",[40,293,77],{"className":294},[271,272],[40,296,80],{"className":297},[298],"mclose",[40,300],{"className":301,"style":302},[290],"margin-right:0.2778em;",[40,304,83],{"className":305},[306],"mrel",[40,308],{"className":309,"style":302},[290],[40,311,313,317,405,408,488,491],{"className":312},[262],[40,314],{"className":315,"style":316},[266],"height:1.304em;vertical-align:-0.35em;",[40,318,320,324,402],{"className":319},[271],[40,321],{"className":322},[277,323],"nulldelimiter",[40,325,327],{"className":326},[85],[40,328,332,393],{"className":329},[330,331],"vlist-t","vlist-t2",[40,333,336,388],{"className":334},[335],"vlist-r",[40,337,341,362,373],{"className":338,"style":340},[339],"vlist","height:0.8451em;",[40,342,344,349],{"style":343},"top:-2.655em;",[40,345],{"className":346,"style":348},[347],"pstrut","height:3em;",[40,350,356],{"className":351},[352,353,354,355],"sizing","reset-size6","size3","mtight",[40,357,359],{"className":358},[271,355],[40,360,93],{"className":361},[271,272,355],[40,363,365,368],{"style":364},"top:-3.23em;",[40,366],{"className":367,"style":348},[347],[40,369],{"className":370,"style":372},[371],"frac-line","border-bottom-width:0.04em;",[40,374,376,379],{"style":375},"top:-3.394em;",[40,377],{"className":378,"style":348},[347],[40,380,382],{"className":381},[352,353,354,355],[40,383,385],{"className":384},[271,355],[40,386,90],{"className":387},[271,355],[40,389,392],{"className":390},[391],"vlist-s","​",[40,394,396],{"className":395},[335],[40,397,400],{"className":398,"style":399},[339],"height:0.345em;",[40,401],{},[40,403],{"className":404},[298,323],[40,406],{"className":407,"style":291},[290],[40,409,412,418],{"className":410},[411],"mop",[40,413,99],{"className":414,"style":417},[411,415,416],"op-symbol","small-op","position:relative;top:0em;",[40,419,422],{"className":420},[421],"msupsub",[40,423,425,479],{"className":424},[330,331],[40,426,428,476],{"className":427},[335],[40,429,432,454],{"className":430,"style":431},[339],"height:0.954em;",[40,433,435,439],{"style":434},"top:-2.4003em;margin-left:0em;margin-right:0.05em;",[40,436],{"className":437,"style":438},[347],"height:2.7em;",[40,440,442],{"className":441},[352,353,354,355],[40,443,445,448,451],{"className":444},[271,355],[40,446,104],{"className":447},[271,272,355],[40,449,83],{"className":450},[306,355],[40,452,109],{"className":453},[271,355],[40,455,457,460],{"style":456},"top:-3.2029em;margin-right:0.05em;",[40,458],{"className":459,"style":438},[347],[40,461,463],{"className":462},[352,353,354,355],[40,464,466,469,473],{"className":465},[271,355],[40,467,93],{"className":468},[271,272,355],[40,470,116],{"className":471},[472,355],"mbin",[40,474,90],{"className":475},[271,355],[40,477,392],{"className":478},[391],[40,480,482],{"className":481},[335],[40,483,486],{"className":484,"style":485},[339],"height:0.2997em;",[40,487],{},[40,489],{"className":490,"style":291},[290],[40,492,495,505,508,549,552,560,563,675,679,682,685,688,691,694,697,700,738,741,744,749,752,872],{"className":493},[494],"minner",[40,496,500],{"className":497,"style":499},[277,498],"delimcenter","top:0em;",[40,501,123],{"className":502},[503,504],"delimsizing","size1",[40,506,116],{"className":507},[271],[40,509,511,515],{"className":510},[271],[40,512,131],{"className":513,"style":514},[271,272],"margin-right:0.0359em;",[40,516,518],{"className":517},[421],[40,519,521],{"className":520},[330],[40,522,524],{"className":523},[335],[40,525,528],{"className":526,"style":527},[339],"height:0.888em;",[40,529,531,534],{"style":530},"top:-3.063em;margin-right:0.05em;",[40,532],{"className":533,"style":438},[347],[40,535,537],{"className":536},[352,353,354,355],[40,538,540,543,546],{"className":539},[271,355],[40,541,66],{"className":542},[277,355],[40,544,104],{"className":545},[271,272,355],[40,547,80],{"className":548},[298,355],[40,550],{"className":551,"style":291},[290],[40,553,555,556],{"className":554},[411],"lo",[40,557,559],{"style":558},"margin-right:0.0139em;","g",[40,561],{"className":562,"style":291},[290],[40,564,566,572,625,628,666,669],{"className":565},[494],[40,567,569],{"className":568,"style":499},[277,498],[40,570,66],{"className":571},[503,504],[40,573,575,579],{"className":574},[271],[40,576,155],{"className":577,"style":578},[271,272],"margin-right:0.1076em;",[40,580,582],{"className":581},[421],[40,583,585,616],{"className":584},[330,331],[40,586,588,613],{"className":587},[335],[40,589,592],{"className":590,"style":591},[339],"height:0.3361em;",[40,593,595,598],{"style":594},"top:-2.55em;margin-left:-0.1076em;margin-right:0.05em;",[40,596],{"className":597,"style":438},[347],[40,599,601],{"className":600},[352,353,354,355],[40,602,604,607,610],{"className":603},[271,355],[40,605,70],{"className":606,"style":282},[271,281,355],[40,608,74],{"className":609},[286,355],[40,611,77],{"className":612},[271,272,355],[40,614,392],{"className":615},[391],[40,617,619],{"className":618},[335],[40,620,623],{"className":621,"style":622},[339],"height:0.2861em;",[40,624],{},[40,626,66],{"className":627},[277],[40,629,631,634],{"className":630},[271],[40,632,170],{"className":633},[271,281],[40,635,637],{"className":636},[421],[40,638,640],{"className":639},[330],[40,641,643],{"className":642},[335],[40,644,646],{"className":645,"style":527},[339],[40,647,648,651],{"style":530},[40,649],{"className":650,"style":438},[347],[40,652,654],{"className":653},[352,353,354,355],[40,655,657,660,663],{"className":656},[271,355],[40,658,66],{"className":659},[277,355],[40,661,104],{"className":662},[271,272,355],[40,664,80],{"className":665},[298,355],[40,667,80],{"className":668},[298],[40,670,672],{"className":671,"style":499},[298,498],[40,673,80],{"className":674},[503,504],[40,676],{"className":677,"style":678},[290],"margin-right:0.2222em;",[40,680,116],{"className":681},[472],[40,683],{"className":684,"style":678},[290],[40,686,66],{"className":687},[277],[40,689,90],{"className":690},[271],[40,692],{"className":693,"style":678},[290],[40,695,116],{"className":696},[472],[40,698],{"className":699,"style":678},[290],[40,701,703,706],{"className":702},[271],[40,704,131],{"className":705,"style":514},[271,272],[40,707,709],{"className":708},[421],[40,710,712],{"className":711},[330],[40,713,715],{"className":714},[335],[40,716,718],{"className":717,"style":527},[339],[40,719,720,723],{"style":530},[40,721],{"className":722,"style":438},[347],[40,724,726],{"className":725},[352,353,354,355],[40,727,729,732,735],{"className":728},[271,355],[40,730,66],{"className":731},[277,355],[40,733,104],{"className":734},[271,272,355],[40,736,80],{"className":737},[298,355],[40,739,80],{"className":740},[298],[40,742],{"className":743,"style":291},[290],[40,745,555,747],{"className":746},[411],[40,748,559],{"style":558},[40,750],{"className":751,"style":291},[290],[40,753,755,761,764,767,770,773,822,825,863,866],{"className":754},[494],[40,756,758],{"className":757,"style":499},[277,498],[40,759,66],{"className":760},[503,504],[40,762,90],{"className":763},[271],[40,765],{"className":766,"style":678},[290],[40,768,116],{"className":769},[472],[40,771],{"className":772,"style":678},[290],[40,774,776,779],{"className":775},[271],[40,777,155],{"className":778,"style":578},[271,272],[40,780,782],{"className":781},[421],[40,783,785,814],{"className":784},[330,331],[40,786,788,811],{"className":787},[335],[40,789,791],{"className":790,"style":591},[339],[40,792,793,796],{"style":594},[40,794],{"className":795,"style":438},[347],[40,797,799],{"className":798},[352,353,354,355],[40,800,802,805,808],{"className":801},[271,355],[40,803,70],{"className":804,"style":282},[271,281,355],[40,806,74],{"className":807},[286,355],[40,809,77],{"className":810},[271,272,355],[40,812,392],{"className":813},[391],[40,815,817],{"className":816},[335],[40,818,820],{"className":819,"style":622},[339],[40,821],{},[40,823,66],{"className":824},[277],[40,826,828,831],{"className":827},[271],[40,829,170],{"className":830},[271,281],[40,832,834],{"className":833},[421],[40,835,837],{"className":836},[330],[40,838,840],{"className":839},[335],[40,841,843],{"className":842,"style":527},[339],[40,844,845,848],{"style":530},[40,846],{"className":847,"style":438},[347],[40,849,851],{"className":850},[352,353,354,355],[40,852,854,857,860],{"className":853},[271,355],[40,855,66],{"className":856},[277,355],[40,858,104],{"className":859},[271,272,355],[40,861,80],{"className":862},[298,355],[40,864,80],{"className":865},[298],[40,867,869],{"className":868,"style":499},[298,498],[40,870,80],{"className":871},[503,504],[40,873,875],{"className":874,"style":499},[298,498],[40,876,249],{"className":877},[503,504],[11,879,880,881,884,885,888],{},"Looks complicated, but it's just ",[14,882,883],{"href":16},"one example's loss",", the same single-line formula from the last lab, sitting inside a sum divided by ",[886,887,93],"code",{},". The average loss across everyone.",[33,890,892],{"id":891},"the-code-line-by-line","The code, line by line",[894,895,900],"pre",{"className":896,"code":897,"language":898,"meta":899,"style":899},"language-python shiki shiki-themes github-light github-dark","def compute_cost_logistic(X, y, w, b):\n    m = X.shape[0]\n    cost = 0.0\n    for i in range(m):\n        z_i = np.dot(X[i],w) + b\n        f_wb_i = sigmoid(z_i)\n        cost +=  -y[i]*np.log(f_wb_i) - (1-y[i])*np.log(1-f_wb_i)\n    cost = cost \u002F m\n    return cost\n","python","",[886,901,902,909,915,921,927,933,939,945,951],{"__ignoreMap":899},[40,903,906],{"class":904,"line":905},"line",1,[40,907,908],{},"def compute_cost_logistic(X, y, w, b):\n",[40,910,912],{"class":904,"line":911},2,[40,913,914],{},"    m = X.shape[0]\n",[40,916,918],{"class":904,"line":917},3,[40,919,920],{},"    cost = 0.0\n",[40,922,924],{"class":904,"line":923},4,[40,925,926],{},"    for i in range(m):\n",[40,928,930],{"class":904,"line":929},5,[40,931,932],{},"        z_i = np.dot(X[i],w) + b\n",[40,934,936],{"class":904,"line":935},6,[40,937,938],{},"        f_wb_i = sigmoid(z_i)\n",[40,940,942],{"class":904,"line":941},7,[40,943,944],{},"        cost +=  -y[i]*np.log(f_wb_i) - (1-y[i])*np.log(1-f_wb_i)\n",[40,946,948],{"class":904,"line":947},8,[40,949,950],{},"    cost = cost \u002F m\n",[40,952,954],{"class":904,"line":953},9,[40,955,956],{},"    return cost\n",[958,959,960,967,977,992,998,1007],"ul",{},[961,962,963,966],"li",{},[886,964,965],{},"m = X.shape[0]",": how many examples are in the set.",[961,968,969,970,973,974,976],{},"the ",[886,971,972],{},"for"," loop walks through each patient ",[886,975,104],{},".",[961,978,979,982,983,987,988,991],{},[886,980,981],{},"z_i = np.dot(X[i],w) + b",": the linear part, ",[14,984,986],{"href":985},"\u002Fen\u002Fplaylists\u002Fmachine-learning-specialization\u002Fw3-lab03-decision-boundary","the same combination as always",", except now ",[886,989,990],{},"X[i]"," can hold several variables, so it's a dot product instead of a plain multiplication.",[961,993,994,997],{},[886,995,996],{},"f_wb_i = sigmoid(z_i)",": squash it into a probability.",[961,999,1000,1001,1003,1004,976],{},"the middle line adds that patient's loss to the running total ",[886,1002,30],{},", ",[14,1005,1006],{"href":16},"the same single-line formula from the last lab",[961,1008,1009,1010,1013],{},"at the end, ",[886,1011,1012],{},"cost \u002F m"," takes the average.",[33,1015,1017],{"id":1016},"testing-with-two-different-values-of-b","Testing with two different values of b",[11,1019,1020,1021,1024,1025,1028,1029,1032],{},"Same dataset as always, two candidate boundaries: ",[886,1022,1023],{},"b=-3"," and ",[886,1026,1027],{},"b=-4"," (keeping ",[886,1030,1031],{},"w=[1,1]"," fixed both times).",[894,1034,1036],{"className":896,"code":1035,"language":898,"meta":899,"style":899},"print(\"Cost with b = -3:\", compute_cost_logistic(X_train, y_train, np.array([1,1]), -3))\nprint(\"Cost with b = -4:\", compute_cost_logistic(X_train, y_train, np.array([1,1]), -4))\n",[886,1037,1038,1043],{"__ignoreMap":899},[40,1039,1040],{"class":904,"line":905},[40,1041,1042],{},"print(\"Cost with b = -3:\", compute_cost_logistic(X_train, y_train, np.array([1,1]), -3))\n",[40,1044,1045],{"class":904,"line":911},[40,1046,1047],{},"print(\"Cost with b = -4:\", compute_cost_logistic(X_train, y_train, np.array([1,1]), -4))\n",[1049,1050,1051],"blockquote",{},[11,1052,1053,1056,1057,1060,1061],{},[20,1054,1055],{},"Output:"," ",[886,1058,1059],{},"Cost with b = -3: 0.3669"," · ",[886,1062,1063],{},"Cost with b = -4: 0.5037",[11,1065,1066],{},"The cost already gives away which boundary is worse, before I need to look at any plot. But the plot confirms it:",[1068,1069],"classification-boundary-comparison-chart",{":boundaries":1070,":classes":1071,":points":1072,":x-max":1073,":x-min":109,":y-max":1073,":y-min":109,"negative-label":1074,"positive-label":1075,"x-label":1076,"y-label":1077},"[{\"w\":[1,1],\"bias\":-3,\"label\":\"b=-3 (cost 0.3669)\"},{\"w\":[1,1],\"bias\":-4,\"label\":\"b=-4 (cost 0.5037)\",\"dashed\":true}]","[-1,-1,-1,1,1,1]","[[0.5,1.5],[1,1],[1.5,0.5],[3,0.5],[2,2],[1,2.5]]","4","y=0","y=1","x0","x1",[11,1079,1080,1081,1083,1084,1086,1087,1089,1090,1092],{},"The ",[886,1082,1027],{}," line (dashed) shifts up and to the right relative to ",[886,1085,1023],{},", and in that shift it ends up putting two ",[886,1088,1075],{}," patients on the wrong side (below the line, predicted as ",[886,1091,109],{},"). Makes sense its cost is higher: a high cost is literally the model saying \"this boundary explains the data I saw worse than the other one\".",[33,1094,1096],{"id":1095},"wrapping-up","Wrapping up",[1098,1099,1100,1114],"table",{},[1101,1102,1103],"thead",{},[1104,1105,1106,1111],"tr",{},[1107,1108,1110],"th",{"align":1109},"left","What I already knew",[1107,1112,1113],{"align":1109},"What this lecture settled",[1115,1116,1117,1126,1137],"tbody",{},[1104,1118,1119,1123],{},[1120,1121,1122],"td",{"align":1109},"Loss measures one example's error",[1120,1124,1125],{"align":1109},"Cost is the average loss over the whole training set, that's what gets minimized",[1104,1127,1128,1131],{},[1120,1129,1130],{"align":1109},"The logistic loss formula, single line",[1120,1132,1133,1134,1136],{"align":1109},"That same code, inside a ",[886,1135,972],{}," loop with an average at the end, becomes the full cost function",[1104,1138,1139,1142],{},[1120,1140,1141],{"align":1109},"A worse boundary misclassifies more people",[1120,1143,1144],{"align":1109},"Cost measures that worsening numerically, before I even plot anything",[33,1146,1148],{"id":1147},"practical-application","Practical Application",[11,1150,1151,1152,1155,1156,1159,1160,1163,1164,1167,1168,1170,1171,1173,1174,1177],{},"I use the real two-variable model ",[14,1153,1154],{"href":985},"from the decision boundary lab"," (",[886,1157,1158],{},"worst concave points"," + ",[886,1161,1162],{},"worst perimeter",", both normalized), with weights ",[886,1165,1166],{},"w=[2.5494, 4.0739]"," learned via gradient descent, and compare the cost of the trained ",[886,1169,77],{}," against a deliberately worse ",[886,1172,77],{}," (shifted by ",[886,1175,1176],{},"+2","):",[894,1179,1181],{"className":896,"code":1180,"language":898,"meta":899,"style":899},"print(\"Cost with trained b:\", compute_cost_logistic(X_train_z, y_train, w, b))\nprint(\"Cost with b + 2:\", compute_cost_logistic(X_train_z, y_train, w, b + 2))\n",[886,1182,1183,1188],{"__ignoreMap":899},[40,1184,1185],{"class":904,"line":905},[40,1186,1187],{},"print(\"Cost with trained b:\", compute_cost_logistic(X_train_z, y_train, w, b))\n",[40,1189,1190],{"class":904,"line":911},[40,1191,1192],{},"print(\"Cost with b + 2:\", compute_cost_logistic(X_train_z, y_train, w, b + 2))\n",[1049,1194,1195],{},[11,1196,1197,1056,1199,1060,1202],{},[20,1198,1055],{},[886,1200,1201],{},"Cost with trained b: 0.1461",[886,1203,1204],{},"Cost with b + 2: 0.2391",[11,1206,1207,1208,1210,1211,1214,1215,1217,1218,1221,1222,1224,1225,1227],{},"The cost jumps by more than a third just from shifting the boundary by two units. And accuracy feels it in practice: with the trained ",[886,1209,77],{},", training accuracy is ",[886,1212,1213],{},"0.9319","; with the shifted ",[886,1216,77],{},", it drops to ",[886,1219,1220],{},"0.8989",". A \"close enough\" ",[886,1223,77],{}," (the boundary's direction, given by ",[886,1226,70],{},", stays the same) already costs 3 percentage points of accuracy, and the cost calls out exactly that worsening, in the exact form gradient descent sees it: as a bigger number, one it'll try to shrink again on the next steps.",[1229,1230,1231],"style",{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":899,"searchDepth":911,"depth":911,"links":1233},[1234,1235,1236,1237,1238],{"id":35,"depth":911,"text":36},{"id":891,"depth":911,"text":892},{"id":1016,"depth":911,"text":1017},{"id":1095,"depth":911,"text":1096},{"id":1147,"depth":911,"text":1148},null,"2026-09-04","Week 3, Lab 5: the logistic loss measures one patient's error. The cost sums that loss (averaged) over the whole training set into a single function, the one gradient descent actually minimizes. A real example shows how cost spots a worse boundary before I even look at the plot.","md",{},true,16,"\u002Fen\u002Fplaylists\u002Fmachine-learning-specialization\u002Fw3-lab05-cost-function","machine-learning-specialization",{"title":6,"description":1241},"published","en\u002Fplaylists\u002Fmachine-learning-specialization\u002Fw3-lab05-cost-function",[1252,1253,1254],"classification","logistic-regression","cost-function","CI7mNSawD3SLZq4woYYNJmd1TyWEn4UwYud_B_RQuWA",1788965100397]