source: orange/docs/reference/rst/code/lasso-example.py @ 10859:08a0a35c1687

Revision 10859:08a0a35c1687, 450 bytes checked in by Lan Zagar <lan.zagar@…>, 2 years ago (diff)

Reimplemented lasso. Breaks compatibility.

It now uses a proximal gradient method for optimization instead of using scipy.optimize (see #1118).
The formulation is slightly different so there are new parameters (mainly lasso_lambda instead of t/s).
Improved some other things as well.

Line 
1# Description: Lasso regression
2# Category:    regression
3
4import Orange
5import numpy
6
7numpy.random.seed(0)
8
9housing = Orange.data.Table("housing")
10learner = Orange.regression.lasso.LassoRegressionLearner(
11    lasso_lambda=1, n_boot=100, n_perm=100)
12classifier = learner(housing)
13
14# prediction for five data instances
15for ins in housing[:5]:
16    print "Actual: %3.2f, predicted: %3.2f" % (
17        ins.get_class(), classifier(ins))
18
19print classifier
Note: See TracBrowser for help on using the repository browser.