20190711工作进展

  1. 得到了title表和叶子类目的对应关系
    hs_leaf_class_for_title
    确认有些title表中的项目在原始数据表中找不到对应项目,大概每个表有1000条找不到

  2. 取得商品的item_id
    select coalesce(get_json_object(body, '.entities.k0.item_id/l'), get_json_object(body, '.entities.k1.item_id/l')) as item_id, title, id from hs_jingyan_query_related_video_pool_2_3 limit 100;

  3. 按照item_id取得叶子类目

create table hs_leaf_class_for_title_3 as select item_id, title, cate_id, cate_name, cate_level, commodity_id, commodity_name from tbcdm.dim_tb_itm where ds=max_pt('tbcdm.dim_tb_itm') and item_id in(select coalesce(get_json_object(body, '.entities.k0.item_id/l'), get_json_object(body, '.entities.k1.item_id/l')) from hs_jingyan_query_related_video_pool_3_3);

select count(*) from as select coalesce(get_json_object(body, '.entities.k0.item_id/l'), get_json_object(body, '.entities.k1.item_id/l')) from hs_jingyan_query_related_video_pool_3_3;

create table hs_tmp_1 as select coalesce(get_json_object(body, '.entities.k0.item_id/l'), get_json_object(body, '.entities.k1.item_id/l')) as item_id, id from hs_jingyan_query_related_video_pool_3_3;

  1. 得到query对应的商品id列表

create table hs_tmp_0 as select se_keyword, item_list from graph_embedding.jl_jingyan_query_related_top_query_detailed;

create table hs_tmp_1 as select b.id, b.query, a.item_list from (select se_keyword, item_list from hs_tmp_0)a left join (select id, query from hs_jingyan_query_related_top_query_1)b on a.se_keyword == b.query;

create table hs_tmp_4 as select a.id, b.query, a.item_id from
(select id, item_id from hs_tmp_3)a left join (select query, id from hs_jingyan_query_related_top_query_1)b on a.id == b.id;

create table hs_leaf_class_for_query as select item_id, title, cate_id, cate_name, cate_level, commodity_id, commodity_name from tbcdm.dim_tb_itm where ds=max_pt('tbcdm.dim_tb_itm') and item_id in(select coalesce(get_json_object(body, '.entities.k0.item_id/l'), get_json_object(body, '.entities.k1.item_id/l')) from hs_jingyan_query_related_video_pool_3_3);

select se_keywork, item_list from graph_embedding.jl_jingyan_query_related_top_query_detailed where se_keyword is NULL limit 100;

  1. 得到的query中能与原始query对应上的只有9150条数据,也就是说有850个query没有对应的叶子类目
    hs_leaf_class_for_query_0

create table hs_tmp_7 as select b.id, b.query, b.item_id, a.title, a.cate_id, a.cate_name, a.cate_level, a.commodity_id, a.commodity_name from (select item_id, title, cate_id, cate_name, cate_level, commodity_id, commodity_name from hs_tmp_6 where item_id in(select item_id from hs_tmp_5))a left join (select id, query, item_id from hs_tmp_5)b on a.item_id == b.item_id;

  1. 过滤

hs_result_title_query_1w_2, hs_leaf_class_for_query_0 -> hs_result_title_query_1w_filtered

pai -name pytorch -project algo_public_dev -Dpython=3.6 -Dscript="file:///apsarapangu/disk1/hengsong.lhs/origin_deep_cluster_odps_5.tar.gz" -DentryFile="test_query_with_title.py" -Dtables="odps://graph_embedding/tables/hs_result_title_query_1w_2,odps://graph_embedding/tables/hs_leaf_class_for_query_0" -Doutputs="odps://graph_embedding/tables/hs_result_title_query_1w_filtered_tmp" -Dbucket="oss://bucket-automl/" -Darn="acs:ram::1293303983251548:role/graph2018" -Dhost="cn-hangzhou.oss-internal.aliyun-inc.com" -DuserDefinedParameters="" -DworkerCount=1;

create table hs_result_title_query_1w_filtered_1 as
select a.* from
(select * from hs_result_title_query_1w_2)a right join
(select * from hs_result_title_query_1w_filtered)b on a.index == b.index and b.item_id == b.item_id;

  1. 除去叶子类目中找不到的结果

create table hs_result_title_query_1w_2 as
select a.index, a.origin_query, a.query, a.title_id, a.title, b.item_id, a.score, b.cate_id, b.cate_name, a.url from
(select * from hs_result_title_query_1w_1 where title in (select title from hs_leaf_class_for_title_2))a join (select * from hs_leaf_class_for_title_2)b on a.title == b.title;

  1. 处理url
    select index, origin_query, query, title_id, title, item_id, score, cate_id, cate_name, url when url is not "\N" then CONCAT("http://cloud.video.taobao.com", url) from hs_result_title_query_1w_filtered_2 limit 10;

