// utility functions
Array.prototype.contains = function(v) {
for(var i = 0; i < this.length; i++) {
if(this[i] === v) return true;
}
return false;
};
Array.prototype.unique = function() {
var arr = [];
for(var i = 0; i < this.length; i++) {
if(!arr.contains(this[i])) {
arr.push(this[i]);
}
}
return arr;
}
function FAIL(outdivid, msg) {
$(outdivid).prepend("
"+msg+"
")
}
function SUCC(outdivid, msg) {
$(outdivid).prepend(""+msg+"
")
}
// looks at a column i of data and guesses what's in it
// returns results of analysis: is column numeric? How many unique entries and what are they?
function guessColumn(data, c) {
var numeric = true;
var vs = [];
for(var i=0,n=data.length;i 20 && i>3 && i < D-3) {
if(i==4) {
SUCC(outdivid, "..."); // suppress output for too many columns
}
} else {
SUCC(outdivid, "column " + i + " looks " + (res.numeric ? "numeric" : "NOT numeric") + " and has " + res.num + " unique elements");
}
}
return {arr: arr, colstats: colstats};
}
// process input mess into vols and labels
function makeDataset(arr, colstats) {
var labelix = parseInt($("#labelix").val());
if(labelix < 0) labelix = D + labelix; // -1 should turn to D-1
var data = [];
var labels = [];
for(var i=0;i 0) {
t += 'Results based on ' + c.acc.length + ' folds:';
t += 'best model in current batch (validation accuracy ' + mm.maxv + '):
';
t += 'Net layer definitions:
';
t += JSON.stringify(cm.layer_defs);
t += '
Trainer definition:
';
t += JSON.stringify(cm.trainer_def);
t += '
';
}
$('#bestmodel').html(t);
// also print out the best model so far
var t = '';
if(magicNet.evaluated_candidates.length > 0) {
var cm = magicNet.evaluated_candidates[0];
t += 'validation accuracy of best model so far, overall: ' + cm.accv / cm.acc.length + '
';
t += 'Net layer definitions:
';
t += JSON.stringify(cm.layer_defs);
t += '
Trainer definition:
';
t += JSON.stringify(cm.trainer_def);
t += '
';
}
$('#bestmodeloverall').html(t);
}
}
// TODO: MOVE TO CONVNETJS UTILS
var randperm = function(n) {
var i = n,
j = 0,
temp;
var array = [];
for(var q=0;q