natekupp/ffx

Using out-of-date scikit.learn

jmmcd opened this issue · 3 comments

It looks like scikit-learn has changed a lot since FFX was written. I had to edit core.py to import as follows:

from sklearn.linear_model import ElasticNet

After fixing that, it imported ok. When I ran the sample code in Readme.md, I got an error concerning args in ElasticNet.fit() (pasted below) -- I tried fiddling with the args, but then I got a different error, and I don't really know those modules, so I stopped fiddling.

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-1-5756048b6a36> in <module>()
      8 test_y = np.array( [3.03,0.9113,1.823])
      9 
---> 10 models = ffx.run(train_X, train_y, test_X, test_y, ["predictor_a", "predictor_b"])
     11 for model in models:
     12     yhat = model.simulate(test_X)

/Users/jmmcd/Documents/dev/anaconda/lib/python2.7/site-packages/ffx/api.pyc in run(train_X, train_y, test_X, test_y, varnames, verbose)
      2 
      3 def run(train_X, train_y, test_X, test_y, varnames=None, verbose=False):
----> 4     return core.MultiFFXModelFactory().build(train_X, train_y, test_X, test_y, varnames, verbose)

/Users/jmmcd/Documents/dev/anaconda/lib/python2.7/site-packages/ffx/core.py in build(self, train_X, train_y, test_X, test_y, varnames, verbose)
    441             ss = FFXBuildStrategy(approach)
    442 
--> 443             next_models = FFXModelFactory().build(train_X, train_y, ss, varnames, verbose)
    444 
    445             #set test_nmse on each model

/Users/jmmcd/Documents/dev/anaconda/lib/python2.7/site-packages/ffx/core.py in build(self, X, y, ss, varnames, verbose)
    582             target_train_nmse = 0.01
    583             models = self._basesToModels(
--> 584                 ss, varnames, order1_bases, X, y, max_num_bases, target_train_nmse, verbose) 
    585             if models is None: #fit failed.
    586                 model = ConstantModel(y[0], 0)

/Users/jmmcd/Documents/dev/anaconda/lib/python2.7/site-packages/ffx/core.py in _basesToModels(self, ss, varnames, bases, X, y, max_num_bases, target_train_nmse, verbose)
    681         #compute models.
    682         models = self._pathwiseLearn(ss, varnames, bases, X, regress_X, y, 
--> 683                                      max_num_bases, target_train_nmse, verbose)
    684         return models
    685 

/Users/jmmcd/Documents/dev/anaconda/lib/python2.7/site-packages/ffx/core.py in _pathwiseLearn(self, ss, varnames, bases, X_orig, X_orig_regress, y_orig, max_num_bases, target_nmse, verbose, **fit_params)
    727             try:
    728                 clf.fit(X_unbiased, y_unbiased, coef_init=cur_unbiased_coefs, 
--> 729                         max_iter=max_iter, **fit_params)
    730             except TimeoutError:
    731                 print '    Regularized update failed. Returning None'

/Users/jmmcd/Documents/dev/anaconda/lib/python2.7/site-packages/ffx/core.py in new_f(*args, **kwargs)
    839             signal.alarm(seconds_before_timeout)
    840             try:
--> 841                 result = f(*args, **kwargs)
    842             finally:
    843                 signal.signal(signal.SIGALRM, old)

/Users/jmmcd/Documents/dev/anaconda/lib/python2.7/site-packages/ffx/core.py in fit(self, *args, **kwargs)
    851     @timeout(MAX_TIME_REGULARIZE_UPDATE) #if this freezes, then exit with a TimeoutError
    852     def fit(self, *args, **kwargs):
--> 853         return ElasticNet.fit(self, *args, **kwargs)
    854 
    855 #========================================================================================

TypeError: fit() got an unexpected keyword argument 'precompute'

/Users/jmmcd/Documents/dev/anaconda/lib/python2.7/site-packages/sklearn/linear_model/coordinate_descent.py:137: DeprecationWarning: rho was renamed to l1_ratio and will be removed in 0.15
  "in 0.15", DeprecationWarning)

Fixed by 54a9a0e..3bba0f2.

Having the same issue. @natekupp are you planning to update the pip version any time soon?

@jmmcd I just updated core.py, now I'm getting #7