import numpy as np from DStreamII import DStreamII # D-StreamII training objects trainer = DStreamII(complexity=0, numInputs=1, discreteOutputs=0, discreteInputs=0, appFieldsDict= {'gridSize': [0.25], 'gridUpperRange':[25], 'gridLowerRange':[0]}); trainInputData = [] trainOutputData = [] # Train to determine the grid size with open("trace.txt", mode='r') as fp: for line in fp: dataInfo = line.split() trainInputData.append(dataInfo) with open("trace_obs.txt", mode='r') as fp: for line in fp: dataInfo = line.split() trainOutputData.append(dataInfo) trainer.addBatchObservations(trainInputData, trainOutputData); trainer.train(); inputData = [] #Execute D-Stream II clustering algorithm with open("power_use.txt") as fp: for line in fp: dataInfo = line.split()
import numpy as np from DStreamII import DStreamII # D-StreamII training objects trainer = DStreamII(complexity=0, numInputs=1, discreteOutputs=0, discreteInputs=0, appFieldsDict={ 'gridSize': [0.25], 'gridUpperRange': [25], 'gridLowerRange': [0] }) trainInputData = [] trainOutputData = [] # Train to determine the grid size with open("trace.txt", mode='r') as fp: for line in fp: dataInfo = line.split() trainInputData.append(dataInfo) with open("trace_obs.txt", mode='r') as fp: for line in fp: dataInfo = line.split() trainOutputData.append(dataInfo) trainer.addBatchObservations(trainInputData, trainOutputData) trainer.train()
## Import your algorithms here. from DStreamII import DStreamII ## For different tests, these values will vary. inputFilePath = "DStreamIITestInput.csv" outputFilePath = "DStreamIITestOutput.csv" numTrainingSamples = 30; numExecuteSamples = 100; inputFile = open(inputFilePath); outputFile = open(outputFilePath); inputReader = csv.reader(inputFile); outputReader = csv.reader(outputFile); ## Change the name of the algorithm to test it out. dStreamIITest = DStreamII(0, 2, 0, [0, 0],{'gridSize': [1,1], 'gridUpperRange':[10,10], 'gridLowerRange':[0,0]}); dStreamIITimestamps = {}; for trainingSample in range(numTrainingSamples): inputRow = next(inputReader); outputRow = next(outputReader); if (len(inputRow) > 0): input1 = float(inputRow[0]); input2 = float(inputRow[1]); output = float(outputRow[0]); firstTS = time.time(); dStreamIITest.addSingleObservation([input1, input2], output); secondTS = time.time(); dStreamIITimestamps["load" + str(trainingSample)] = secondTS - firstTS;
## Import your algorithms here. from DStreamII import DStreamII ## For different tests, these values will vary. inputFilePath = "DStreamIITestInput.csv" outputFilePath = "DStreamIITestOutput.csv" numTrainingSamples = 30; numExecuteSamples = 100; inputFile = open(inputFilePath); outputFile = open(outputFilePath); inputReader = csv.reader(inputFile); outputReader = csv.reader(outputFile); ## Change the name of the algorithm to test it out. dStreamIITest = DStreamII(0, 2, 0, [0, 0],{'gridSize': [1,1], 'gridUpperRange':[10,10], 'gridLowerRange':[0,0], 'key':'AESKEY'}); dStreamIITimestamps = {}; for trainingSample in range(numTrainingSamples): inputRow = next(inputReader); outputRow = next(outputReader); if (len(inputRow) > 0): input1 = float(inputRow[0]); input2 = float(inputRow[1]); output = float(outputRow[0]); firstTS = time.time(); dStreamIITest.addSingleObservation([input1, input2], output); secondTS = time.time(); dStreamIITimestamps["load" + str(trainingSample)] = secondTS - firstTS;
## For different tests, these values will vary. inputFilePath = "DStreamIITestInput.csv" outputFilePath = "DStreamIITestOutput.csv" numTrainingSamples = 30 numExecuteSamples = 100 inputFile = open(inputFilePath) outputFile = open(outputFilePath) inputReader = csv.reader(inputFile) outputReader = csv.reader(outputFile) ## Change the name of the algorithm to test it out. dStreamIITest = DStreamII(0, 2, 0, [0, 0], { 'gridSize': [1, 1], 'gridUpperRange': [10, 10], 'gridLowerRange': [0, 0] }) dStreamIITimestamps = {} for trainingSample in range(numTrainingSamples): inputRow = next(inputReader) outputRow = next(outputReader) if (len(inputRow) > 0): input1 = float(inputRow[0]) input2 = float(inputRow[1]) output = float(outputRow[0]) firstTS = time.time() dStreamIITest.addSingleObservation([input1, input2], output) secondTS = time.time()