summary(5.1- 5.9)

1. the token we`re going to predict

1 .1 for block range(?)

for 结构一般都是for what in range(what) 或者 for what in what。 对于第一种大多是取此for结构上的一个被赋予constant的field variable,或者len(某个dict或者list)
在这里插入图片描述

1 .2 for block

如果是for x in X: 那么X大概率可能马上就会用到,可以用作API call的参数等等
在这里插入图片描述

1.3 array index

某些类似于数组的结构的索引值,在循环结构中,跟for 条件里的变量关系很大,
在这里插入图片描述

1.4 similar parent and similar structure

要预测第二个if的body里面是什么,如果可以知道这是recursion结构,上一个if返回了all _data, 那这个语句返回all_data的可能性就很大。
在这里插入图片描述
接下来这个就是相同的操作复现,不过一个针对“type”, 一个针对“value”
在这里插入图片描述

1.5 API call

对于API的调用,我们大可不必收集所有的method,可以把用到的做个排序。
对于list,随处可见的append
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

1.6 print args

编程时,我们喜欢print 中间结果,print函数一般要打印的变量都在他附近
在这里插入图片描述

1.7 alias

python里很多package,import的时候都喜欢用alias,

import numpy as np
import tensorflow as tf
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import panda as pd
在这里插入图片描述

1.8 summary

根据suggestion scenario制定规则,为这个scenario就可以认为是不同的上下文,我们根据不用的上下文,先知道given code snippet是属于哪种 scenario,然后不同的scenario建立不同的概率模型,API call也许unconditional probabilistic model就可以,field name用naive nayes, 有些用svm等等。

2. 基本思路

根据code snippet得到很多subset,根据subset来各自建模。
在这里插入图片描述

2.1 基本思想

分而治之,类似与decision tree,不同的是leaf node不是决策,而是一个model。
对于API call, array index, field variables,keywords的suggestion或者completion应该分别建模,如何分开可以Manuals make rule

2.2 Manuals make rule

指定rule,为了找context分scenario,那context与什么有关呢?我们就需要知道要which type we’re going to, 也就是node_type;对于tree structure,parent,children, his leaf node, sibling, his sibling’s leaf node,对于sequence structure,previous DFS node, next DFS node,prev leaf node, 和当前node具有type 或者value的 node :previous DFS node type ,previous DFS node value 话可以在添加一些具有相同type和value的grandparent,parent 的previous same context 共计12个特征。特征之间的是否独立我们没有关心。(待改进的地方就是一次用多个rule,来生成decision tree)

2. 3 dynamically capture context

类似于decision tree的建模过程,不同的是leaf node不是决策,而是要建立一个probabilistic model。
在这里插入图片描述
当dataset小于一定程度,比如小于1%的dataset的时候,也可以终止decision tree的继续生成

2.4 probabilistic model

baseline captures context的时候一次用一个rule,probabilistic model使用 unconditional probabilistic model也就是频率frequency。待改进的地方很大,可以用其他probabilistic model。

3. result

len 7535904

rule: 生成decision treeTraing set sizeEvalation setProbabilistic modelevaluate MAPtime consumption
每次用2个rule746320unconditional probabilistic model ( frequency)36.41%00:00:38
每次用3个rule746320unconditional probabilistic model ( frequency)37.75%00:38:45
每次用2个rule24851065unconditional probabilistic model ( frequency)36.72%00:03:41
每次用3个rule24851065unconditional probabilistic model ( frequency)****running
每次用3个rule7535904。。。unconditional probabilistic model ( frequency)****/2019/5/8/18:40 – 没出结果

result:
在这里插入图片描述
在这里插入图片描述

4. 待改进

4.1. use genetic algorithm to find best rules during building decision tree

build decision tree一次用多个特征(算法C4.5防止生成很多分支),一次用多个rule, 12条rule,排列组合,如果一次用5个以内的rule来capture context,那么没进行一次branch,就要在4万个指标中找一个best,
2.
树的深度如果是10,那就要在40万中遍历,greedy algorithm行不通,可以用遗传算法 genetic algorithm找到一个best。

4.2 . probabilistic model

使用其他的probabilistic model而不是frequency

4. 3. model

model不一定要预测value,可以预测是从那个位置获取value,这样可以handle out of vocabulary, 而且应该回提高指标。但是如何设计还不清楚

4. 4. model save

我们把数据保存在了叶子节点,这个树将会非常庞大,dataset size 是千万级别的,那么在处理每个subset后得一个model再次保存下来,model的参数过大,存不下,程序就会被killed掉,而且直接运行生成叶子节点为数据的程序,memory已经占了80多个G,
在这里插入图片描述
遍历tree用递归,真的有可能killed,现在是tree都没跑下来。

4. 5. random forest

capture context是用的是指标是信息增益率(information gain ratio),这个未必能把true context capture住,那sample rules,sample data建立 random forest,code suggestion进行vote,效果应该会很很好。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值