包括内容如下图:

使用直接估计法,置信区间置信率的估计:

1.使用二项分布直接估计

$p(0.04<\hat{p}<0.06) = \sum_{0.04n\leq k \leq 0.06n}{n \choose k}0.05^{k}0.95^{n-k}$

low=ceil(n*0.04);%上取整
high=floor(n*0.06);%下取整
prob = 0;
for i=low:1:high
prob = prob+nchoosek(n,i)*(0.05^i)*(0.95^(n-i));
end

2.使用正态分布近似

$\mu = p = 0.05,\sigma^2 = \frac{p(1-p)}{n} = \frac{0.05*0.95}{n}$

normcdf(0.06,0.05,sigma/x(i)^0.5) - normcdf(0.04,0.05,sigma/x(i)^0.5)
warning off all;
clear all;clc;close all;
x=500:1:1500;
y = zeros(1,size(x,2));
y2 = zeros(1,size(x,2));
sigma = sqrt(0.05*0.95);
for i =1:size(x,2)
y(i) = adPredict(x(i));
y2(i) = normcdf(0.06,0.05,sigma/x(i)^0.5) - normcdf(0.04,0.05,sigma/x(i)^0.5);
end plot(x,y,'b-'); hold on;
plot(x,y2,'r-');
hold on;
x1=[500 1500];
y1=[0.85 0.85];
plot(x1,y1,'y-');

打印曲线:观测到,n=1000,差不多置信度会到达0.85

AUC概念及计算:

sklearn代码:sklearn中有现成方法,计算一组TPR,FPR,然后plot就可以;AUC也可以直接调用方法。

import numpy as np
import matplotlib.pyplot as plt from sklearn.linear_model import LogisticRegression
from sklearn import datasets
from sklearn.preprocessing import StandardScaler
from sklearn.metrics import roc_auc_score
from sklearn.metrics import roc_curve digits = datasets.load_digits() X, y = digits.data, digits.target
X = StandardScaler().fit_transform(X) # classify small against large digits
y = (y > 4).astype(np.int)
X_train = X[:-400]
y_train = y[:-400] X_test = X[-400:]
y_test = y[-400:] lrg = LogisticRegression(penalty='l1')
lrg.fit(X_train, y_train) y_test_prob=lrg.predict_proba(X_test)
P = np.where(y_test==1)[0].shape[0];
N = np.where(y_test==0)[0].shape[0]; dt = 10001
TPR = np.zeros((dt,1))
FPR = np.zeros((dt,1))
for i in range(dt):
y_test_p = y_test_prob[:,1]>=i*(1.0/(dt-1))
TP = np.where((y_test==1)&(y_test_p==True))[0].shape[0];
FN = P-TP;
FP = np.where((y_test==0)&(y_test_p==True))[0].shape[0];
TN = N - FP;
TPR[i]=TP*1.0/P
FPR[i]=FP*1.0/N plt.plot(FPR,TPR,color='black')
plt.plot(np.array([[0],[1]]),np.array([[0],[1]]),color='red')
plt.show() #use sklearn method
# fpr, tpr, thresholds = roc_curve(y_test,y_test_prob[:,1],pos_label=1)
# plt.plot(fpr,tpr,color='black')
# plt.plot(np.array([[0],[1]]),np.array([[0],[1]]),color='red')
# plt.show() rank = y_test_prob[:,1].argsort()
rank = rank.argsort()+1
auc = (sum(rank[np.where(y_test==1)[0]])-(P*1.0*(P+1)/2))/(P*N);
print auc
print roc_auc_score(y_test, y_test_prob[:,1])

