PR welcome on this. I think Jaques you have it ready.

Best,
Alex

On Tue, May 7, 2013 at 11:42 AM, Jaques Grobler <jaquesgrob...@gmail.com> wrote:
>
>
>>
>> 2013/5/7 James D Jensen <jdjen...@ucsd.edu>
>> Thanks. You mentioned that I could "[add] positive to LassoCV and [pass]
>> it to the Lasso estimators used in the cross-val." In the directory of my
>> own installation of scikit-learn, I modified
>> sklearn/linear_model/coordinate_descent.py to include "positive=False" to
>> the parameter list of __init__ for the classes LassoCV, ElasticNetCV, and
>> LinearModelCV, and added "self.positive=positive" in the body of the
>> __init__ methods. However, calling LassoCV("positive=True", cv=20) still
>> gives me the error "TypeError: __init__() got an unexpected keyword
>> argument 'positive'".
>
>
> I tried that quickly and got no error. Just with the parameter lists of
> LinearModelCV
> and LassoCV, i changed this:
>
> in class LinearModelCV(LinearModel)
>
> def __init__(self, eps=1e-3, n_alphas=100, alphas=None, fit_intercept=True,
>                  normalize=False, precompute='auto', max_iter=1000,
> tol=1e-4,
>                  copy_X=True, cv=None, verbose=False, positive=False):
>
>         .....
>         self.positive = positive
>
> within LassoCV(LinearModelCV, RegressorMixin):
>
> def __init__(self, eps=1e-3, n_alphas=100, alphas=None, fit_intercept=True,
>                  normalize=False, precompute='auto', max_iter=1000,
> tol=1e-4,
>                  copy_X=True, cv=None, verbose=False, positive=False):
>         super(LassoCV, self).__init__(
>             eps=eps, n_alphas=n_alphas, alphas=alphas,
>             fit_intercept=fit_intercept, normalize=normalize,
>             precompute=precompute, max_iter=max_iter, tol=tol,
> copy_X=copy_X,
>             cv=cv, verbose=verbose, positive=positive)
>
> Then in ipython
>
> In [3]: coordinate_descent.LassoCV(positive=True, cv=20)
> Out[3]:
> LassoCV(alphas=None, copy_X=True, cv=20, eps=0.001, fit_intercept=True,
>     max_iter=1000, n_alphas=100, normalize=False, positive=True,
>     precompute='auto', tol=0.0001, verbose=False)
>
> Just have a look if you don't have any typos or you're missing something
> small.
> Goodluck!
>
>
>
>
>
>
>
>>
>> I appreciate your patience with me. I have been programming in Python for
>> only a few months and am no expert in machine learning. I imagine that I'm
>> overlooking or misunderstanding some things that are obvious to those with
>> more experience.
>>
>> I notice that Lasso inherits from ElasticNet, and that ElasticNet includes
>> the "positive" option, although some of the documentation for ElasticNet
>> doesn't seem to reflect this. I imagine that this means it would be at
>> least as straightforward for me to add the "positive" option to
>> ElasticNetCV as to LassoCV. ElasticNetCV may be even better for my problem
>> than LassoCV, since I expect many of my regressors to be correlated.
>>
>> I'm using these regularized regression methods as part of an iterative
>> solver for non-negative canonical correlation. CCA can be done by finding
>> w that minimizes ||Yv-Xw||^2, then scaling w by ||Xw||, then doing the
>> same for v, and so on back and forth until convergence. Lasso and
>> ElasticNet can be used for the minimization step. I'm realizing, however,
>> that the objective function I need to minimize will require an additional
>> quadratic term to enforce the orthogonality of each projection direction
>> to all previous directions. These methods from scikit-learn could give me
>> the first pair of canonical variables, but if I want to get subsequent
>> ones (and I do) I may have to use a more general-purpose optimization
>> library like scipy.optimize and define my own objective function.
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Learn Graph Databases - Download FREE O'Reilly Book
>> "Graph Databases" is the definitive new guide to graph databases and
>> their applications. This 200-page book is written by three acclaimed
>> leaders in the field. The early access version is available now.
>> Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
>> _______________________________________________
>> Scikit-learn-general mailing list
>> Scikit-learn-general@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
>
>
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and
> their applications. This 200-page book is written by three acclaimed
> leaders in the field. The early access version is available now.
> Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
> _______________________________________________
> Scikit-learn-general mailing list
> Scikit-learn-general@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
>

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and 
their applications. This 200-page book is written by three acclaimed 
leaders in the field. The early access version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
Scikit-learn-general mailing list
Scikit-learn-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

Reply via email to