Commit 5bfa0f50 authored by 郭羽's avatar 郭羽

ctr 平滑

parent 0e345a29
...@@ -229,13 +229,13 @@ def wilson_ctr(num_pv, num_click): ...@@ -229,13 +229,13 @@ def wilson_ctr(num_pv, num_click):
num_pv = float(num_pv) num_pv = float(num_pv)
num_click = float(num_click) num_click = float(num_click)
if num_pv * num_click == 0 or num_pv < num_click: if num_pv * num_click == 0 or num_pv < num_click:
return 0 return 0.0
z = 1.96; z = 1.96;
n = num_pv; n = num_pv;
p = num_click / num_pv; p = num_click / num_pv;
score = (p + z*z/(2*n) - z*math.sqrt((p*(1.0 - p) + z*z /(4.0*n))/n)) / (1.0 + z*z/n); score = (p + z*z/(2*n) - z*math.sqrt((p*(1.0 - p) + z*z /(4.0*n))/n)) / (1.0 + z*z/n);
return score; return float(score);
def addUserFeatures(samples,dataVocab,multiVocab): def addUserFeatures(samples,dataVocab,multiVocab):
dataVocab["userid"] = collectColumnToVocab(samples, "userid") dataVocab["userid"] = collectColumnToVocab(samples, "userid")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment