Changeset 9343:7a1287d57379 in orange


Ignore:
Timestamp:
12/13/11 11:32:48 (2 years ago)
Author:
ales_erjavec <ales.erjavec@…>
Branch:
default
Convert:
06ffa30f6358faeb98f01fb267ec60c187591426
Message:

Added option to set the terms automatically similar to Earth in R.

Location:
orange
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orange/Orange/regression/earth.py

    r9319 r9343  
    118118            of the terms in the model. 
    119119        :type degree: int 
    120         :param terms: Maximum number of terms in the forward pass. 
     120        :param terms: Maximum number of terms in the forward pass (default 21). 
     121             
     122            .. note:: If this paramter is None then  
     123                ``min(200, max(20, 2 * n_attributes)) + 1`` will be used. This 
     124                is the same as the default setting in earth R package. 
     125                 
    121126        :type terms: int 
    122127        :param penalty: Penalty for hinges in the GCV computation (used  
     
    133138        :param fast_k: Fast k. 
    134139        :param fast_beta: Fast beta. 
    135         :param pruned_terms: Maximum number if terms in the model after 
     140        :param pruned_terms: Maximum number of terms in the model after 
    136141            pruning (default None - no limit). 
    137142        :type pruned_terms: int 
     
    204209            sy = y 
    205210             
     211        terms = self.terms 
     212        if terms is None: 
     213            # Automatic maximum number of terms 
     214            terms = min(200, max(20, 2 * x.shape[1])) + 1 
     215             
    206216        n_terms, used, bx, dirs, cuts = forward_pass(x, sy, 
    207             degree=self.degree, terms=self.terms, penalty=self.penalty, 
     217            degree=self.degree, terms=terms, penalty=self.penalty, 
    208218            thresh=self.thresh, fast_k=self.fast_k, fast_beta=self.fast_beta, 
    209219            new_var_penalty=self.new_var_penalty) 
  • orange/OrangeWidgets/Regression/OWEarth.py

    r9304 r9343  
    4444                   label="Max. term degree",  
    4545                   tooltip="Maximum degree of the terms derived (number of hinge functions).") 
    46         OWGUI.spin(box, self, "terms", 2, 50, step=1, 
    47                    label="Max. terms", 
    48                    tooltip="Maximum number of terms derived in the forward pass.") 
     46        s = OWGUI.spin(box, self, "terms", 1, 200, step=1, 
     47                       label="Max. terms", 
     48                       tooltip="Maximum number of terms derived in the forward pass.") 
     49        s.control.setSpecialValueText("Automatic") 
    4950         
    5051        box = OWGUI.widgetBox(self.controlArea, "Pruning Pass", addSpace=True) 
     
    7273    def apply(self): 
    7374        learner = earth.EarthLearner(degree=self.degree, 
    74                                     terms=self.terms, 
     75                                    terms=self.terms if self.terms >= 2 else None, 
    7576                                    penalty=self.penalty, 
    7677                                    name=self.name) 
     
    9394        self.reportSettings("Learning parameters",  
    9495                            [("Degree", self.degree), 
    95                              ("Terms", self.terms), 
     96                             ("Terms", self.terms if self.terms >= 2 else "Automatic"), 
    9697                             ("Knot penalty", "%.2f" % self.penalty) 
    9798                             ]) 
Note: See TracChangeset for help on using the changeset viewer.