from nupic.frameworks.opf.common_models.cluster_params import getScalarMetricWithTimeOfDayAnomalyParams
from nupic.frameworks.opf.model_factory import ModelFactory
modelParams = getScalarMetricWithTimeOfDayAnomalyParams(
metricData=[0.1, 0.2, 0.3, 0.4, 0.5],
numAnomalies=3,
startAnomaly=2,
anomalyDuration=1
)
model = ModelFactory.create(modelParams)
model.enableInference({'predictedField': 'value'})
for i in range(10):
modelInput = {'value': 0.1 * i}
result = model.run(modelInput)
print("Input: {0}, Anomaly Score: {1}".format(modelInput, result.inferences['anomalyScore']))