Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/classification/svm/__init__.py

    r11377 r11397  
    2020 
    2121from Orange.data import preprocess 
     22from Orange.data.preprocess import DomainContinuizer 
    2223 
    2324from Orange import feature as variable 
     
    805806 
    806807    def __init__(self, solver_type=L2R_L2LOSS_DUAL, C=1.0, eps=0.01, 
    807                  bias=1.0, normalization=True, **kwargs): 
     808                 bias=1.0, normalization=True, 
     809                 multinomial_treatment=DomainContinuizer.NValues, **kwargs): 
    808810        """ 
    809811        :param solver_type: One of the following class constants: 
     
    833835        :type normalization: bool 
    834836 
    835         .. note:: If the training data contains discrete features they are 
    836             replaced by indicator columns one for each value of the feature 
    837             regardless of the value of `normalization`. This is different 
    838             then in :class:`SVMLearner` where this is done only if 
     837        :param multinomial_treatment: Defines how to handle multinomial 
     838            features for learning. It can be one of the 
     839            :class:`~.DomainContinuizer` `multinomial_treatment` 
     840            constants (default: `DomainContinuizer.NValues`). 
     841 
     842        :type multinomial_treatment: int 
     843 
     844        .. versionadded:: 2.6.1 
     845            Added `multinomial_treatment` 
     846 
     847        .. note:: By default if the training data contains discrete features 
     848            they are replaced by indicator columns one for each value of the 
     849            feature regardless of the value of `normalization`. This is 
     850            different then in :class:`SVMLearner` where this is done only if 
    839851            `normalization` is ``True``. 
    840852 
     
    852864        self.bias = bias 
    853865        self.normalization = normalization 
     866        self.multinomial_treatment = multinomial_treatment 
    854867 
    855868        for name, val in kwargs.items(): 
    856869            setattr(self, name, val) 
     870 
    857871        if self.solver_type not in [self.L2R_L2LOSS_DUAL, self.L2R_L2LOSS, 
    858872                self.L2R_L1LOSS_DUAL, self.L1R_L2LOSS]: 
    859             warnings.warn("""\ 
    860 Deprecated 'solver_type', use 
    861 'Orange.classification.logreg.LibLinearLogRegLearner' 
    862 to build a logistic regression model using LIBLINEAR. 
    863 """, 
    864                 DeprecationWarning) 
     873            warnings.warn( 
     874                " Deprecated 'solver_type', use " 
     875                "'Orange.classification.logreg.LibLinearLogRegLearner'" 
     876                "to build a logistic regression models using LIBLINEAR.", 
     877                DeprecationWarning 
     878            ) 
    865879 
    866880    def __call__(self, data, weight_id=None): 
     
    869883 
    870884        if data.domain.has_discrete_attributes(False) or self.normalization: 
    871             dc = Orange.data.continuization.DomainContinuizer() 
    872             dc.multinomial_treatment = dc.NValues 
     885            dc = DomainContinuizer() 
     886            dc.multinomial_treatment = self.multinomial_treatment 
    873887            dc.class_treatment = dc.Ignore 
    874888            dc.continuous_treatment = \ 
     
    888902 
    889903    def __init__(self, C=1.0, eps=0.01, bias=1.0, 
    890                  normalization=True, **kwargs): 
     904                 normalization=True, 
     905                 multinomial_treatment=DomainContinuizer.NValues, 
     906                 **kwargs): 
    891907        """\ 
    892908        :param C: Regularization parameter (default 1.0) 
     
    904920            (default True) 
    905921        :type normalization: bool 
     922 
     923        :param multinomial_treatment: Defines how to handle multinomial 
     924            features for learning. It can be one of the 
     925            :class:`~.DomainContinuizer` `multinomial_treatment` 
     926            constants (default: `DomainContinuizer.NValues`). 
     927 
     928        :type multinomial_treatment: int 
     929 
     930        .. versionadded:: 2.6.1 
     931            Added `multinomial_treatment` 
    906932 
    907933        """ 
     
    910936        self.bias = bias 
    911937        self.normalization = normalization 
     938        self.multinomial_treatment = multinomial_treatment 
    912939        for name, val in kwargs.items(): 
    913940            setattr(self, name, val) 
     
    920947 
    921948        if data.domain.has_discrete_attributes(False) or self.normalization: 
    922             dc = Orange.data.continuization.DomainContinuizer() 
    923             dc.multinomial_treatment = dc.NValues 
     949            dc = DomainContinuizer() 
     950            dc.multinomial_treatment = self.multinomial_treatment 
    924951            dc.class_treatment = dc.Ignore 
    925952            dc.continuous_treatment = \ 
Note: See TracChangeset for help on using the changeset viewer.