Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [recommenders-dev] About the Bayesian network in Eclipse Code Recommenders

Hi Marcel,

After a group discussion tonight, we came up with a draft structure of the Bayesian network for Precise (attached).

Here are some explanations:
1. In our previous approach, for an actual parameter, the context information consists of four features:
    Feature 1. the corresponding formal parameter
    Feature 2. the enclosing method (i.e. the method being overridden)
    Feature 3. the method calls happened on the local variable(s) used in the actual parameter
    Feature 4. the method calls happened on the base variable (if any) of the method call using the actual parameter

    For example, for the code snippet below:

        public class ExampleClass{
    public void addButton(Panel panel){
        Button b = new Button();
        b.setVisible(true);
        b.setAttrib(0);
      
        panel.init();
        panel.addElement(b);
        panel.setAttrib(b.getAttrib());
    }
}
    
    If the actual parameter of interest is b.getAttrib(), then the features are:
    Feature 1: the first (and sole) formal parameter of method Panel.setAttrib(...)
    Feature 2: the method ExampleClass.addButton(...)
    Feature 3: the method calls happened on variable b, that is, {<init>, setVisible, setAttrib}
    Feature 4: the method calls happened on variable panel, that is, {init, addElement}

2. As for the actual parameter, we extract and record its important information (and call it a "parameter usage"), including:
    1) Its _expression_ type: method call/qualified name/array access/literals/...
    2) If it is a method call, record the type of its (inner most) base variable (or _expression_)
    3) If it is a qualified name, record the type of its qualifier
    4) If it is a literal, just record it as it is.
   
3. As shown in the figure, we build a Bayesian network for each specific formal parameter (corresponding to Feature 1).
    1) The node "method contexts" (corresponding to Feature 2) is the same concept as that used in your figure 
    2) The node "Method Call: ClassA.m1()" corresponds to Feature 4
    3) Other ellipse nodes correspond to Feature 3.
    4) The rectangle nodes are parameter usages that may be recommended.

You can see that this structure is quite preliminary. At least, we are concerning about the size of the probability tables, 
since there are so many parents nodes...
We are still in the process of searching for better design, but I think you may give us some suggestions :)

Thanks,
Cheng 

On Tue, Aug 7, 2012 at 1:35 PM, Marcel Bruch <marcel.bruch@xxxxxxxxx> wrote:
Hi Cheng,

On 06.08.2012, at 17:35, Cheng Zhang wrote:

> Hi Marcel,
>
> Thank you for spending more than an hour to help us understand the Bayesian network.
>
> After our discussion, we have studied Bayesian network and the relevant
> code in Eclipse Code Recommenders more carefully. Still, we have a couple
> of questions:
>
> 1. You pointed out to us the code that uses the built model, but we also
>    want to learn the way of model building. Unfortunately, we failed to
>    find the code for this part. Is this part of code not publicly available?
>    Or we just overlooked it?

See /org.eclipse.recommenders.completion.rcp.overrides/src/org/eclipse/recommenders/internal/completion/rcp/overrides/ClassOverridesNetworkBuilder.java for an example how to create a bayesian network from some json input. It consists of two node types only: one "pattern node” and a list of "method nodes” encoding the overridable methods of a java base class. The method nodes encode the likelihood a method is overridden given a pattern in the pattern node. You will notice that we don’t use 1 and 0 as probabilities but MIN/MAX which are “close to 1/0”. This is because we want to allow some unexpected patterns.

If you could explain which structure your are trying to implement I may be able to assist with a more concrete example.

>
> 2. In your previous approach (FSE' 09 paper), the method contexts are treated
>    as a feature which seems similar to other features (i.e. method calls).
>    In the current approach, the method contexts seem to be used differently
>    than the method calls (and you used orange and blue to distinguish the nodes).
>    Would you please explain a bit more on this?

see below.


> 3. Using the JDT debugger, we have inspected the run-time data of a Bayesian network.
>    It seems that there are two layers in the network: the top layer is the "patterns" and
>    the bottom layer consists of the "method calls". Is our understanding correct?
>    Is it possible that a Bayesian network in Code Recommenders has more than two
>    layers? If so, would you please show us a simple example?

The current general network layout is depicted below:


the MethodN, Patterns, and Contexts node is what you already know. Kinds and Definitions are ’new’. Note that you may observer values in all nodes *except* the patterns node. It’s just a “virtual node” that connects all information. You may observe a call to method3 for a variable v --> set Method3=true. Setting this value to true updates the probabilities of all other MethodN, Contexts, Kinds, Definitions Nodes in the net.
If you observe another method call, say, to Method2 --> set the state true of node Method2 to observed again. Again this updates the probabilities of all other nodes and their states. You now just have to read the values of each state in every node and create your proposals.


Can you draw a similar figure for your network? If you like we can work on such a structure together.


> Thanks again for your help and suggestions :)

HTH,
Marcel


> Best,
> Cheng
> _______________________________________________
> recommenders-dev mailing list
> recommenders-dev@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/recommenders-dev


_______________________________________________
recommenders-dev mailing list
recommenders-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/recommenders-dev


Attachment: BN4Precise-draft.jpg
Description: JPEG image


Back to the top