public DoubleList transform(DoubleList vector, VariableType type)
{
Validate.isTrue(inClassValue != outClassValue, "inClassValue == outClassValue");
Validate.isTrue(vector.size() > 0, "Vector calcCountOfItems is 0");
DoubleList result = new ArrayDoubleList();
int closestValueIndex = -1;
double minDisnance = Double.MAX_VALUE;
for (int i = 0; i < vector.size(); ++i)
{
double distance = Math.abs(vector.get(i) - inClassValue);
if (distance < minDisnance)
{
closestValueIndex = i;
minDisnance = distance;
}
}
double res = closestValueIndex + 1;
if (classToValueTable != null)
{
res = classToValueTable.get(res);
}
result.add(res);
return result;
}