Changeset 9477:de11ce1a5f4b in orange


Ignore:
Timestamp:
08/12/11 19:45:26 (3 years ago)
Author:
wencanluo <wencanluo@…>
Branch:
default
Convert:
697d0370778e2867f3bf04c007699c1f716f553b
Message:

Add some annotations for the methods

Location:
orange
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • orange/Orange/multilabel/br.py

    r9475 r9477  
    153153         
    154154######################################################################################### 
     155# Test the code, run from DOS prompt 
     156# assume the data file is in proper directory 
     157 
    155158if __name__ == "__main__": 
    156159    data = Orange.data.Table("emotions.tab") 
  • orange/Orange/multilabel/brknn.py

    r9475 r9477  
    276276     
    277277######################################################################################### 
     278# Test the code, run from DOS prompt 
     279# assume the data file is in proper directory 
     280 
    278281if __name__ == "__main__": 
    279282    data = Orange.data.Table("emotions.tab") 
  • orange/Orange/multilabel/label.py

    r9476 r9477  
    6666    domain = data.domain 
    6767    newdomain =  [domain[i] for i, var in enumerate(data.domain.variables) 
    68           if var.attributes.has_key('label')] 
     68          if not var.attributes.has_key('label')] 
    6969    new_data = data.translate(newdomain) 
    70      
     70    return new_data 
     71 
    7172def get_label_bitstream(data,example): 
    72     """ get the labels in terms of a string of 0 and 1 """ 
     73    """ get the labels in a 0/1 string. For example, if the first char in the string is '1', then the example belongs to the first label""" 
    7374    if not isinstance(data, Orange.data.Table): 
    7475        raise TypeError('data must be of type \'Orange.data.Table\'') 
  • orange/Orange/multilabel/lp.py

    r9476 r9477  
    77 
    88LabelPowerset Classification is another transformation method for multi-label classification.  
    9 It consideres each different set of labels that exist in the multi-label data as a  
     9It considers each different set of labels that exist in the multi-label data as a  
    1010single label. It so learns one single-label classifier :math:`H:X \\rightarrow P(L)`, where 
    1111:math:`P(L)` is the power set of L. 
     
    144144 
    145145######################################################################################### 
     146# Test the code, run from DOS prompt 
     147# assume the data file is in proper directory 
     148 
    146149if __name__ == "__main__": 
    147150    data = Orange.data.Table("emotions.tab") 
  • orange/Orange/multilabel/mlknn.py

    r9475 r9477  
    77 
    88ML-kNN Classification is a kind of adaptation method for multi-label classification.  
    9 It is an adaptation of the kNN lazy learning algorithm for multi-label data. In essence, 
    10 ML-kNN uses the kNN algorithm independently for each label :math:'l': It finds the k nearest  
    11 examples to the test instance and considers those that are labelled at least with :math:'l'  
    12 as positive and the rest as negative. Actually this method follows the paradigm of Binary Relevance (BR). 
    13 What mainly differentiates this method from BR is the use of prior probabilities. ML-kNN has also 
     9It is an adaptation of the kNN lazy learning algorithm for multi-label data.  
     10In essence, ML-kNN uses the kNN algorithm independently for each label :math:'l':  
     11It finds the k nearest examples to the test instance and considers those that are  
     12labelled at least with :math:'l' as positive and the rest as negative.  
     13Actually this method follows the paradigm of Binary Relevance (BR). What mainly  
     14differentiates this method from BR is the use of prior probabilities. ML-kNN has also 
    1415the capability of producing a ranking of the labels as an output. 
    15 For more information, see Zhang, M. and Zhou, Z. 2007. `ML-KNN: A lazy learning approach to multi-label learning <http://dx.doi.org/10.1016/j.patcog.2006.12.019>`_.  
     16For more information, see Zhang, M. and Zhou, Z. 2007. `ML-KNN: A lazy learning  
     17approach to multi-label learning <http://dx.doi.org/10.1016/j.patcog.2006.12.019>`_.  
    1618Pattern Recogn. 40, 7 (Jul. 2007), 2038-2048.   
    1719 
     
    278280         
    279281######################################################################################### 
     282# Test the code, run from DOS prompt 
     283# assume the data file is in proper directory 
     284 
    280285if __name__ == "__main__": 
    281286    data = Orange.data.Table("emotions.tab") 
  • orange/Orange/multilabel/mulan.py

    r9467 r9477  
    4040############################################################################## 
    4141# Test the code, run from DOS prompt 
     42# assume the data file is in proper directory 
    4243 
    4344if __name__=="__main__": 
  • orange/OrangeWidgets/Multilabel/OWLP.py

    r9476 r9477  
    8989                self.classifier = self.learner(self.data) 
    9090                self.classifier.name = self.name 
    91                 for i in range(10): 
    92                     c,p = self.classifier(self.data[i],Orange.classification.Classifier.GetBoth) 
    93                     print c,p 
     91                #for i in range(10): 
     92                #    c,p = self.classifier(self.data[i],Orange.classification.Classifier.GetBoth) 
     93                #    print c,p 
    9494            except Exception, (errValue): 
    9595                self.classifier = None 
  • orange/doc/Orange/rst/code/mlc-label-example.py

    r9460 r9477  
    2626 
    2727#test getlabelIndices 
     28print "#test getlabelIndices:" 
    2829for id in label.get_label_indices(data): 
    2930    print data.domain[id].name, 
    3031print 
    3132# print Sports Religion Science Politics 
     33 
     34#test remove_labels 
     35print "#test remove_labels:" 
     36data3 = label.remove_labels(data) 
     37for e in data3: 
     38    print e 
    3239 
    3340#test removeIndices 
     
    4855#['3', '1', '3'] 
    4956#['4', '0', '4'] 
     57 
Note: See TracChangeset for help on using the changeset viewer.