Skip to content

Instantly share code, notes, and snippets.

@theianchan
Created September 7, 2017 07:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theianchan/0752a42b9c90d4152c1701d5e073ad3e to your computer and use it in GitHub Desktop.
Save theianchan/0752a42b9c90d4152c1701d5e073ad3e to your computer and use it in GitHub Desktop.
var PARAM_M = "J79";
var PARAM_B = "J80";
var PARAM_EPOCH = "E79";
var PARAM_LEARN = "E80";
var RMSE = "M79";
var NEW_M = "J104";
var NEW_B = "M104";
function updateParameters(m, b) {
var ss = SpreadsheetApp.getActiveSheet();
ss.getRange(PARAM_M).setValue(m);
ss.getRange(PARAM_B).setValue(b);
}
function runEpoch() {
var ss = SpreadsheetApp.getActiveSheet();
var newM = ss.getRange(NEW_M).getDisplayValue();
var newB = ss.getRange(NEW_B).getDisplayValue();
appendTable();
updateParameters(m=newM, b=newB);
}
function appendTable() {
var ss = SpreadsheetApp.getActiveSheet();
var m = ss.getRange(PARAM_M).getDisplayValue();
var b = ss.getRange(PARAM_B).getDisplayValue();
var learn = ss.getRange(PARAM_LEARN).getDisplayValue();
var rmse = ss.getRange(RMSE).getDisplayValue();
var row = (ss.getLastRow() + 1).toString();
ss.getRange("B" + row + ":E" + row).setValues([[m, b, learn, rmse]]);
}
function runEpochs() {
var ss = SpreadsheetApp.getActiveSheet();
var numEpochs = ss.getRange(PARAM_EPOCH).getDisplayValue();
for (var i = 0; i < numEpochs; i++) {
runEpoch();
}
}
function reset() {
updateParameters(1, 1);
var ss = SpreadsheetApp.getActiveSheet();
var table = ss.getRange("B109:E" + ss.getLastRow().toString());
table.clear();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment