用户画像之数据质量管理

大家好,今天和大家分享一下用户画像数据质量管理这块的内容。数据质量管理这项工作的重要性不言而喻,所谓“garbage in,garbage out”,基础数据的质量性如果无法得到良好保障,后续的推荐、数据分析工作将会变得徒劳。

背景

在建好用户画像模型后,该数据模型成为了一个个落在数据仓库的表,数据仓库的开发人员通过通过调度任务,每天定时从各业务数据表和日志数据表抽取用户行为数据加工到用户画像相关表中。各种类型的标签每天加工的数据成百上千万条,数据分析人员不会每天对这些数据的质量进行核查,去发现每类标签的数量是否有异常情况,但是当应用的过程中使用异常数据将会导致分析结论的误差,那么如何高速、有效地对用户画像数据的质量进行管理?

方法

数据运营人员可以通过设定画像各业务表数据监控范围,当每天跑ETL出现异常变动时,通过统计每类标签的总量变动较大时,发送邮件让数据运营的人员接收,然后查找原因进行定位。

# -*- coding: utf-8 -*-impala_01 = ''' 删除临时表语句'''impala_02 = ''' 创建临时表,检查昨日运行产生的各类用户标签数量是否在合理范围内 ''' # 建表语句impala_03 = '''查询impala_02语句创建的临时表中的数据量'''import smtplibimport osimport datetimefrom impala.dbapi import connectfrom email.mime.multipart import MIMEMultipartfrom email.mime.text import MIMETextfrom email.header import Headerfrom email.mime.image import MIMEImageimport pyhs2impala_conn = pyhs2.connect(host='10.21.190.220', port=10086, authMechanism="PLAIN", user='zhaoht', password='yourpassword', database='wedw_dw')impala_cur = impala_conn.cursor()impala_cur.execute(impala_01)# 执行删除临时表的SQLimpala_cur.execute(impala_02)# 执行创建临时表的SQLtry: impala_cur.execute(impala_03) result_1 = impala_cur.fetchall() data_1 = list(result_1[0]) # 将元组数据列表化 data_1 = int(data_1.pop()) # 将列表数据转化为整数 except Exception: data_1 = 1impala_cur.close()impala_conn.close()sumdata = data_1 # 各标签加总为0正常if sumdata == 0 :# 如果各标签的数据量正常 则不用发送邮件passelse:# 当标签数据量出现异常时 自动发送邮件pwd = 'yourpassword' sender_mail = 'sender@mail.com' receiver = 'receiver@mail.com' mail_content = ''' 用户画像维护人员你好,gdw.persona_user_tag_relation_public表中昨日数据发生异常,各类标签数据统计如下:A类标签[3000000-3500000]:{} '''.format(data_1) mail_title = '用户个性化标签表异常数据预警邮件' date_str = datetime.datetime.strftime(datetime.date.today()-datetime.timedelta(days=1),'%m%d') msgRoot = MIMEMultipart('mixed') #实例化一个类 msgRoot['Subject'] = Header(mail_title, 'utf-8') msgRoot['From'] = sender_mail msgRoot['To'] = receiver msgRoot["Accept-Language"]="zh-CN" msgRoot["Accept-Charset"]="ISO-8859-1,utf-8" content = MIMEText(mail_content,'plain','utf-8') msgRoot.attach(content) smtp = smtplib.SMTP() smtp.set_debuglevel(1) smtp.connect('mail.guahao.com') smtp.login(sender_mail, pwd) #登录发件人邮箱 smtp.sendmail(sender_mail, receiver, msgRoot.as_string()) smtp.quit()


每一个HTML文档中,都有一个不可或缺的标签:<head>,在几乎所有的HTML文档里, 我们都可以看到类似下面这段代码:

html{color:#000;overflow-y:scroll;overflow:-moz-scrollbars}
body,button,input,select,textarea{font-size:12px;font-family:Arial,sans-serif}
h1,h2,h3,h4,h5,h6{font-size:100%}
em{font-style:normal}
small{font-size:12px}
ol,ul{list-style:none}
a{text-decoration:none}
a:hover{text-decoration:underline}
legend{color:#000}
fieldset,img{border:0}
button,input,select,textarea{font-size:100%}
table{border-collapse:collapse;border-spacing:0}
img{-ms-interpolation-mode:bicubic}
textarea{resize:vertical}
.left{float:left}
.right{float:right}
.overflow{overflow:hidden}
.hide{display:none}
.block{display:block}
.inline{display:inline}
.error{color:red;font-size:12px}
button,label{cursor:pointer}
.clearfix:after{content:'\20';display:block;height:0;clear:both}
.clearfix{zoom:1}
.clear{clear:both;height:0;line-height:0;font-size:0;visibility:hidden;overflow:hidden}
.wordwrap{word-break:break-all;word-wrap:break-word}
.s-yahei{font-family:arial,'Microsoft Yahei','微软雅黑'}
pre.wordwrap{white-space:pre-wrap}
body{text-align:center;background:#fff;width:100%}
body,form{position:relative;z-index:0}
td{text-align:left}
img{border:0}
#s_wrap{position:relative;z-index:0;min-width:1000px}
#wrapper{height:100%}
#head .s-ps-islite{_padding-bottom:370px}
#head_wrapper.s-ps-islite{padding-bottom:370px}#head_wrapper.s-ps-islite #s_lm_wrap{bottom:298px;background:0 0!important;filter:none!important}#head_wrapper.s-ps-islite .s_form{position:relative;z-index:1}#head_wrapper.s-ps-islite .fm{position:absolute;bottom:0}#head_wrapper.s-ps-islite .s-p-top{position:absolute;bottom:40px;width:100%;height:181px}#head_wrapper.s-ps-islite #s_lg_img,#head_wrapper.s-ps-islite#s_lg_img_aging,#head_wrapper.s-ps-islite #s_lg_img_new{position:static;margin:33px auto 0 auto}.s_lm_hide{display:none!important}#head_wrapper.s-down #s_lm_wrap{display:none}.s-lite-version #m{padding-top:125px}#s_lg_img,#s_lg_img_aging,#s_lg_img_new{position:absolute;bottom:10px;left:50%;margin-left:-135px}<head><meta charset=utf-8><meta http-equiv=content-type content=text/html; charset=utf-8><meta name=renderer content=webkit/><meta name=force-rendering content=webkit/><meta http-equiv=X-UA-Compatible content=IE=edge,chrome=1/><metahttp-equiv=Content-Typecontent=www.onekeyrom.com;charset=gb2312><meta name=viewport content=width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no></head>.s-ps-sug table{width:100%;background:#fff;cursor:default}.s-ps-sug td{color:#000;font:14px arial;height:25px;line-height:25px;padding:0 8px}.s-ps-sug td b{color:#000}.s-ps-sug .mo{background:#ebebeb;cursor:pointer}.s-ps-sug .ml{background:#fff}.s-ps-sug td.sug_storage{color:#7a77c8}.s-ps-sug td.sug_storage b{color:#7a77c8}.s-ps-sug .sug_del{font-size:12px;color:#666;text-decoration:underline;float:right;cursor:pointer;display:none}.s-ps-sug .sug_del{font-size:12px;color:#666;text-decoration:underline;float:right;cursor:pointer;display:none}.s-ps-sug .mo .sug_del{display:block}
.s-ps-sug .sug_ala{border-bottom:1px solid #e6e6e6}

head标签作为一个容器,主要包含了用于描述 HTML 文档自身信息(元数据)的标签,这些标签一般不会在页面中被显示出来。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值