diff --git a/py/nupic/frameworks/opf/metrics.py b/py/nupic/frameworks/opf/metrics.py
index <HASH>..<HASH> 100644
--- a/py/nupic/frameworks/opf/metrics.py
+++ b/py/nupic/frameworks/opf/metrics.py
@@ -771,11 +771,16 @@ class MetricMovingMean(AggregateMetric):
 
 def evalCustomErrorMetric(expr, prediction, groundTruth, tools):
   sandbox = SafeInterpreter(writer=StringIO())
-  sandbox.symtable['prediction'] = tools.mostLikely(prediction)
+  if(type(prediction)==float):
+    sandbox.symtable['prediction']=prediction
+  elif(type(prediction)==dict):
+    sandbox.symtable['prediction'] = tools.mostLikely(prediction)
+    sandbox.symtable['EXP'] = tools.expValue(prediction)
+    sandbox.symtable['probabilityDistribution'] = prediction
+  else:
+    assert False, "prediction is neither a dict nor float"
   sandbox.symtable['groundTruth'] = groundTruth
   sandbox.symtable['tools'] = tools
-  sandbox.symtable['EXP'] = tools.expValue(prediction)
-  sandbox.symtable['probabilityDistribution'] = prediction
   error = sandbox(expr)
   return error
can now run anomaly models with custom error metrics