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

Exponential Regression Doens't Accept Negative Y Values #117

Open
JimLynchCodes opened this issue Jan 17, 2021 · 3 comments
Open

Exponential Regression Doens't Accept Negative Y Values #117

JimLynchCodes opened this issue Jan 17, 2021 · 3 comments

Comments

@JimLynchCodes
Copy link

Hi, I am trying to fit an exponential curve to some points that have negative initial values.

For example, these points:

const exponentialPoints = [[0.1, -0.25], [1, 1.1], [2, 5], [4, 30]] 

When I run it through regression.exponential(exponentialPoints) it outputs a regression model where all the y values are "NaN"... 🤔

{
  points: [ [ 0.1, NaN ], [ 1, NaN ], [ 2, NaN ], [ 4, NaN ] ],
  predict: [Function: predict],
  equation: [ NaN, NaN ],
  string: 'y = NaNe^(NaNx)',
  r2: NaN
}

I am wondering why this is happening. I would think it's perfectly fine for an exponential curve to have negative y values.

For example, consider this line: y = 2 * e^(3x) - 7

(and see it plotted here: https://www.wolframalpha.com/input/?i=plot+y%3D+2+*+e%5E%283x%29+-+7)

You can also run the code here: https://repl.it/@JimLynch/exponential-reg-negative-y#index.js

Thanks!

@Jezternz
Copy link

I had this problem also by even just having the first value as [0, 0]. Checking out another repo mentioned on another issue: https://github.com/mljs/ml#regression.

@Jezternz
Copy link

I had this problem also by even just having the first value as [0, 0]. Checking out another repo mentioned on another issue: https://github.com/mljs/ml#regression.

That one doesn't seem to be much better, struggles to handle similar problems. I am shocked at how hard it seems to be to find a reasonable library to do this.

@josephrocca
Copy link

It also NaNs on non-negative examples:

eval(await fetch("https://cdnjs.cloudflare.com/ajax/libs/regression/2.0.1/regression.min.js").then(r => r.text()));
let data = [[0,0],[1,0],[2,0],[3,1],[4,2],[5,0],[6,10],[7,20],[8,30],[9,10],[10,50],[11,70],[12,100],[13,250],[14,100],[15,300],[16,700]];
regression.exponential(data);

image

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

3 participants