Changeset 7339:f48293b252f9 in orange


Ignore:
Timestamp:
02/03/11 21:26:11 (3 years ago)
Author:
jzbontar <jure.zbontar@…>
Branch:
default
Convert:
831107d3235cdd1770e4ad7c2006f3756a35160f
Message:

checkpoint

Location:
orange
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • orange/Orange/classification/logreg.py

    r7311 r7339  
    66=================== 
    77 
    8 A set of wrappers around the classes LogisticLearner and 
    9 LogisticClassifier, that are implemented in core Orange. This module 
    10 extends the use of logistic regression to discrete features, it can 
    11 handle various anomalies in features, such as constant variables and 
    12 singularities, that make fitting logistic regression almost impossible. It 
    13 also implements a function for constructing stepwise logistic regression, 
    14 which is a good technique for prevent overfitting, and is a good feature 
    15 subset selection technique as well. 
     8Implements logistic regression and extends it's use to discrete features. 
     9It can handle various anomalies in features, such as constant variables 
     10and singularities, that make fitting logistic regression almost 
     11impossible. It also implements a function for constructing stepwise 
     12logistic regression, which is a good technique for prevent overfitting, 
     13and is a good feature subset selection technique as well. 
     14 
    1615 
    1716Useful Functions 
    18 --------- 
     17---------------- 
    1918 
    2019.. autofunction:: LogRegLearner 
    2120.. autofunction:: StepWiseFSS 
    2221.. autofunction:: printOUT 
     22 
    2323 
    2424Class 
     
    187187import orngCI 
    188188import math, os 
     189import warnings 
    189190from numpy import * 
    190191from numpy.linalg import * 
     
    194195## Print out methods ## 
    195196####################### 
    196  
    197197def printOUT(classifier): 
     198    warnings.warn("printOut is deprecated, use dump instead.", DeprecationWarning) 
     199    dump(classifier) 
     200 
     201def dump(classifier): 
    198202    """ Formatted print to console of all major features in logistic 
    199203    regression classifier.  
  • orange/Orange/classification/svm/kernels.py

    r7300 r7339  
    3535class RBFKernelWrapper(KernelWrapper): 
    3636     
    37     """AKernel wrapper that uses a wrapped kernel function in a RBF 
     37    """A Kernel wrapper that uses a wrapped kernel function in a RBF 
    3838    (Radial Basis Function) 
    3939     
     
    7878        """Return: 
    7979         
    80         :math::`wrapped1(example1, example2) + wrapped2(example1, example2)` 
     80        :math:`wrapped1(example1, example2) + wrapped2(example1, example2)` 
    8181             
    8282        """ 
  • orange/doc/Orange/rst/code/logreg-run.py

    r7292 r7339  
    99    if lr(ex) == ex.getclass(): 
    1010        correct += 1 
    11 print "Classification accuracy:", correct/len(table) 
     11print "Classification accuracy:", correct / len(table) 
    1212classification.logreg.printOUT(lr) 
  • orange/doc/Orange/rst/code/logreg-stepwise.py

    r7292 r7339  
    44from Orange import * 
    55 
    6 del orange 
    76 
    87def StepWiseFSS_Filter(examples=None, **kwds): 
     
    2322 
    2423    def __call__(self, examples): 
    25         attr = classification.logreg.StepWiseFSS(examples, addCrit=self.addCrit, deleteCrit = self.deleteCrit, numAttr = self.numAttr) 
    26         return examples.select(data.Domain(attr, examples.domain.classVar)) 
     24        feature = classification.logreg.StepWiseFSS(examples, 
     25          addCrit=self.addCrit, deleteCrit=self.deleteCrit, 
     26          numAttr=self.numAttr) 
     27        return examples.select(data.Domain(feature, examples.domain.classVar)) 
    2728 
    2829 
     
    3031 
    3132lr = classification.logreg.LogRegLearner(removeSingular=1) 
    32 learners = (classification.logreg.LogRegLearner(name='logistic', removeSingular=1), 
    33             orngFSS.FilteredLearner(lr, filter=StepWiseFSS_Filter(addCrit=0.05, deleteCrit=0.9), name='filtered')) 
     33learners = ( 
     34  classification.logreg.LogRegLearner(name='logistic', removeSingular=1), 
     35  orngFSS.FilteredLearner(lr, 
     36     filter=StepWiseFSS_Filter(addCrit=0.05, deleteCrit=0.9), 
     37     name='filtered') 
     38) 
    3439results = orngTest.crossValidation(learners, table, storeClassifiers=1) 
    3540 
     
    3742print "Learner      CA" 
    3843for i in range(len(learners)): 
    39   print "%-12s %5.3f" % (learners[i].name, orngStat.CA(results)[i]) 
     44    print "%-12s %5.3f" % (learners[i].name, orngStat.CA(results)[i]) 
    4045 
    41 # find out which attributes were retained by filtering 
     46# find out which features were retained by filtering 
    4247 
    43 print "\nNumber of times attributes were used in cross-validation:" 
    44 attsUsed = {} 
     48print "\nNumber of times features were used in cross-validation:" 
     49featuresUsed = {} 
    4550for i in range(10): 
    46   for a in results.classifiers[i][1].atts(): 
    47     if a.name in attsUsed.keys(): attsUsed[a.name] += 1 
    48     else: attsUsed[a.name] = 1 
    49 for k in attsUsed.keys(): 
    50   print "%2d x %s" % (attsUsed[k], k) 
     51    for a in results.classifiers[i][1].atts(): 
     52        if a.name in featuresUsed.keys(): 
     53            featuresUsed[a.name] += 1 
     54        else: 
     55            featuresUsed[a.name] = 1 
     56for k in featuresUsed: 
     57    print "%2d x %s" % (featuresUsed[k], k) 
Note: See TracChangeset for help on using the changeset viewer.