Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError('Not enough data points') #72

Closed
iclucho opened this issue Aug 17, 2017 · 7 comments
Closed

ValueError('Not enough data points') #72

iclucho opened this issue Aug 17, 2017 · 7 comments

Comments

@iclucho
Copy link

iclucho commented Aug 17, 2017

Hi,

I'm trying to run a SMA fit on my data but I can't seem to enter it correctly. My x-data is a 1062x4 matrix and correspondingly my y-data is a 1062x1 vector.

x
array([[ -0.69314718, -1.2039728 , -13.81551056, -13.81551056],
[ -0.65392647, -1.2039728 , -13.81551056, -13.81551056],
[ -0.61618614, -1.2039728 , -13.81551056, -13.81551056],
...,
[ 0.37843644, 0.18232156, -11.51292546, -9.21034037],
[ 0.39204209, 0.18232156, -11.51292546, -9.21034037],
[ 0.40546511, 0.18232156, -11.51292546, -9.21034037]])

x.shape
(1062, 4)

y
array([-10.09725113, -10.0955659 , -10.09396532, ..., -5.87544124,
-5.87526203, -5.87509244])

y.shape
(1062,)

When I try to run the fit, I get the following error:

cSMA, errorSMA = fit(x,y,K,"SMA")
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/dist-packages/gpfit/fit.py", line 72, in fit
params = get_params(ftype, K, xdata, ydata)
File "/usr/local/lib/python2.7/dist-packages/gpfit/fit.py", line 26, in get_params
ba = ba_init(xdata, ydata.reshape(ydata.size, 1), K).flatten('F')
File "/usr/local/lib/python2.7/dist-packages/gpfit/ba_init.py", line 36, in ba_init
raise ValueError('Not enough data points')
ValueError: Not enough data points

I know that this is probably not a tool error but a user-keyboard bug, but I just don't get what could be the problem here. Any pointers are much appreciated.

Regards,

Lucho.

@bqpd
Copy link
Contributor

bqpd commented Aug 17, 2017

You probably need to transpose x, as in this example:

from gpfit.fit import fit
from numpy import logspace, log, log10, random

# fixed initial guess for fitting
random.seed(33404)

u = 100*random.random((1062, 4)) + 1
# note: should be (4, 1062), we'll fix this on the next line
u = u.T
w = (u**2).sum(axis=1)
x = log(u)
y = log(w)
K = 4

cSMA, errorSMA = fit(x, y, K, "SMA")

print "SMA RMS Error: %.5g" % errorSMA

@bqpd
Copy link
Contributor

bqpd commented Aug 17, 2017

(also, welcome to gpfit / gpkit! Always curious to hear what uses it's finding, how you heard about it, and how we can make it more useful to you: give the feedback here or via email to gpkit@mit.edu)

@iclucho
Copy link
Author

iclucho commented Aug 17, 2017

Thanks bqpd!

I actually tried to transpose y-data but not the x-data :p

@bqpd
Copy link
Contributor

bqpd commented Aug 17, 2017

(the first thing I'm noticing here is that that required shape is...odd. I understand why it was done in the original code, but I'm going to add it to the list of things to change now that I'm the maintainer)

@bqpd bqpd mentioned this issue Aug 17, 2017
4 tasks
@bqpd
Copy link
Contributor

bqpd commented Aug 17, 2017

(also note that the docstring has this info! Since I don't know your level of Python experience, I'll note that you can see this and much additional documentationby typing help(fit) into an interactive session)

@iclucho
Copy link
Author

iclucho commented Aug 17, 2017

I'm pretty much an absolute beginner. I'm used to work with MATLAB. My intention is to use gpfit/kit in IC design. I read the paper "Fitting geometric programming models to data" and I'm curious to see how can this extended GP approach help me in analog design automation. Thanks for your quick reply and for sure I'll be dropping questions here.

@bqpd
Copy link
Contributor

bqpd commented Aug 17, 2017

Awesome! We don't do much IC stuff in the lab; we've talked about abstractions/syntax for making it easy to connect components, but without much chance to apply them they've gone stale, so let me know if you end up with something monolithic and complex that could use some more modularity. :)

@bqpd bqpd closed this as completed Aug 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants