官术网_书友最值得收藏!

The cost function

The cost function is a metric that determines how well or poorly a machine learning algorithm performed with regards to the actual training output and the predicted output. If you remember linear regression, where the sum of squares of errors was used as the loss function, that is, . This works better in a convex curve, but in the case of classification, the curve is non convex; as a result, the gradient descent doesn't work well and doesn't tend to global optimum. Therefore, we use cross-entropy loss which fits better in classification tasks as the cost function.

Cross entropy as loss function (for input data), that is, , where C refers to different output classes.
Thus, cost function = Average cross entropy loss (for the whole dataset), that is, .

In case of binary logistic regression, output classes are only two, that is, 0 and 1, since the sum of class values will always be 1. Therefore (for input data), if one class is , the other will be . Similarly, since the probability of class is (prediction), then the probability of the other class, that is, , will be .

Therefore, the loss function modifies to , where:

  • If , that is, = - . Therefore, to minimize , should be large, that is, closer to 1.

  • If , that is, = - . Therefore, to minimize , should be small, that is, closer to 0.

Loss function applies to a single example whereas cost function applies on the whole training lot. Thus, the cost function for this case will be:

主站蜘蛛池模板: 九江市| 南投市| 灵丘县| 衡阳县| 青神县| 道孚县| 溧水县| 古浪县| 安岳县| 庆云县| 宿松县| 和政县| 富阳市| 怀远县| 施秉县| 奉化市| 桐庐县| 汝阳县| 黄石市| 尼玛县| 富锦市| 呼和浩特市| 文水县| 区。| 和顺县| 徐州市| 城固县| 宾川县| 黄平县| 镇赉县| 运城市| 威信县| 衡阳县| 漳州市| 牟定县| 巴东县| 库伦旗| 宽城| 理塘县| 万安县| 馆陶县|