Last active
August 29, 2015 14:19
-
-
Save logicmason/d010683e7c6fc3420819 to your computer and use it in GitHub Desktop.
Revisions
-
logicmason revised this gist
Apr 24, 2015 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -35,4 +35,7 @@ var reward(lever, amount) { var bucket = mycookie.currentLever; if (bucket.name === 'noCarousel') return; else if (bucket.name === 'crazyCarousel') launchCrazyCarousel(); else launchCarousel(); //upon conversion reward(bucket, amount); -
logicmason revised this gist
Apr 24, 2015 . 1 changed file with 7 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -29,4 +29,10 @@ var reward(lever, amount) { lever.conversions++; lever.revenue += amount; save(lever); // api call }; // In app var bucket = mycookie.currentLever; if (bucket.name === 'noCarousel') return; else if (bucket.name === 'crazyCarousel') launchCrazyCarousel(); else launchCarousel(); -
logicmason revised this gist
Apr 24, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ // Mini-bandit const explorationRatio = 0.1; // example levers array -
logicmason created this gist
Apr 24, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ Bandit const explorationRatio = 0.1; // example levers array /* [{name: 'control', trials: 412, conversions: 113, revenue: 22260}, {name: 'noCarousel', trials: 723, conversions: 298, revenue: 45390}, {name: 'crazyCarousel', trials: 19, conversions: 11, revenue: 6600} ] */ var choose = function(levers) { if (Math.random() < explorationRatio) { // exploration! // choose a random lever } else { // exploitation! levers.forEach((x) => { // calculate expected reward // this is trials / conversions or even trials / revenue bestLever = getLeverWithHighestReward(levers); assignBucket(bestLever); // store choice in cookie bestLever.trials++; // store test data in redis or something } } } var reward(lever, amount) { lever.conversions++; lever.revenue += amount; save(lever); // api call };