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

How to predict average? #104

Open
smachs opened this issue May 6, 2018 · 0 comments
Open

How to predict average? #104

smachs opened this issue May 6, 2018 · 0 comments

Comments

@smachs
Copy link

smachs commented May 6, 2018

how can I predict the average value of an amount of data in an array?

For example i am use real currency using all the data in an array

var balance = [
    '1,98',
    '10,50',
    '500,47',
    '5.000,64',
    '5.206,64',
    '5.778,03',
    '70.000,29',
    '900.000,16',
   '1.000.000,07'
]

How can I predict that the average balance is 5k and corresponds to 70% of the total of all the array?

I was looking at some examples and in the below it can predict what will be the next number of the array in order of 0 to 9

            var my_data = [
                0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
                0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
                0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
                0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
                0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
                0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
                0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
                0, 1, 2, 3, 4, 5, 6, 7, 8
            ];

            var trainer = new convnetjs.SGDTrainer(net, { learning_rate: 0.01, momentum: 0.2, batch_size: 1, l2_decay: 0.001 });

            var learn = function () {
                for (var j = 0; j < 100; j++) {
                    for (var i = 0; i < my_data.length - d; i++) {
                        var data = my_data.slice(i, i + d);
                        var real_value = [my_data[i + d]];
                        var x = new convnetjs.Vol(data);
                        trainer.train(x, real_value);
                        var predicted_values = net.forward(x);
                        console.log("data: [" + data + "] -> value: " + real_value);
                        console.log("prediction in learn stage is: " + predicted_values.w[0]);
                    }
                }

            }

            var predict = function (data) {
                var x = new convnetjs.Vol(data);
                var predicted_value = net.forward(x);
                return predicted_value.w[0];
            }

            learn();
            var item = [0, 1, 2, 3, 4, 5, 6, 7, 8];
            console.log("predicted value for [" + item + "] is: " + predict(item));

is it possible to learn deeply to predict the average values of an array?

Thanks a lot for the help 👍

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

1 participant