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

Porting to JS #1

Open
bustavo opened this issue Nov 21, 2016 · 10 comments
Open

Porting to JS #1

bustavo opened this issue Nov 21, 2016 · 10 comments

Comments

@bustavo
Copy link
Owner

bustavo commented Nov 21, 2016

Will create a new branch for JS version of the predictor...

@bustavo
Copy link
Owner Author

bustavo commented Nov 22, 2016

@jasoncalabrese

I added the javascript_port branch...

Still some issues with passing arrays of data between the different functions...

Also the result is not the same as the ruby version... need to check where things are getting changed it probably has to do with the array slicing.

@bustavo
Copy link
Owner Author

bustavo commented Nov 25, 2016

Last commit on javascript_port branch now is returning a result, although its different from the ruby version... will now check where it is breaking and fix it.

@jasoncalabrese
Copy link

Thats great, it doesn't look like you pushed anything to your JS branch yet, once that's there I'll setup a NS branch to pull your branch in as a dependency, then you'll be able to make improvements that will get picked up with new deploys.

@bustavo
Copy link
Owner Author

bustavo commented Nov 26, 2016

@jasoncalabrese, I just updated the javascript_port branch...

index.html is where the JS is... If you run index.html on your browser and test with the same set of numbers as indicated on the Readme it should give you the same/very similar output...

I think there is an issue with how javascript rounds the numbers vs ruby but the output is very very similar.

Please test and let me know if it works so I can merge it to master.

@jasoncalabrese
Copy link

Oh, I didn't realize it was in the html, I was thinking it would be a node module that I could pull in, but it's easy to copy, so I'll give that a try.

@bustavo
Copy link
Owner Author

bustavo commented Nov 27, 2016

🙈 Let me extract into an independent js file

@bustavo
Copy link
Owner Author

bustavo commented Nov 27, 2016

@jasoncalabrese I just added simpancreas_predictor.js file...

The main function which gives you the ability to predict one number or a series of numbers is:
get_prediction(bg_data,dates)

I added it the ability to receive 'dates' ( which are optional... if none are passed, the function will autogenerate 5 minute separated dates )

If you want to know the format for dates, use the following function:
generate_dummy_date_data(bg_data)

@jasoncalabrese
Copy link

Great, thanks

@jasoncalabrese
Copy link

I played with the html test page a little, I was expecting the results to be an array of points going into the future, but only 1 is returned

100,102,105,106,108 -> 111

I saw with there was a check to only return multiple predictions if there are more than 9 points, but even with extra points I get nulls.

100,102,105,106,108,110,118,120,121 -> null,null,null,null,null,null,null,null,106

@bustavo
Copy link
Owner Author

bustavo commented Nov 30, 2016

There are two ways to get predictions for the index.html demo file...

If you want to predict only 1 point in time, you send a set of 5 points and get returned one point in time like the first example you point out.

If you want to send a lot of data points and then see how the prediction looks for that set of data points, you send lots of data points. The returned array starts with nil points so you can compare them side to side. The first predicted point needs 5 data points ( that is why you have 4 null points ) then the prediction will be 20 min ahead ( hence the other 4 null points ) and afterwards you start getting the predictions for the rest of the data points.

If you always want to get 1 prediction point, use:
bg_prediction(periods,cur_bg,bg_array,bg_date_array,time)

Please let me know if it is confusing so I can try to explain it better...

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