Instantly share code, notes, and snippets.

Embed
What would you like to do?
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