Changeset 10420:969093619068 in orange


Ignore:
Timestamp:
03/02/12 15:47:18 (2 years ago)
Author:
janezd <janez.demsar@…>
Branch:
default
Message:

Minor changes to documentation about multitarget

Location:
Orange
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • Orange/multitarget/__init__.py

    r10331 r10420  
    2929    :lines: 1-6 
    3030 
    31 Multi-target learners can be used to build prediction models (classifiers) 
     31Multi-target learners can build prediction models (classifiers) 
    3232which then predict (multiple) class values for a new instance (continuation of 
    3333:download:`multitarget.py <code/multitarget.py>`): 
     
    9999class MultitargetClassifier(Orange.classification.Classifier): 
    100100    """ 
    101     Multitarget classifier returning a list of predictions from each 
     101    Multitarget classifier that returns a list of predictions from each 
    102102    of the independent base classifiers. 
    103103 
  • Orange/regression/earth.py

    r10330 r10420  
    104104class EarthLearner(Orange.regression.base.BaseRegressionLearner): 
    105105    """Earth learner class. Supports both regression and classification 
    106     problems. In case of classification the class values are expanded into  
     106    problems. For classification, class values are expanded into  
    107107    continuous indicator columns (one for each value if the number of  
    108     values is grater then 2), and a multi response model is learned on these 
    109     new columns. The resulting classifier will then use the computed response 
     108    values is grater then 2), and a multi response model is fit to these 
     109    new columns. The resulting classifier the computes response 
    110110    values on new instances to select the final predicted class. 
    111111      
     
    126126         
    127127        :param degree: Maximum degree (num. of hinge functions per term) 
    128             of the terms in the model. 
     128            of the terms in the model (default: 1). 
    129129        :type degree: int 
    130         :param terms: Maximum number of terms in the forward pass (default 21). 
    131              
    132             .. note:: If this paramter is None then  
    133                 ``min(200, max(20, 2 * n_attributes)) + 1`` will be used. This 
    134                 is the same as the default setting in earth R package. 
    135                  
     130        :param terms: Maximum number of terms in the forward pass 
     131                (default: 21).  If set to ``None``, ``min(200, max(20, 2 
     132                * n_attributes)) + 1`` will be used, like the default 
     133                setting in earth R package. 
    136134        :type terms: int 
    137135        :param penalty: Penalty for hinges in the GCV computation (used  
    138             in the pruning pass). By default it is 3.0 if the degree > 1, 
    139             2.0 otherwise.  
     136            in the pruning pass). Default is 3.0 if ``degree`` is above 1, 
     137            and 2.0 otherwise.  
    140138        :type penalty: float 
    141139        :param thresh: Threshold for RSS decrease in the forward pass 
    142             (default 0.001). 
     140            (default: 0.001). 
    143141        :type thresh: float 
    144142        :param min_span: TODO. 
    145143        :param new_var_penalty: Penalty for introducing a new variable 
    146             in the model during the forward pass (default 0). 
     144            in the model during the forward pass (default: 0). 
    147145        :type new_var_penalty: float 
    148146        :param fast_k: Fast k. 
    149147        :param fast_beta: Fast beta. 
    150148        :param pruned_terms: Maximum number of terms in the model after 
    151             pruning (default None - no limit). 
     149            pruning (default: ``None``, no limit). 
    152150        :type pruned_terms: int 
    153         :param scale_resp: Scale responses prior to forward pass (default 
    154             True - ignored for multi response models). 
     151        :param scale_resp: Scale responses prior to forward pass (default: 
     152            ``True``); ignored for models with multiple responses. 
    155153        :type scale_resp: bool 
    156154        :param store_instances: Store training instances in the model 
    157             (default True). 
     155            (default: ``True``). 
    158156        :type store_instances: bool 
    159157          
     
    333331    def base_matrix(self, instances=None): 
    334332        """Return the base matrix (bx) of the Earth model for the table. 
    335         If table is not supplied the base matrix of the training instances  
     333        If table is not supplied, the base matrix of the training instances  
    336334        is returned. 
    337335        Base matrix is a len(instances) x num_terms matrix of computed values 
     
    350348     
    351349    def predict(self, instance): 
    352         """ Predict the response values for the instance 
     350        """ Predict the response value(s) 
    353351         
    354352        :param instance: Data instance 
     
    363361     
    364362    def used_attributes(self, term=None): 
    365         """ Return the used terms for term (index). If no term is given 
     363        """Return the used terms for term (index). If no term is given, 
    366364        return all attributes in the model. 
    367365         
     
    965963             
    966964class ScoreEarthImportance(scoring.Score): 
    967     """ An :class:`Orange.feature.scoring.Score` subclass. 
    968     Scores features based on their importance in the Earth 
    969     model using ``bagged_evimp``'s function return value. 
     965    """ A subclass of :class:`Orange.feature.scoring.Score` that. 
     966    scores features based on their importance in the Earth 
     967    model using ``bagged_evimp``. 
    970968     
    971969    """ 
  • Orange/regression/pls.py

    r10367 r10420  
    1010`Partial least squares 
    1111<http://en.wikipedia.org/wiki/Partial_least_squares_regression>`_ 
    12 regression is a statistical method which can be used to predict 
    13 multiple response variables simultaniously. Implementation is based on 
    14 `Scikit learn python implementation 
     12regression is a statistical method for simultaneous prediction of 
     13multiple response variables. Orange's implementation is 
     14based on `Scikit learn python implementation 
    1515<https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/pls.py>`_. 
    1616 
     
    3434 
    3535.. autofunction:: svd_xy 
    36  
    3736 
    3837======== 
     
    4039======== 
    4140 
    42 To predict values for the first two data instances 
    43 use the following code:  
     41The following code predicts the values of output variables for the 
     42first two instances in ``data``. 
     43 
    4444 
    4545.. literalinclude:: code/pls-example.py 
    4646    :lines: 16-20 
    4747 
    48 Output:: 
     48:: 
    4949 
    5050    Actual     [<orange.Value 'Y1'='0.490'>, <orange.Value 'Y2'='1.237'>, <orange.Value 'Y3'='1.808'>, <orange.Value 'Y4'='0.422'>] 
     
    5454    Predicted  [<orange.Value 'Y1'='0.058'>, <orange.Value 'Y2'='-0.706'>, <orange.Value 'Y3'='-1.420'>, <orange.Value 'Y4'='0.599'>] 
    5555 
    56 To see the coefficient of the model (in this case they are stored in a matrix) 
    57 print the model: 
     56To see the coefficient of the model, print the model: 
    5857 
    5958.. literalinclude:: code/pls-example.py 
    6059    :lines: 22 
    6160 
    62 The ouptut looks like this:: 
     61:: 
    6362 
    6463    Regression coefficients: 
     
    6867          X3        0.230       -0.314       -0.880       -0.060  
    6968 
    70  
     69Note that coefficients are stored in a matrix since the model predicts 
     70values of multiple outputs. 
    7171""" 
    7272 
     
    8383 
    8484def normalize_matrix(X): 
    85     """ Normalizes matrix, i.e. subtracts column means 
    86     and divides them by column standard deviations. 
    87     Returns the standardized matrix, sample mean and 
    88     standard deviation 
     85    """ 
     86    Normalize a matrix column-wise: subtract the means and divide by 
     87    standard deviations. Returns the standardized matrix, sample mean 
     88    and standard deviation 
    8989 
    9090    :param X: data matrix 
     
    9999def nipals_xy(X, Y, mode="PLS", max_iter=500, tol=1e-06): 
    100100    """ 
    101     NIPALS algorithm. Returns the first left and rigth singular 
     101    NIPALS algorithm; returns the first left and rigth singular 
    102102    vectors of X'Y. 
    103103 
     
    108108    :type mode: string 
    109109 
    110     :param max_iter: maximal number of iterations (default 500) 
     110    :param max_iter: maximal number of iterations (default: 500) 
    111111    :type max_iter: int 
    112112 
    113     :param tol: tolerance parameter, if norm of difference 
     113    :param tol: tolerance parameter; if norm of difference 
    114114        between two successive left singular vectors is less than tol, 
    115115        iteration is stopped 
     
    155155 
    156156def svd_xy(X, Y): 
    157     """ Returns the first left and right singular 
     157    """ Return the first left and right singular 
    158158    vectors of X'Y. 
    159159 
     
    169169 
    170170def select_attrs(table, attributes, class_var=None, metas=None): 
    171     """ Select only ``attributes`` from the ``table``. 
     171    """ Select ``attributes`` from the ``table`` and return a new data table. 
    172172    """ 
    173173    domain = Orange.data.Domain(attributes, class_var) 
     
    178178 
    179179class PLSRegressionLearner(base.BaseRegressionLearner): 
    180     """ Fits the partial least squares regression model, 
    181     i.e. learns the regression parameters. The implementation is based on 
    182     `Scikit learn python implementation`_ 
     180    """ 
     181    Fit the partial least squares regression model, i.e. learn the 
     182    regression parameters. The implementation is based on `Scikit 
     183    learn python implementation`_ 
    183184     
    184185    The class is derived from 
    185     :class:`Orange.regression.base.BaseRegressionLearner` 
    186     which is used for preprocessing the data (continuization and imputation) 
     186    :class:`Orange.regression.base.BaseRegressionLearner` that is 
     187    used for preprocessing the data (continuization and imputation) 
    187188    before fitting the regression parameters 
    188189     
     
    196197        .. attribute:: n_comp 
    197198     
    198             number of components to keep. Default: 2 
     199            number of components to keep (default: 2) 
    199200 
    200201        .. attribute:: deflation_mode 
     
    209210        .. attribute:: algorithm 
    210211     
    211             The algorithm used to estimate the weights: 
     212            The algorithm for estimating the weights: 
    212213            "nipals" or "svd" (default) 
    213214 
     
    231232        :param x_vars, y_vars: List of input and response variables 
    232233            (:obj:`Orange.feature.Continuous` or 
    233             :obj:`Orange.feature.Discrete`). If None (default) it is 
     234            :obj:`Orange.feature.Discrete`). If ``None`` (default) it is 
    234235            assumed that the data domain provides information which variables 
    235236            are reponses and which are not. If data has 
     
    281282 
    282283    def fit(self, X, Y): 
    283         """ Fits all unknown parameters, i.e. 
     284        """ Fit all unknown parameters, i.e. 
    284285        weights, scores, loadings (for x and y) and regression coefficients. 
    285         Returns a dict with all of the parameters. 
    286          
     286        Return a dict with all of the parameters. 
    287287        """ 
    288288        # copy since this will contain the residuals (deflated) matrices 
     
    365365 
    366366class PLSRegression(Orange.classification.Classifier): 
    367     """ PLSRegression predicts value of the response variables 
     367    """ Predict values of the response variables 
    368368    based on the values of independent variables. 
    369369     
Note: See TracChangeset for help on using the changeset viewer.