static/js/drawer.js
// return 5 length array, each element is [probability,category_name] 
return 5 length array, each element is [probability,category_name]
return 5 length array each element is [ probability category_name ]
function grabMaxOutput(prediction){
    var topIndices = [];
    var maxOut=[];
        for (var i = 0; i < prediction.length; i++){
            topIndices.push(i);
            if (topIndices.length>5){
                topIndices.sort(function(a,b){
                    return prediction[b]-prediction[a];
                });
                topIndices.pop();
            }
        }
    topIndices.forEach(function(index){
        maxOut.push([prediction[index],categ25[index]]);
    })
    return maxOut;
}
function grabMaxOutput ( prediction ) { var topIndices = [ ] ; var maxOut = [ ] ; for ( var i = 0 ; i < prediction . length ; i ++ ) { topIndices . push ( i ) ; if ( topIndices . length > 5 ) { topIndices . sort ( function ( a , b ) { return prediction [ b ] - prediction [ a ] ; } ) ; topIndices . pop ( ) ; } } topIndices . forEach ( function ( index ) { maxOut . push ( [ prediction [ index ] , categ25 [ index ] ] ) ; } ) return maxOut ; }
return 5 length array, each element is [probability,category_name]
return 5 length array each element is [ probability category_name ]
// Sort the arry of indices base on prediction value and pop the lowest // console.log('Probabilities') // console.log(prediction[index]); // console.log(categ25[index]);