click through rate prediction的更多相关文章

  1. 微软的一篇ctr预估的论文:Web-Scale Bayesian Click-Through Rate Prediction for Sponsored Search Advertising in Microsoft’s Bing Search Engine。

    周末看了一下这篇论文,觉得挺难的,后来想想是ICML的论文,也就明白为什么了. 先简单记录下来,以后会继续添加内容. 主要参考了论文Web-Scale Bayesian Click-Through R ...

  2. 【论文笔记】用反事实推断方法缓解标题党内容对推荐系统的影响 Click can be Cheating: Counterfactual Recommendation for Mitigating Clickbait Issue

    Click can be Cheating: Counterfactual Recommendation for Mitigating Clickbait Issue Authors: 王文杰,冯福利 ...

  3. 【点击模型学习笔记】Predicting Clicks_Estimating the Click-Through Rate for New Ads_MS_www2007

    概要: 微软研究院的人写的文章,提出用逻辑回归来解决ctr预估问题,是以后ctr的经典解决方式,经典文章. 详细内容: 名词: CPC -- cost per click CTR -- click t ...

  4. python命令行神器Click

    原文: http://www.lengirl.com/code/python-click.html Click 是用Python写的一个第三方模块,用于快速创建命令行.我们知道,Python内置了一个 ...

  5. Bayesian CTR Prediction for Bing

    Microsoft published a paper in ICML 2009 named ‘Web-Scale Bayesian Click-Through Rate Prediction for ...

  6. 【python】命令行神器 Click 简明笔记

    全文拷贝自 命令行神器 Click 简明笔记 Click Click 是用 Python 写的一个第三方模块,用于快速创建命令行.我们知道,Python 内置了一个 Argparse 的标准库用于创建 ...

  7. 命令行神器 Click 简明笔记

    Click 是用 Python 写的一个第三方模块,用于快速创建命令行.我们知道,Python 内置了一个 Argparse 的标准库用于创建命令行,但使用起来有些繁琐,Click 相比于 Argpa ...

  8. Andrew 机器学习课程笔记

    Andrew 机器学习课程笔记 完成 Andrew 的课程结束至今已有一段时间,课程介绍深入浅出,很好的解释了模型的基本原理以及应用.在我看来这是个很好的入门视频,他老人家现在又出了一门 deep l ...

  9. 主流CTR预估模型的演化及对比

    https://zhuanlan.zhihu.com/p/35465875 学习和预测用户的反馈对于个性化推荐.信息检索和在线广告等领域都有着极其重要的作用.在这些领域,用户的反馈行为包括点击.收藏. ...

随机推荐

  1. SQL Server 查看数据库空间分配情况的 2 种方法

    方法 1. sys.dm_db_file_space_usage. 方法 2. sys.dm_db_session_space_usage. ----------------------------- ...

  2. Oracle EBS-SQL (INV-10):检查库存接口.sql

    /*检查库存接口表*/ select msi.segment1                            项目编码, msi.description                     ...

  3. 一步一步学python(五) -条件 循环和其他语句

    1.print 使用逗号输出 - 打印多个表达式也是可行的,但要用逗号隔开 >>> print 'chentongxin',23 SyntaxError: invalid synta ...

  4. select自动选中

    //筛选 var typeid = "<!--{$typeid}-->"; var bigclassid = "<!--{$bigclassid}--& ...

  5. 【思考题】CSDN第四届在线编程大赛2014初赛:带通配符的数

    题目要求: 输入参数:参数A,含有任意个数的?的数值字符串,如:12?4,?代表一位任意数                     参数B,不含?的数值字符串,长度与参数A一致 输出结果:参数A比参数 ...

  6. 电子科大POJ "a^b"

    a ^ b Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) C-sources: ...

  7. BootStrap框架写的致敬乔布斯的网页

    http://codepen.io/Gabyler/pen/oxjRYj <div class="container"> <div class="jum ...

  8. hdu 5510 Bazinga(暴力)

    Problem Description Ladies and gentlemen, please sit up straight. Don't tilt your head. I'm serious. ...

  9. 卸载mysql残留

    一.在控制面板中查看是否有mysql,有则进行卸载.或执行同样版本号的mysql安装文件,选择"remove"进行卸载. 二.卸载mysql后其服务仍在,解决的方法: 点击&quo ...

  10. 项目总结——SqlParameter的参数设置长度(size属性)

    看到很多朋友在实例化SqlParameter时,通常都没有指定参数的长度就直接给参数赋值了.就像下面的写法: new SqlParameter("@address", SqlDbT ...