Changeset 7975:e1cf74ae63a3 in orange


Ignore:
Timestamp:
06/02/11 23:13:00 (3 years ago)
Author:
miha <miha.stajdohar@…>
Branch:
default
Convert:
848a8c0dfd89264c6e24f46194aa79260ac180b5
Message:

Added another community detection algorithm of Loung et al, 2009

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeWidgets/Unsupervised/OWNxClustering.py

    r7954 r7975  
    88 
    99import Orange 
     10import Orange.network.community as cd 
    1011import OWGUI 
    1112 
     
    1415class OWNxClustering(OWWidget): 
    1516     
    16     settingsList = ['method', 'iterationHistory', "autoApply"] 
     17    settingsList = ['method', 'iterationHistory', 'autoApply', 'iterations', 'hop_attenuation'] 
    1718     
    1819    def __init__(self, parent=None, signalManager=None): 
     
    2627        self.iterationHistory = 0 
    2728        self.autoApply = 0 
    28          
     29        self.iterations = 1000 
     30        self.hop_attenuation = 0.1 
    2931        self.loadSettings() 
    3032         
     33        OWGUI.spin(self.controlArea, self, "iterations", 1, 100000, 1, label="Iterations: ") 
    3134        ribg = OWGUI.radioButtonsInBox(self.controlArea, self, "method", [], "Method", callback = self.cluster) 
    3235        OWGUI.appendRadioButton(ribg, self, "method", "Label propagation clustering (Raghavan et al., 2007)", callback = self.cluster) 
    33         OWGUI.checkBox(OWGUI.indentedBox(ribg), self, "iterationHistory", "Append clustering data on each iteration", callback = self.cluster) 
     36         
     37        OWGUI.appendRadioButton(ribg, self, "method", "Label propagation clustering (Loung et al., 2009)", callback = self.cluster) 
     38        OWGUI.doubleSpin(OWGUI.indentedBox(ribg), self, "hop_attenuation", 0, 1, 0.01, label="Hop attenuation (delta): ") 
     39         
     40         
    3441        self.info = OWGUI.widgetLabel(self.controlArea, ' ') 
     42        OWGUI.checkBox(self.controlArea, self, "iterationHistory", "Append clustering data on each iteration") 
    3543        autoApplyCB = OWGUI.checkBox(self.controlArea, self, "autoApply", "Commit automatically") 
    3644        OWGUI.button(self.controlArea, self, "Commit", callback=self.cluster) 
     
    4452        self.info.setText(' ') 
    4553         
    46         if self.net == None: 
     54        if self.net is None: 
    4755            self.send("Network", None) 
    4856            return 
    4957         
    50         labels = Orange.network.community.label_propagation(self.net, results2items=1, resultHistory2items=self.iterationHistory) 
    51         self.info.setText('%d clusters found' % len(set(labels)))         
     58        if self.method == 0: 
     59            labels = cd.label_propagation(self.net, results2items=1,  
     60                                    resultHistory2items=self.iterationHistory,  
     61                                    iterations=self.iterations) 
     62        if self.method == 1: 
     63            labels = cd.label_propagation_hop_attenuation( 
     64                                    self.net,  
     65                                    results2items=1,  
     66                                    resultHistory2items=self.iterationHistory,  
     67                                    iterations=self.iterations, 
     68                                    delta=self.hop_attenuation) 
     69         
     70        self.info.setText('%d clusters found' % len(set(labels.items())))         
    5271        self.send("Network", self.net) 
Note: See TracChangeset for help on using the changeset viewer.