Changeset 9776:600ac31393ee in orange for Orange/regression/lasso.py
 Timestamp:
 02/06/12 17:39:53 (2 years ago)
 Branch:
 default
 rebase_source:
 aeea356a746ae91cb578766fe56376f160e20257
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

Orange/regression/lasso.py
r9671 r9776 10 10 11 11 12 Example :: 13 14 >>> from Orange.regression import lasso 15 >>> table = Orange.data.Table("housing") 16 >>> c = lasso.LassoRegressionLearner(table) 17 >>> print c 18 19 Variable Coeff Est Std Error p 20 Intercept 22.533 21 CRIM 0.044 0.030 0.510 22 ZN 0.013 0.010 0.660 23 INDUS 0.003 0.023 0.980 24 CHAS 2.318 1.304 0.200 25 NOX 7.530 2.803 0.370 26 RM 4.231 0.819 0.000 *** 27 DIS 0.710 0.130 0.070 . 28 RAD 0.074 0.029 0.510 29 TAX 0.004 0.002 0.560 30 PTRATIO 0.821 0.095 0.000 *** 31 B 0.007 0.002 0.170 32 LSTAT 0.503 0.085 0.000 *** 33 Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 empty 1 34 35 36 For 1 variable the regression coefficient equals 0: 37 AGE 38 39 >>> 40 12 `The Lasso <http://wwwstat.stanford.edu/~tibs/lasso/lasso.pdf>`_ is a shrinkage 13 and selection method for linear regression. It minimizes the usual sum of squared 14 errors, with a bound on the sum of the absolute values of the coefficients. 15 16 To fit the regression parameters on housing data set use the following code: 17 18 .. literalinclude:: code/lassoexample.py 19 :lines: 7,9,10,11 41 20 42 21 .. autoclass:: LassoRegressionLearner … … 46 25 :members: 47 26 27 28 .. autoclass:: LassoRegressionLearner 29 :members: 30 31 .. autoclass:: LassoRegression 32 :members: 33 48 34 Utility functions 49 35  … … 54 40 55 41 .. autofunction:: permute_responses 42 43 44 ======== 45 Examples 46 ======== 47 48 To predict values of the response for the first five instances 49 use the code 50 51 .. literalinclude:: code/lassoexample.py 52 :lines: 14,15 53 54 Output 55 56 :: 57 58 Actual: 24.00, predicted: 24.58 59 Actual: 21.60, predicted: 23.30 60 Actual: 34.70, predicted: 24.98 61 Actual: 33.40, predicted: 24.78 62 Actual: 36.20, predicted: 24.66 63 64 To see the fitted regression coefficients, print the model 65 66 .. literalinclude:: code/lassoexample.py 67 :lines: 17 68 69 The output 70 71 :: 72 73 Variable Coeff Est Std Error p 74 Intercept 22.533 75 CRIM 0.000 0.023 0.480 76 INDUS 0.010 0.023 0.300 77 RM 1.303 0.994 0.000 *** 78 AGE 0.002 0.000 0.320 79 PTRATIO 0.191 0.209 0.050 . 80 LSTAT 0.126 0.105 0.000 *** 81 Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 empty 1 82 83 84 For 7 variables the regression coefficient equals 0: 85 ZN 86 CHAS 87 NOX 88 DIS 89 RAD 90 TAX 91 B 92 93 shows that some of the regression coefficients are equal to 0. 94 95 96 97 56 98 57 99 """ … … 265 307 .. attribute:: coef0 266 308 267 intercept (sample mean of the response variable)309 Intercept (sample mean of the response variable). 268 310 269 311 .. attribute:: coefficients 270 312 271 list of regression coefficients.313 Regression coefficients, sotred in list. 272 314 273 315 .. attribute:: std_errors_fixed_t 274 316 275 list of standard errors of the coefficient estimator for the fixed317 Standard errors of the coefficient estimator for the fixed 276 318 tuning parameter t. The standard errors are estimated using 277 319 bootstrapping method. … … 279 321 .. attribute:: p_vals 280 322 281 list of pvalues for the null hypothesis that the regression282 coefficients equal 0 based on nonparametric permutation test 323 List of pvalues for the null hypothesis that the regression 324 coefficients equal 0 based on nonparametric permutation test. 283 325 284 326 .. attribute:: dict_model 285 327 286 dictionary of statistical properties of the model.328 Statistical properties of the model stored in dictionary: 287 329 Keys  names of the independent variables 288 330 Values  tuples (coefficient, standard error, pvalue) … … 290 332 .. attribute:: mu_x 291 333 292 the sample mean of the all independent variables334 Sample mean of the all independent variables. 293 335 294 336 """
Note: See TracChangeset
for help on using the changeset viewer.