dist/multilabel/ThresholdClassifier.js
function(opts) {
	
	opts = opts || {};

	if (!('multiclassClassifierType' in opts)) {
		console.dir(opts);
		throw new Error("opts must contain multiclassClassifierType");
	}
	if (!opts.multiclassClassifierType) {
		console.dir(opts);
		throw new Error("opts.multiclassClassifierType is null");
	}

	if (!('evaluateMeasureToMaximize' in opts)) {
		console.dir(opts);
		throw new Error("opts must contain evaluateMeasureToMaximize");
	}
	if (!opts.evaluateMeasureToMaximize) {
		console.dir(opts);
		throw new Error("opts.evaluateMeasureToMaximize is null");
	}
	if (!opts.numOfFoldsForThresholdCalculation) {
		console.dir(opts);
		throw new Error("opts.numOfFoldsForThresholdCalculation is null");
	}
	
	this.multiclassClassifier = new opts.multiclassClassifierType();

	// [F1, Accuracy]	
	this.evaluateMeasureToMaximize = opts.evaluateMeasureToMaximize;

	// constant size of validation set
	this.devsetsize = 0.1

	// > 1, n - fold cross - validation, otherwise validation set
	this.numOfFoldsForThresholdCalculation = opts.numOfFoldsForThresholdCalculation
}
function(opts) {
	
	opts = opts || {};

	if (!('multiclassClassifierType' in opts)) {
		console.dir(opts);
		throw new Error("opts must contain multiclassClassifierType");
	}
	if (!opts.multiclassClassifierType) {
		console.dir(opts);
		throw new Error("opts.multiclassClassifierType is null");
	}

	if (!('evaluateMeasureToMaximize' in opts)) {
		console.dir(opts);
		throw new Error("opts must contain evaluateMeasureToMaximize");
	}
	if (!opts.evaluateMeasureToMaximize) {
		console.dir(opts);
		throw new Error("opts.evaluateMeasureToMaximize is null");
	}
	if (!opts.numOfFoldsForThresholdCalculation) {
		console.dir(opts);
		throw new Error("opts.numOfFoldsForThresholdCalculation is null");
	}
	
	this.multiclassClassifier = new opts.multiclassClassifierType();

	// [F1, Accuracy]	
	this.evaluateMeasureToMaximize = opts.evaluateMeasureToMaximize;

	// constant size of validation set
	this.devsetsize = 0.1

	// > 1, n - fold cross - validation, otherwise validation set
	this.numOfFoldsForThresholdCalculation = opts.numOfFoldsForThresholdCalculation
}
/* ThresholdClassifier - classifier that converts multi-class classifier to multi-label classifier by finding
the best appropriate threshold.
@param opts
numOfFoldsForThresholdCalculation - =1 the threshold is approximated on validation set of size 10% of training set
>1 n - fold cross - validation is applied to approximate the threshold
evaluateMeasureToMaximize (['Accuracy','F1']) - string of the measure that operate the improvement of threshold
multiclassClassifier - multi-class classifier used for classification.
@author Vasily Konovalov