dist/multilabel/ThresholdClassifier.js
function(list_of_scores, testSet, FN){

		current_set=[]

		TRUE = 0
		FP = 0
		TP = 0

		result = []
		
		for (var th=0; th<list_of_scores.length; ++th) {

			if (list_of_scores[th][2]=="+") {TP+=1; FN-=1}
			if (list_of_scores[th][2]=="-") {FP+=1;}

			// console.log(list_of_scores[th])
			// console.log("TP "+TP+" FP "+FP+" FN "+FN)

			index_in_testSet = list_of_scores[th][3]

			if (_.isEqual(current_set[index_in_testSet], testSet[index_in_testSet]['output'])) 
			{TRUE-=1}
			
			if (!current_set[index_in_testSet])
			{current_set[index_in_testSet] = [list_of_scores[th][0]]}
			else
			{current_set[index_in_testSet].push(list_of_scores[th][0])}

 			if (_.isEqual(current_set[index_in_testSet], testSet[index_in_testSet]['output'])) 
			{TRUE+=1 }
			
 			PRF = calculate_PRF(TP, FP, FN)
 			PRF['Accuracy'] = TRUE/testSet.length
 			PRF['Threshold'] = list_of_scores[th][1]
 
 			result[list_of_scores[th][1]] = PRF
 			}

			optial_measure=0
			index=Object.keys(result)[0]
			for (i in result)
			{
				if (result[i][this.evaluateMeasureToMaximize] >= optial_measure)
				{
					index = i
					optial_measure = result[i][this.evaluateMeasureToMaximize]
				}
			}

 			return result[index]
 		
	}
function(list_of_scores, testSet, FN){

		current_set=[]

		TRUE = 0
		FP = 0
		TP = 0

		result = []
		
		for (var th=0; th<list_of_scores.length; ++th) {

			if (list_of_scores[th][2]=="+") {TP+=1; FN-=1}
			if (list_of_scores[th][2]=="-") {FP+=1;}

			// console.log(list_of_scores[th])
			// console.log("TP "+TP+" FP "+FP+" FN "+FN)

			index_in_testSet = list_of_scores[th][3]

			if (_.isEqual(current_set[index_in_testSet], testSet[index_in_testSet]['output'])) 
			{TRUE-=1}
			
			if (!current_set[index_in_testSet])
			{current_set[index_in_testSet] = [list_of_scores[th][0]]}
			else
			{current_set[index_in_testSet].push(list_of_scores[th][0])}

 			if (_.isEqual(current_set[index_in_testSet], testSet[index_in_testSet]['output'])) 
			{TRUE+=1 }
			
 			PRF = calculate_PRF(TP, FP, FN)
 			PRF['Accuracy'] = TRUE/testSet.length
 			PRF['Threshold'] = list_of_scores[th][1]
 
 			result[list_of_scores[th][1]] = PRF
 			}

			optial_measure=0
			index=Object.keys(result)[0]
			for (i in result)
			{
				if (result[i][this.evaluateMeasureToMaximize] >= optial_measure)
				{
					index = i
					optial_measure = result[i][this.evaluateMeasureToMaximize]
				}
			}

 			return result[index]
 		
	}
function ( list_of_scores , testSet , FN ) { current_set = [ ] TRUE = 0 FP = 0 TP = 0 result = [ ] for ( var th = 0 ; th < list_of_scores . length ; ++ th ) { if ( list_of_scores [ th ] [ 2 ] == "+" ) { TP += 1 ; FN -= 1 } if ( list_of_scores [ th ] [ 2 ] == "-" ) { FP += 1 ; } // console.log(list_of_scores[th]) // console.log("TP "+TP+" FP "+FP+" FN "+FN) index_in_testSet = list_of_scores [ th ] [ 3 ] if ( _ . isEqual ( current_set [ index_in_testSet ] , testSet [ index_in_testSet ] [ 'output' ] ) ) { TRUE -= 1 } if ( ! current_set [ index_in_testSet ] ) { current_set [ index_in_testSet ] = [ list_of_scores [ th ] [ 0 ] ] } else { current_set [ index_in_testSet ] . push ( list_of_scores [ th ] [ 0 ] ) } if ( _ . isEqual ( current_set [ index_in_testSet ] , testSet [ index_in_testSet ] [ 'output' ] ) ) { TRUE += 1 } PRF = calculate_PRF ( TP , FP , FN ) PRF [ 'Accuracy' ] = TRUE / testSet . length PRF [ 'Threshold' ] = list_of_scores [ th ] [ 1 ] result [ list_of_scores [ th ] [ 1 ] ] = PRF } optial_measure = 0 index = Object . keys ( result ) [ 0 ] for ( i in result ) { if ( result [ i ] [ this . evaluateMeasureToMaximize ] >= optial_measure ) { index = i optial_measure = result [ i ] [ this . evaluateMeasureToMaximize ] } } return result [ index ] }
/*
Calculate the bst threshold with the highest evaluateMeasureToMaximize
@param  list_of_scores list of scores
@param  testSet test set
@param FN false negative
/ * Calculate the bst threshold with the highest evaluateMeasureToMaximize