1 | ############################ |
---|

2 | Lasso regression (``lasso``) |
---|

3 | ############################ |
---|

4 | |
---|

5 | .. automodule:: Orange.regression.lasso |
---|

6 | |
---|

7 | .. index:: regression |
---|

8 | |
---|

9 | .. _`Lasso regression. Regression shrinkage and selection via the lasso`: |
---|

10 | http://www-stat.stanford.edu/~tibs/lasso/lasso.pdf |
---|

11 | |
---|

12 | |
---|

13 | `The Lasso <http://www-stat.stanford.edu/~tibs/lasso/lasso.pdf>`_ is a shrinkage |
---|

14 | and selection method for linear regression. It minimizes the usual sum of squared |
---|

15 | errors, with a bound on the sum of the absolute values of the coefficients. |
---|

16 | |
---|

17 | To fit the regression parameters on housing data set use the following code: |
---|

18 | |
---|

19 | .. literalinclude:: code/lasso-example.py |
---|

20 | :lines: 9,10,11 |
---|

21 | |
---|

22 | .. autoclass:: LassoRegressionLearner |
---|

23 | :members: |
---|

24 | |
---|

25 | .. autoclass:: LassoRegression |
---|

26 | :members: |
---|

27 | |
---|

28 | |
---|

29 | .. autoclass:: LassoRegressionLearner |
---|

30 | :members: |
---|

31 | |
---|

32 | .. autoclass:: LassoRegression |
---|

33 | :members: |
---|

34 | |
---|

35 | Utility functions |
---|

36 | ----------------- |
---|

37 | |
---|

38 | .. autofunction:: center |
---|

39 | |
---|

40 | .. autofunction:: get_bootstrap_sample |
---|

41 | |
---|

42 | .. autofunction:: permute_responses |
---|

43 | |
---|

44 | |
---|

45 | ======== |
---|

46 | Examples |
---|

47 | ======== |
---|

48 | |
---|

49 | To predict values of the response for the first five instances |
---|

50 | use the code |
---|

51 | |
---|

52 | .. literalinclude:: code/lasso-example.py |
---|

53 | :lines: 14,15 |
---|

54 | |
---|

55 | Output |
---|

56 | |
---|

57 | :: |
---|

58 | |
---|

59 | Actual: 24.00, predicted: 24.58 |
---|

60 | Actual: 21.60, predicted: 23.30 |
---|

61 | Actual: 34.70, predicted: 24.98 |
---|

62 | Actual: 33.40, predicted: 24.78 |
---|

63 | Actual: 36.20, predicted: 24.66 |
---|

64 | |
---|

65 | To see the fitted regression coefficients, print the model |
---|

66 | |
---|

67 | .. literalinclude:: code/lasso-example.py |
---|

68 | :lines: 17 |
---|

69 | |
---|

70 | The output |
---|

71 | |
---|

72 | :: |
---|

73 | |
---|

74 | Variable Coeff Est Std Error p |
---|

75 | Intercept 22.533 |
---|

76 | CRIM -0.000 0.023 0.480 |
---|

77 | INDUS -0.010 0.023 0.300 |
---|

78 | RM 1.303 0.994 0.000 *** |
---|

79 | AGE -0.002 0.000 0.320 |
---|

80 | PTRATIO -0.191 0.209 0.050 . |
---|

81 | LSTAT -0.126 0.105 0.000 *** |
---|

82 | Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 empty 1 |
---|

83 | |
---|

84 | |
---|

85 | For 7 variables the regression coefficient equals 0: |
---|

86 | ZN |
---|

87 | CHAS |
---|

88 | NOX |
---|

89 | DIS |
---|

90 | RAD |
---|

91 | TAX |
---|

92 | B |
---|

93 | |
---|

94 | shows that some of the regression coefficients are equal to 0. |
---|

95 | |
---|