dist/multilabel/ThresholdClassifier.js
function(dataset) {

		_.times(3, function(n) {dataset = _.shuffle(dataset)})

		if (this.numOfFoldsForThresholdCalculation > 1) {
			thresholds=[]
			best_performances=[]
			average_performances = []
			median_performances = []
			partitions.partitions_consistent(dataset, this.numOfFoldsForThresholdCalculation, (function(trainSet, testSet, index) { 	 
				this.multiclassClassifier.trainBatch(trainSet);
				result = this.receiveScores(testSet)
				performance = this.CalculatePerformance(result[0], testSet, result[1])
				best_performances.push(performance)
			}).bind(this))

			this.stats = best_performances
					
			threshold_average = ulist.average(_.pluck(best_performances, 'Threshold'))
			threshold_median = ulist.median(_.pluck(best_performances, 'Threshold'))

			Threshold = threshold_median
		}
		else
		{
			dataset = partitions.partition(dataset, 1, Math.round(dataset.length*this.devsetsize))
			trainSet = dataset['train']
			testSet = dataset['test']
			this.multiclassClassifier.trainBatch(trainSet);
			result = this.receiveScores(testSet)
			performance = this.CalculatePerformance(result[0], testSet, result[1])
			Threshold = performance['Threshold']	
		}

		this.multiclassClassifier.threshold = Threshold
	}
function(dataset) {

		_.times(3, function(n) {dataset = _.shuffle(dataset)})

		if (this.numOfFoldsForThresholdCalculation > 1) {
			thresholds=[]
			best_performances=[]
			average_performances = []
			median_performances = []
			partitions.partitions_consistent(dataset, this.numOfFoldsForThresholdCalculation, (function(trainSet, testSet, index) { 	 
				this.multiclassClassifier.trainBatch(trainSet);
				result = this.receiveScores(testSet)
				performance = this.CalculatePerformance(result[0], testSet, result[1])
				best_performances.push(performance)
			}).bind(this))

			this.stats = best_performances
					
			threshold_average = ulist.average(_.pluck(best_performances, 'Threshold'))
			threshold_median = ulist.median(_.pluck(best_performances, 'Threshold'))

			Threshold = threshold_median
		}
		else
		{
			dataset = partitions.partition(dataset, 1, Math.round(dataset.length*this.devsetsize))
			trainSet = dataset['train']
			testSet = dataset['test']
			this.multiclassClassifier.trainBatch(trainSet);
			result = this.receiveScores(testSet)
			performance = this.CalculatePerformance(result[0], testSet, result[1])
			Threshold = performance['Threshold']	
		}

		this.multiclassClassifier.threshold = Threshold
	}
Train the classifier with all the given documents and identify the best possible threshold
simply by running over all relevant scores and determining the value of feedback function
(F1 by default)

@param dataset
an array with objects of the format:
{input: sample1, output: [class11, class12...]}
@author Vasily Konovalov