formats/svmlight.js
function featureArrayToFeatureString(features, bias, firstFeatureNumber) {
	if (!Array.isArray(features))
		throw new Error("Expected an array, but got "+JSON.stringify(features))
	var line = (bias? " "+firstFeatureNumber+":"+bias: "");
	for (var feature=0; feature<features.length; ++feature) {
		var value = features[feature];
		if (value)
			line += (" "+(feature+firstFeatureNumber+(bias?1:0))+":"+value.toPrecision(5));
	}
	return line;
}
function featureArrayToFeatureString(features, bias, firstFeatureNumber) {
	if (!Array.isArray(features))
		throw new Error("Expected an array, but got "+JSON.stringify(features))
	var line = (bias? " "+firstFeatureNumber+":"+bias: "");
	for (var feature=0; feature<features.length; ++feature) {
		var value = features[feature];
		if (value)
			line += (" "+(feature+firstFeatureNumber+(bias?1:0))+":"+value.toPrecision(5));
	}
	return line;
}
function featureArrayToFeatureString ( features , bias , firstFeatureNumber ) { if ( ! Array . isArray ( features ) ) throw new Error ( "Expected an array, but got " + JSON . stringify ( features ) ) var line = ( bias ? " " + firstFeatureNumber + ":" + bias : "" ) ; for ( var feature = 0 ; feature < features . length ; ++ feature ) { var value = features [ feature ] ; if ( value ) line += ( " " + ( feature + firstFeatureNumber + ( bias ? 1 : 0 ) ) + ":" + value . toPrecision ( 5 ) ) ; } return line ; }
convert an array of features to a single line in SVM-light format. The line starts with a space.
convert an array of features to a single line in SVM - light format . The line starts with a space .