natekupp / ffx

Fast Function Extraction
http://trent.st/ffx
Other
80 stars 93 forks source link

TypeError: slice indices must be integers or None or have an __index__ method #28

Closed thiemom closed 6 years ago

thiemom commented 6 years ago

Hi, just tried the example. Alas, no success ...

# now trying ffx
import numpy as np
import ffx

train_X = np.array( [ (1.5,2,3), (4,5,6) ] ).T
train_y = np.array( [1,2,3])

test_X = np.array( [ (5.241,1.23, 3.125), (1.1,0.124,0.391) ] ).T
test_y = np.array( [3.03,0.9113,1.823])

models = ffx.run(train_X, train_y, test_X, test_y, ["a", "b"])
for model in models:
    yhat = model.simulate(test_X)
    print(model)

I'm running: numpy version 1.12.1 scikit-learn version 0.18.1 Python 3.6.1 |Anaconda 4.4.0 (x86_64)| (default, May 11 2017, 13:04:09) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin

Trace:

TypeError Traceback (most recent call last)

in () 9 test_y = np.array( [3.03,0.9113,1.823]) 10 ---> 11 models = ffx.run(train_X, train_y, test_X, test_y, ["a", "b"]) 12 for model in models: 13 yhat = model.simulate(test_X) /Users/thiemo/miniconda3/envs/py36_64/lib/python3.6/site-packages/ffx/api.py 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/thiemo/miniconda3/envs/py36_64/lib/python3.6/site-packages/ffx/core.py in build(self, train_X, train_y, test_X, test_y, varnames, verbose) 557 ss = FFXBuildStrategy(approach) 558 --> 559 next_models = FFXModelFactory().build(train_X, train_y, ss, varnames, verbose) 560 561 # set test_nmse on each model /Users/thiemo/miniconda3/envs/py36_64/lib/python3.6/site-packages/ffx/core.py in build(self, X, y, ss, varnames, verbose) 709 target_train_nmse = 0.01 710 models = self._basesToModels( --> 711 ss, varnames, order1_bases, X, y, max_num_bases, target_train_nmse, verbose) 712 if models is None: # fit failed. 713 model = ConstantModel(y[0], 0) /Users/thiemo/miniconda3/envs/py36_64/lib/python3.6/site-packages/ffx/core.py in _basesToModels(self, ss, varnames, bases, X, y, max_num_bases, target_train_nmse, verbose) 829 # compute models. 830 models = self._pathwiseLearn(ss, varnames, bases, X, regress_X, y, --> 831 max_num_bases, target_train_nmse, verbose) 832 return models 833 /Users/thiemo/miniconda3/envs/py36_64/lib/python3.6/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) 863 st, fin = numpy.log10(alpha_max * ss.eps()), numpy.log10(alpha_max) 864 alphas1 = numpy.logspace( --> 865 st, fin, num=ss.numAlphas() * 10)[::-1][:ss.numAlphas() / 4] 866 alphas2 = numpy.logspace(st, fin, num=ss.numAlphas()) 867 alphas = sorted(set(alphas1).union(alphas2), reverse=True) TypeError: slice indices must be integers or None or have an __index__ method
jmmcd commented 6 years ago

Duplicate of #25.

(We should make a new release with this fix since it will break everyone on Python 3.)