function(sample, explain, withScores) {
		var labels = []
		var scores = []
		var explanations = [];
		var positive_explanations = {};
		var negative_explanations = []

		for (var label in this.mapClassnameToClassifier) {
			var classifier = this.mapClassnameToClassifier[label];

			if (this.debug) console.dir("Classify for class="+label)
			
			// fs.writeFileSync('/tmp/labels/'+label, JSON.stringify(classifier.getFeatures(), null, 4), 'utf8');

			var scoreWithExplain = classifier.classify(sample, explain, withScores);
			if (this.debug) console.log(JSON.stringify(scoreWithExplain, null, 4))

			var score = scoreWithExplain.explanation?  scoreWithExplain.classification: scoreWithExplain;
			if (this.debug) console.dir("score="+score)

			explanations_string = scoreWithExplain.explanation

			// if (score>0.5)
			if (score>0)
				{
				labels.push([label, score])
				if (explanations_string) positive_explanations[label]=explanations_string;
				}
			else
				{
				if (explanations_string) negative_explanations.push([label, score, explanations_string])
				}

			scores.push([label,score])
		}

		if (this.debug) console.dir(scores)

		if (explain>0)
		{
			scores = _.sortBy(scores, function(num){ return num[1] }).reverse()
			var scores_hash = _.object(scores)

			negative_explanations = _.sortBy(negative_explanations, function(num){ return num[1] }).reverse()
			negative_explanations = _.map(negative_explanations, function(num){ return [num[0],num[2]] });

			var negative_explanations_hash = _.object(negative_explanations)
		}

		labels = _.sortBy(labels, function(num){ return num[1] });
		labels = _.map(labels.reverse(), function(num){ return num[0] });

		return (explain>0?
			{
				classes: labels, 
				scores: scores_hash,
				explanation: {
					positive: positive_explanations, 
					negative: negative_explanations_hash,
				}
			}:
			labels);
	}
function(sample, explain, withScores) {
		var labels = []
		var scores = []
		var explanations = [];
		var positive_explanations = {};
		var negative_explanations = []

		for (var label in this.mapClassnameToClassifier) {
			var classifier = this.mapClassnameToClassifier[label];

			if (this.debug) console.dir("Classify for class="+label)
			
			

			var scoreWithExplain = classifier.classify(sample, explain, withScores);
			if (this.debug) console.log(JSON.stringify(scoreWithExplain, null, 4))

			var score = scoreWithExplain.explanation?  scoreWithExplain.classification: scoreWithExplain;
			if (this.debug) console.dir("score="+score)

			explanations_string = scoreWithExplain.explanation

			
			if (score>0)
				{
				labels.push([label, score])
				if (explanations_string) positive_explanations[label]=explanations_string;
				}
			else
				{
				if (explanations_string) negative_explanations.push([label, score, explanations_string])
				}

			scores.push([label,score])
		}

		if (this.debug) console.dir(scores)

		if (explain>0)
		{
			scores = _.sortBy(scores, function(num){ return num[1] }).reverse()
			var scores_hash = _.object(scores)

			negative_explanations = _.sortBy(negative_explanations, function(num){ return num[1] }).reverse()
			negative_explanations = _.map(negative_explanations, function(num){ return [num[0],num[2]] });

			var negative_explanations_hash = _.object(negative_explanations)
		}

		labels = _.sortBy(labels, function(num){ return num[1] });
		labels = _.map(labels.reverse(), function(num){ return num[0] });

		return (explain>0?
			{
				classes: labels, 
				scores: scores_hash,
				explanation: {
					positive: positive_explanations, 
					negative: negative_explanations_hash,
				}
			}:
			labels);
	}
function ( sample , explain , withScores ) { var labels = [ ] var scores = [ ] var explanations = [ ] ; var positive_explanations = { } ; var negative_explanations = [ ] for ( var label in this . mapClassnameToClassifier ) { var classifier = this . mapClassnameToClassifier [ label ] ; if ( this . debug ) console . dir ( "Classify for class=" + label ) // fs.writeFileSync('/tmp/labels/'+label, JSON.stringify(classifier.getFeatures(), null, 4), 'utf8'); var scoreWithExplain = classifier . classify ( sample , explain , withScores ) ; if ( this . debug ) console . log ( JSON . stringify ( scoreWithExplain , null , 4 ) ) var score = scoreWithExplain . explanation ? scoreWithExplain . classification : scoreWithExplain ; if ( this . debug ) console . dir ( "score=" + score ) explanations_string = scoreWithExplain . explanation // if (score>0.5) if ( score > 0 ) { labels . push ( [ label , score ] ) if ( explanations_string ) positive_explanations [ label ] = explanations_string ; } else { if ( explanations_string ) negative_explanations . push ( [ label , score , explanations_string ] ) } scores . push ( [ label , score ] ) } if ( this . debug ) console . dir ( scores ) if ( explain > 0 ) { scores = _ . sortBy ( scores , function ( num ) { return num [ 1 ] } ) . reverse ( ) var scores_hash = _ . object ( scores ) negative_explanations = _ . sortBy ( negative_explanations , function ( num ) { return num [ 1 ] } ) . reverse ( ) negative_explanations = _ . map ( negative_explanations , function ( num ) { return [ num [ 0 ] , num [ 2 ] ] } ) ; var negative_explanations_hash = _ . object ( negative_explanations ) } labels = _ . sortBy ( labels , function ( num ) { return num [ 1 ] } ) ; labels = _ . map ( labels . reverse ( ) , function ( num ) { return num [ 0 ] } ) ; return ( explain > 0 ? { classes : labels , scores : scores_hash , explanation : { positive : positive_explanations , negative : negative_explanations_hash , } } : labels ) ; }
Use the model trained so far to classify a new sample.

@param sample a document.
@param explain - int - if positive, an "explanation" field, with the given length, will be added to the result.
@param withScores - boolean - if true, return an array of [class,score], ordered by decreasing order of score.

@return an array whose VALUES are the labels.
@output
scores [hash] - the scores of each binary classifier in the class
explanations [hash] positive - features of the classifier with positive labels
negative - features of classifiers with negative labels
classes [list] the list of given labels
Use the model trained so far to classify a new sample .