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

Predict Example #17

Open
kikolobo opened this issue Jul 16, 2022 · 3 comments
Open

Predict Example #17

kikolobo opened this issue Jul 16, 2022 · 3 comments

Comments

@kikolobo
Copy link

Hello,

I am wondering what is the value of the variable X in the predict function? (The parameter we pass)..

Say I have 3 values pushed to the Average storage.

Lets say: 1, 2 and 4

And I want to predict what value comes next given this set. What should I pass as X or as predict parameter?

Thanks in advance.

@majenkotech
Copy link
Contributor

Prediction uses the least squares function to make a y=mx+c representation of the data (a straight line). The X you pass is the X in that formula.

If you draw the data on a graph predict gives you the y value at point X on the graph.

@kikolobo
Copy link
Author

Thank you for the prompt response.

So can we say X is a position in the internal array?

Normally X would be time in my application, but in this case there is no time reference in the internal storage, I am guessing a future index of the array is X for the prediction?

More concrete.. I am reading a load cell and I am getting KG 100 times per seconds. I am storing this value in Average library with push. The size of the storage is 100 slices.

I am trying to predict what weight will I get next given a linear action of adding weights to the cell?

Would X be 101? (If we have more than a 100 samples)?

@majenkotech
Copy link
Contributor

X can be any value you want. If you have 100 data points then any value of X from 0 to 99 should give approximately the value in the array at that point. Any X bigger than 99 will be the value at that point in the future. Any X smaller than 0 will be the value at that point in the past.

At 100 samples per second an X in the order of 200 will be the estimated value one second in the future. An X of 100 will give you an estimated value for the next sample taken.

As I say the formula is y=mx+c which is a straight line graph:

y=mx+c

So any point on the X axis below the size of your array (remember, arrays count from 0 not 1) should correspond to past data, and any point on the X axis equal to or greater than the size of your array will be an estimate of future values.

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