select index as qid, origin_query as query , title as video_titile,
case when url_k2 != "\N" then CONCAT("http://cloud.video.taobao.com", url_k2)
ELSE CONCAT("http:", url_k3)

select index as qid, origin_query as query , title as video_titile,
CONCAT("http://cloud.video.taobao.com", url) from hs_result_title_query_1w_filtered_2 limit 10;

  1. 使用top1000来取title

(0) 得到query_title对应表
create table if not exists graph_embedding.hs_heter_graph_embedding_out_nearest_neighbor_007(
node_id bigint,
emb string
) LIFECYCLE 14;

hs_heter_graph_embedding_out_nearest_neighbor_007

PAI -name am_vsearch_nearest_neighbor_014 -project algo_market
-Dcluster="{"worker":{"count":1,"gpu":100}}"
-Ddim=100
-Did_col="node_id"
-Dvector_col="emb"
-Dinput_slice=1
-Dtopk=1000
-Dnprob=1024
-Dmetric="l2"
-Dinput="odps://graph_embedding/tables/hs_heter_graph_embedding_video_recall_"
-Dquery="odps://graph_embedding/tables/hs_heter_graph_embedding_ave_info_"
-Doutputs="odps://graph_embedding/tables/hs_heter_graph_embedding_out_nearest_neighbor_007"
-DenableDynamicCluster=true -DmaxTrainingTimeInHour=60;

1000 result : hs_heter_graph_embedding_out_nearest_neighbor_007

(1) 分割result
create table hs_tmp_10 as select bi_udf:bi_split_value(node_id, emb, " ") as (query_id, title_id) from hs_heter_graph_embedding_out_nearest_neighbor_007;

create table hs_tmp_11 as select graph_embedding:hs_split(query_id, title_id, ":") as (query_id, title_id, score) from hs_tmp_10;

加title:

create table hs_tmp_12 as
select a.query_id, a.title_id, b.title, a.score from
(select * from hs_tmp_11)a join
(select title, id from hs_jingyan_query_related_video_pool_2_3)b
on a.title_id == b.id;

(2) 除去叶子类目中找不到的结果,顺便加上叶子类目信息
create table hs_tmp_13 as
select a.query_id as index, a.title_id, a.title, b.item_id, a.score, b.cate_id, b.cate_name from
(select * from hs_tmp_12 where title in (select title from hs_leaf_class_for_title_2))a join (select * from hs_leaf_class_for_title_2)b on a.title == b.title;

(3)过滤

pai -name pytorch -project algo_public_dev -Dpython=3.6 -Dscript="file:///apsarapangu/disk1/hengsong.lhs/origin_deep_cluster_odps_5.tar.gz" -DentryFile="test_query_with_title.py" -Dtables="odps://graph_embedding/tables/hs_tmp_13,odps://graph_embedding/tables/hs_leaf_class_for_query_0" -Doutputs="odps://graph_embedding/tables/hs_tmp_14" -Dbucket="oss://bucket-automl/" -Darn="acs:ram::1293303983251548:role/graph2018" -Dhost="cn-hangzhou.oss-internal.aliyun-inc.com" -DuserDefinedParameters="" -DworkerCount=1;

  1. 构造UDTF
    http://help.aliyun-inc.com/internaldoc/detail/27811.html?spm=a2c1f.8259796.3.8.733f96d5LV8C1z

/apsarapangu/disk1/hengsong.lhs/deep_cluster_odps/IDEC-pytorch/hs_udf.py
CREATE FUNCTION hs_split AS hs_udf.Processor USING hs_udf.py;

select graph_embedding:hs_split(query, title_id, ":") as (query_id, title_id, score) from hs_heter_graph_embedding_out_nearest_neighbor_007 limit 100;

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,937评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,503评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,712评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,668评论 1 276
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,677评论 5 366
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,601评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,975评论 3 396
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,637评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,881评论 1 298
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,621评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,710评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,387评论 4 319
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,971评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,947评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,189评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 44,805评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,449评论 2 342

推荐阅读更多精彩内容

  • 将udf得到的结果进行title和query的对应 pai -name pytorch -project algo...
    Songger阅读 289评论 0 0
  • 60个epoch测试 pai -name pytorch -project algo_public_dev -Dp...
    Songger阅读 235评论 0 0
  • create table hs_uc_bhtb_xhs_topic_t_url_info_ as select r...
    Songger阅读 315评论 0 0
  • 参数测试insert overwrite table graph_embedding.hs_tmp_208sele...
    Songger阅读 167评论 0 0
  • 这一篇最主要是记录下命令,方便以后查找 使用Mysql 创建数据库 create database mysql_t...
    Treehl阅读 571评论 0 0