MonkeyJS

Distributed Machine Learning Framework based on Javascript

Eng - -

What is MonkeyJS

MonkeyJS is a machine learning framework based on Javascript, Web and Distributed Computing. MonkeyJS is specifically built for deriving models through the help of monkeys. Monkeys? Are you kidding me? You have probably heard the Infinite Monkey Theorem, a proposition that an unlimited number of monkeys, given typewriters and sufficient time, will eventually complete works of Shakespeare. Of course, our goal is not to produce the works of Shakespeare, but to do machine learning.



To fulfill this goal, we have hired a large number of monkeys around the globe. Learn More



A Simple Example
Suppose you have a dataset of match statistics for the English Premier League since season 2016/17 (the dataset in CSV can be downloaded here) and want to develop a betting model. You believe that the number of shot-on-target would be probably a determining factor in predicting the winner.

Step1: Propose a model

Therefore, you propose the following model:

Average Home Team Shots On Target > aANDAverage Away Team Shots On Target < b

* average shots on target in the past 7 matches

In Javascript, such a model will be written as:

avgHomeShotsOnTarget > a && avgAwayShotsOnTarget < b


We will come back when we discuss the Shakespeare Function in Step 3.

Step2: Identify the scope of parameters for training

If the above criteria matches, you place the bet on the home team. However, what are the optimal values of a and b? You start with some historical data and you can use MonkeyJS to help you to determine the results.

First of all, you need to define the range of a and b. You can do so by a scope.js:

 var scope = [
	"a#0-10:1",
	"b#0-10:1"
];

It means that a will be lying between 1 to 10 and with stepping up interval of 1. i.e the a will be any integer among 1,2,3,4,5,6,7,8,9 or 10. The same applies to b as well.

Step3: Build the Shakespeare Function

Then it comes to the most interesting part. The Shakespeare Function. The Shakespeare Function is a function MonkeyJS will run simulations for your model.

function Shakespeare() {
	var betamount = 50;
	var bankroll = 1000;
	var win_count = 0;
	var total_count = 0;
		
	for(var i=0;i<dataset.length-1;i++) {
		// get data from csv
		var avgHomeShotsOnTarget = monkey.datasetValue(i,'avgHomeShotsOnTarget');
		var avgAwayShotsOnTarget = monkey.datasetValue(i,'avgAwayShotsOnTarget');
		var odd_home = monkey.datasetValue(i,'odd_home');
		var odd_away = monkey.datasetValue(i,'odd_away');
		var homeScore = monkey.datasetValue(i,'homeScore');
		var awayScore = monkey.datasetValue(i,'awayScore');
		var tobet = false;
		
		// if losing all money
		if (bankroll < 0) return bankroll.toFixed(2);
		
		// Criteria
		if (avgHomeShotsOnTarget > a && avgAwayShotsOnTarget < b) {
			tobet=true;
		}
		
		if (tobet) {
			if (homeScore > awayScore) {
				bankroll = (bankroll - betamount) + betamount*odd_home;
				win_count++;
				total_count++;
			}
			else { 
				bankroll = bankroll - betamount;
				total_count++;
			}
		}
	}
	return bankroll.toFixed(2);
}		

Results:


          

Optimized parameters:


          

In about 80% of the cases, you will get a maximum bankroll of $3,319.5 with optimized parameters of a = 3 and b = 5, which is represented as: 3319.5[3,5]

Since you are starting from a bankroll of $1,000, which means your profit would be $2,319.5 if you have placed your bets (5% of bankroll) when the home team with an average Shots On Target (a) greater than 3 and the away team with an average Shots On Target (b) smaller than 5.

Although this betting model has resulted in a positive profit, this is a very simplified model and please don't rely on this to bet! However, if we can include more parameters, e.g. number of corners, free-kick, open-play, counter attack, league rankings etc., it is possible that derive a model with a positive return in long run, given this model is not recognized by the public. In fact, we are researching various betting models through the help of our monkeys. Please follow our Medium closely!

Wider the scope of parameters, more combinations of the parameters and more the computing power are required to train the model. You can probably gain optimized results with a scope with two parameters like the above example in 1-2 seconds by the use of your own browser. But this would not be the case if we have more parameters and that's why our network of monkeys can help.

You can now sign up, design and train your model with MonkeyJS for free. We have developed an easy-to-use dashboard and user-interfaces for you to test, deploy and monitor the progress of your machine learning models.

Screenshots of MonkeyJS Dashboard:


Pay

Receive

History

Settings

Log Out

Eng - -