ctr_metric_bundle

paddle.static. ctr_metric_bundle ( input, label, ins_tag_weight=None ) [source]

ctr related metric layer

This function help compute the ctr related metrics: RMSE, MAE, predicted_ctr, q_value. To compute the final values of these metrics, we should do following computations using total instance number: MAE = local_abserr / instance number RMSE = sqrt(local_sqrerr / instance number) predicted_ctr = local_prob / instance number q = local_q / instance number Note that if you are doing distribute job, you should all reduce these metrics and instance number first

Parameters
  • input (Tensor) – A floating-point 2D Tensor, values are in the range [0, 1]. Each row is sorted in descending order. This input should be the output of topk. Typically, this Tensor indicates the probability of each label.

  • label (Tensor) – A 2D int Tensor indicating the label of the training data. The height is batch size and width is always 1.

  • ins_tag_weight (Tensor) – A 2D int Tensor indicating the ins_tag_weight of the training data. 1 means real data, 0 means fake data. A LoDTensor or Tensor with type float32,float64.

Returns

Local sum of squared error local_abserr(Tensor): Local sum of abs error local_prob(Tensor): Local sum of predicted ctr local_q(Tensor): Local sum of q value local_pos_num (Tensor): Local number of positive examples local_ins_num (Tensor): Local number of instances

Return type

local_sqrerr(Tensor)

Examples

>>> import paddle
>>> paddle.enable_static()
>>> data = paddle.static.data(name="data", shape=[-1, 32], dtype="float32")
>>> label = paddle.static.data(name="label", shape=[-1, 1], dtype="int32")
>>> predict = paddle.nn.functional.sigmoid(paddle.static.nn.fc(x=data, size=1))
>>> auc_out = paddle.static.ctr_metric_bundle(input=predict, label=label)
>>> import paddle
>>> paddle.enable_static()
>>> data = paddle.static.data(name="data", shape=[-1, 32], dtype="float32")
>>> label = paddle.static.data(name="label", shape=[-1, 1], dtype="int32")
>>> predict = paddle.nn.functional.sigmoid(paddle.static.nn.fc(x=data, size=1))
>>> ins_tag_weight = paddle.static.data(name='ins_tag_weight', shape=[-1, 1], lod_level=0, dtype='int64')
>>> auc_out = paddle.static.ctr_metric_bundle(input=predict, label=label, ins_tag_weight=ins_tag_weight)