def closenessScores(self, expValues, actValues, fractional=True):
<EOL>if self.encoders is None:<EOL><INDENT>err = abs(expValues[<NUM_LIT:0>] - actValues[<NUM_LIT:0>])<EOL>if fractional:<EOL><INDENT>denom = max(expValues[<NUM_LIT:0>], actValues[<NUM_LIT:0>])<EOL>if denom == <NUM_LIT:0>:<EOL><INDENT>denom = <NUM_LIT:1.0><EOL><DEDENT>closeness = <NUM_LIT:1.0> - float(err)/denom<EOL>if closeness < <NUM_LIT:0>:<EOL><INDENT>closeness = <NUM_LIT:0><EOL><DEDENT><DEDENT>else:<EOL><INDENT>closeness = err<EOL><DEDENT>return numpy.array([closeness])<EOL><DEDENT>scalarIdx = <NUM_LIT:0><EOL>retVals = numpy.array([])<EOL>for (name, encoder, offset) in self.encoders:<EOL><INDENT>values = encoder.closenessScores(expValues[scalarIdx:], actValues[scalarIdx:],<EOL>fractional=fractional)<EOL>scalarIdx += len(values)<EOL>retVals = numpy.hstack((retVals, values))<EOL><DEDENT>return retVals<EOL>
Compute closeness scores between the expected scalar value(s) and actual
scalar value(s). The expected scalar values are typically those obtained
from the :meth:`.getScalars` method. The actual scalar values are typically
those returned from :meth:`.topDownCompute`.

This method returns one closeness score for each value in expValues (or
actValues which must be the same length). The closeness score ranges from
0 to 1.0, 1.0 being a perfect match and 0 being the worst possible match.

If this encoder is a simple, single field encoder, then it will expect
just 1 item in each of the ``expValues`` and ``actValues`` arrays.
Multi-encoders will expect 1 item per sub-encoder.

Each encoder type can define it's own metric for closeness. For example,
a category encoder may return either 1 or 0, if the scalar matches exactly
or not. A scalar encoder might return a percentage match, etc.

:param expValues: Array of expected scalar values, typically obtained from
                 :meth:`.getScalars`
:param actValues: Array of actual values, typically obtained from
                 :meth:`.topDownCompute`

:return: Array of closeness scores, one per item in expValues (or
         actValues).