Changeset 10420:969093619068 in orange
 Timestamp:
 03/02/12 15:47:18 (2 years ago)
 Branch:
 default
 Location:
 Orange
 Files:

 3 edited
Legend:
 Unmodified
 Added
 Removed

Orange/multitarget/__init__.py
r10331 r10420 29 29 :lines: 16 30 30 31 Multitarget learners can b e used to build prediction models (classifiers)31 Multitarget learners can build prediction models (classifiers) 32 32 which then predict (multiple) class values for a new instance (continuation of 33 33 :download:`multitarget.py <code/multitarget.py>`): … … 99 99 class MultitargetClassifier(Orange.classification.Classifier): 100 100 """ 101 Multitarget classifier returninga list of predictions from each101 Multitarget classifier that returns a list of predictions from each 102 102 of the independent base classifiers. 103 103 
Orange/regression/earth.py
r10330 r10420 104 104 class EarthLearner(Orange.regression.base.BaseRegressionLearner): 105 105 """Earth learner class. Supports both regression and classification 106 problems. In case of classification theclass values are expanded into106 problems. For classification, class values are expanded into 107 107 continuous indicator columns (one for each value if the number of 108 values is grater then 2), and a multi response model is learned onthese109 new columns. The resulting classifier will then use the computedresponse108 values is grater then 2), and a multi response model is fit to these 109 new columns. The resulting classifier the computes response 110 110 values on new instances to select the final predicted class. 111 111 … … 126 126 127 127 :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). 129 129 :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. 136 134 :type terms: int 137 135 :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. 140 138 :type penalty: float 141 139 :param thresh: Threshold for RSS decrease in the forward pass 142 (default 0.001).140 (default: 0.001). 143 141 :type thresh: float 144 142 :param min_span: TODO. 145 143 :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). 147 145 :type new_var_penalty: float 148 146 :param fast_k: Fast k. 149 147 :param fast_beta: Fast beta. 150 148 :param pruned_terms: Maximum number of terms in the model after 151 pruning (default None no limit).149 pruning (default: ``None``, no limit). 152 150 :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. 155 153 :type scale_resp: bool 156 154 :param store_instances: Store training instances in the model 157 (default True).155 (default: ``True``). 158 156 :type store_instances: bool 159 157 … … 333 331 def base_matrix(self, instances=None): 334 332 """Return the base matrix (bx) of the Earth model for the table. 335 If table is not supplied the base matrix of the training instances333 If table is not supplied, the base matrix of the training instances 336 334 is returned. 337 335 Base matrix is a len(instances) x num_terms matrix of computed values … … 350 348 351 349 def predict(self, instance): 352 """ Predict the response value s for the instance350 """ Predict the response value(s) 353 351 354 352 :param instance: Data instance … … 363 361 364 362 def used_attributes(self, term=None): 365 """ Return the used terms for term (index). If no term is given363 """Return the used terms for term (index). If no term is given, 366 364 return all attributes in the model. 367 365 … … 965 963 966 964 class ScoreEarthImportance(scoring.Score): 967 """ A n :class:`Orange.feature.scoring.Score` subclass.968 Scores features based on their importance in the Earth969 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``. 970 968 971 969 """ 
Orange/regression/pls.py
r10367 r10420 10 10 `Partial least squares 11 11 <http://en.wikipedia.org/wiki/Partial_least_squares_regression>`_ 12 regression is a statistical method which can be used to predict13 multiple response variables simultaniously. Implementation is based on14 `Scikit learn python implementation12 regression is a statistical method for simultaneous prediction of 13 multiple response variables. Orange's implementation is 14 based on `Scikit learn python implementation 15 15 <https://github.com/scikitlearn/scikitlearn/blob/master/sklearn/pls.py>`_. 16 16 … … 34 34 35 35 .. autofunction:: svd_xy 36 37 36 38 37 ======== … … 40 39 ======== 41 40 42 To predict values for the first two data instances 43 use the following code: 41 The following code predicts the values of output variables for the 42 first two instances in ``data``. 43 44 44 45 45 .. literalinclude:: code/plsexample.py 46 46 :lines: 1620 47 47 48 Output::48 :: 49 49 50 50 Actual [<orange.Value 'Y1'='0.490'>, <orange.Value 'Y2'='1.237'>, <orange.Value 'Y3'='1.808'>, <orange.Value 'Y4'='0.422'>] … … 54 54 Predicted [<orange.Value 'Y1'='0.058'>, <orange.Value 'Y2'='0.706'>, <orange.Value 'Y3'='1.420'>, <orange.Value 'Y4'='0.599'>] 55 55 56 To see the coefficient of the model (in this case they are stored in a matrix) 57 print the model: 56 To see the coefficient of the model, print the model: 58 57 59 58 .. literalinclude:: code/plsexample.py 60 59 :lines: 22 61 60 62 The ouptut looks like this::61 :: 63 62 64 63 Regression coefficients: … … 68 67 X3 0.230 0.314 0.880 0.060 69 68 70 69 Note that coefficients are stored in a matrix since the model predicts 70 values of multiple outputs. 71 71 """ 72 72 … … 83 83 84 84 def normalize_matrix(X): 85 """ Normalizes matrix, i.e. subtracts column means86 and divides them by column standard deviations.87 Returns the standardized matrix, sample mean and88 standard deviation85 """ 86 Normalize a matrix columnwise: subtract the means and divide by 87 standard deviations. Returns the standardized matrix, sample mean 88 and standard deviation 89 89 90 90 :param X: data matrix … … 99 99 def nipals_xy(X, Y, mode="PLS", max_iter=500, tol=1e06): 100 100 """ 101 NIPALS algorithm . Returns the first left and rigth singular101 NIPALS algorithm; returns the first left and rigth singular 102 102 vectors of X'Y. 103 103 … … 108 108 :type mode: string 109 109 110 :param max_iter: maximal number of iterations (default 500)110 :param max_iter: maximal number of iterations (default: 500) 111 111 :type max_iter: int 112 112 113 :param tol: tolerance parameter ,if norm of difference113 :param tol: tolerance parameter; if norm of difference 114 114 between two successive left singular vectors is less than tol, 115 115 iteration is stopped … … 155 155 156 156 def svd_xy(X, Y): 157 """ Return sthe first left and right singular157 """ Return the first left and right singular 158 158 vectors of X'Y. 159 159 … … 169 169 170 170 def 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. 172 172 """ 173 173 domain = Orange.data.Domain(attributes, class_var) … … 178 178 179 179 class 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`_ 183 184 184 185 The class is derived from 185 :class:`Orange.regression.base.BaseRegressionLearner` 186 which isused for preprocessing the data (continuization and imputation)186 :class:`Orange.regression.base.BaseRegressionLearner` that is 187 used for preprocessing the data (continuization and imputation) 187 188 before fitting the regression parameters 188 189 … … 196 197 .. attribute:: n_comp 197 198 198 number of components to keep . Default: 2199 number of components to keep (default: 2) 199 200 200 201 .. attribute:: deflation_mode … … 209 210 .. attribute:: algorithm 210 211 211 The algorithm used to estimatethe weights:212 The algorithm for estimating the weights: 212 213 "nipals" or "svd" (default) 213 214 … … 231 232 :param x_vars, y_vars: List of input and response variables 232 233 (:obj:`Orange.feature.Continuous` or 233 :obj:`Orange.feature.Discrete`). If None(default) it is234 :obj:`Orange.feature.Discrete`). If ``None`` (default) it is 234 235 assumed that the data domain provides information which variables 235 236 are reponses and which are not. If data has … … 281 282 282 283 def fit(self, X, Y): 283 """ Fit sall unknown parameters, i.e.284 """ Fit all unknown parameters, i.e. 284 285 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. 287 287 """ 288 288 # copy since this will contain the residuals (deflated) matrices … … 365 365 366 366 class PLSRegression(Orange.classification.Classifier): 367 """ P LSRegression predicts valueof the response variables367 """ Predict values of the response variables 368 368 based on the values of independent variables. 369 369
Note: See TracChangeset
for help on using the changeset viewer.