包括内容如下图:

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

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. Change the ball--hdu2277

    Change the ball Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

  2. 进程外Session和进程内Session存储

  3. 关于网络协议和socket编程基本概念

    TCP协议可以说已经是IT人耳熟能详的协议,最近在学习socket网络编程时后重新温习一下这个协议,针对一些问题做了一些总结,很多理解可能还不是很准确. 1. 协议是什么?所谓的各种网络协议无非是一种 ...

  4. uva540 Team Queue by sixleaves

    这道题目.主要是对队列的灵活应用.其实就是一道模拟题目,只要你洞察出题目的本质就十分简单.题目意思大体是有多组测试数据,每组的一开始是一个数字t,代表一共有多少的团队,接着是t行输入,每一行都由一个数 ...

  5. javascript第十四课,方法的扩展prototype

    所谓扩展方法就是,在原函数的基础上我们往对象里面添加一些自己需要的方法,例如: string对象 string.prototype.checkEmail=function(){ //方法体 //在这里 ...

  6. 最新的Android SDK安装攻略(动作要快,来晚就失效了)

    Android的环境搭建好折腾,光是下载Android SDK就折腾了好几天, 直接连接,速度接近于0,一行行红色的refused, 然后找软件翻*墙成功(不推荐,软件可能有后门) 但是...速度比老 ...

  7. Spring Http Invoker

    配置例如以下: ①web.xml配置 <servlet> <servlet-name>remote</servlet-name> <servlet-class ...

  8. UIPageViewController跳跃切换的问题

    使用的是XHScrollMenu和UIPageViewController来构建5个页面: ViewController1, ViewController2, ViewController3, Vie ...

  9. Oracle日志文件常用操作

    Oracle关于日志文件基本操作1.查询系统使用的是哪一组日志文件:select * from v$log; 2.查询正在使用的组所对应的日志文件:select * from v$logfile; 3 ...

  10. 用Teleport Ultra下载网站全部页面 爬虫

    测试case,就是把Commons-FileUpload 的API下载来   上网查的时候我才发现这是一个由很多页面组成的网站,下载起来很麻烦.   怎么办呢?呵呵,一定是有办法的.Teleport ...