def runNetwork(network, writer):
 sensorRegion = network.regions['sensor']
 spatialPoolerRegion = network.regions['spatialPoolerRegion']
 temporalPoolerRegion = network.regions['temporalPoolerRegion']
 anomalyLikelihoodRegion = network.regions['anomalyLikelihoodRegion']
 prevPredictedColumns = []
 for i in xrange(_NUM_RECORDS):
  network.run(1)
  consumption = sensorRegion.getOutputData('sourceOut')[0]
  anomalyScore = temporalPoolerRegion.getOutputData('anomalyScore')[0]
  anomalyLikelihood = anomalyLikelihoodRegion.getOutputData('anomalyLikelihood')[0]
  writer.writerow((i, consumption, anomalyScore, anomalyLikelihood))

def runNetwork ( network , writer ) : sensorRegion = network . regions [ 'sensor' ] spatialPoolerRegion = network . regions [ 'spatialPoolerRegion' ] temporalPoolerRegion = network . regions [ 'temporalPoolerRegion' ] anomalyLikelihoodRegion = network . regions [ 'anomalyLikelihoodRegion' ] prevPredictedColumns = [ ] for i in xrange ( _NUM_RECORDS ) : network . run ( 1 ) consumption = sensorRegion . getOutputData ( 'sourceOut' ) [ 0 ] anomalyScore = temporalPoolerRegion . getOutputData ( 'anomalyScore' ) [ 0 ] anomalyLikelihood = anomalyLikelihoodRegion . getOutputData ( 'anomalyLikelihood' ) [ 0 ] writer . writerow ( ( i , consumption , anomalyScore , anomalyLikelihood ) )
run the network and write output to writer .