def run_seism_experiment(): input_file = "eQnoise.csv" generate_data.run(input_file) print("time is :%f secs" % ((clk.time() - t0) / 60.)) model_params = swarm_over_data() print("time is :%f secs" % ((clk.time() - t0) / 60.)) print(model_params) if PLOT: pass #output = NuPICPlotOutput("sine3_output", show_anomaly_score=True) else: output = NuPICFileOutput("eQnoise_output", show_anomaly_score=True) print("time is :%f min" % ((clk.time() - t0) / 60.)) model = ModelFactory.create(model_params) model.enableInference({"predictedField": "acc"}) with open(input_file, "rb") as data_input: csv_reader = csv.reader(data_input) # skip header rows csv_reader.next() csv_reader.next() csv_reader.next() # the real data for row in csv_reader: time = float(row[0]) acc_value = float(row[1]) result = model.run({"acc": acc_value}) output.write(time, acc_value, result, prediction_step=PSTEPS) output.close() print("time is :%f min" % ((clk.time() - t0) / 60.))
def run_experiment(): generate_data.run() swarm_over_data() import model_params model = ModelFactory.create(model_params.MODEL_PARAMS) model.enableInference({"predictedField": "sine"}) output = NuPICPlotOutput("sine_out", show_anomaly_score=True) with open("sine.csv", "rb") as sine_input: csv_reader = csv.reader(sine_input) # Skip headers csv_reader.next() csv_reader.next() csv_reader.next() # Real Data for row in csv_reader: angle = float(row[0]) sine_value = float(row[1]) result = model.run({"sine": sine_value}) output.write(angle, sine_value, result) output.close()
def run_sine_experiment(): input_file = "sine.csv" generate_data.run(input_file) model_params = swarm_over_data() if PLOT: output = NuPICPlotOutput("sine_output", show_anomaly_score=True) else: output = NuPICFileOutput("sine_output", show_anomaly_score=True) model = ModelFactory.create(model_params) model.enableInference({"predictedField": "sine"}) with open(input_file, "rb") as sine_input: csv_reader = csv.reader(sine_input) # skip header rows csv_reader.next() csv_reader.next() csv_reader.next() # the real data for row in csv_reader: angle = float(row[0]) sine_value = float(row[1]) result = model.run({"sine": sine_value}) output.write(angle, sine_value, result, prediction_step=1) output.close()
def run_sine_experiment(): input_file = "netio.csv" generate_data.run(input_file) model_params = swarm_over_data() if PLOT: output = NuPICPlotOutput("netio_output", show_anomaly_score=True) else: output = NuPICFileOutput("netio_output", show_anomaly_score=True) model = ModelFactory.create(model_params) model.enableInference({"predictedField": "bytes_sent"}) with open(input_file, "rb") as netio_input: csv_reader = csv.reader(netio_input) # skip header rows csv_reader.next() csv_reader.next() csv_reader.next() # the real data for row in csv_reader: timestamp = datetime.datetime.strptime(row[0], DATE_FORMAT) bytes_sent = float(row[1]) #netio = float(row[3]) result = model.run({"bytes_sent": bytes_sent}) output.write(timestamp, bytes_sent, result, prediction_step=1) output.close()
def run_sine_experiment(): input_file = "sine.csv" generate_data.run(input_file) model_params = swarm_over_data() if PLOT: output = NuPICPlotOutput("sine_output", show_anomaly_score=True) else: output = NuPICFileOutput("sine_output", show_anomaly_score=True) model = ModelFactory.create(model_params) model.enableInference({"predictedField": "sine"}) with open(input_file, "rb") as sine_input: csv_reader = csv.reader(sine_input) # skip header rows csv_reader.next() csv_reader.next() csv_reader.next() # the real data for row in csv_reader: angle = float(row[0]) sine_value = float(row[1]) result = model.run({"sine": sine_value}) output.write(angle, sine_value, result, prediction_step=1) output.close()
def run_mem_experiment(): input_file = "cpu.csv" generate_data.run(input_file) model_params = swarm_over_data(SWARM_CONFIG) if PLOT: output = NuPICPlotOutput("final_mem_output") else: output = NuPICFileOutput("final_mem_output") model = ModelFactory.create(model_params) model.enableInference({"predictedField": "mem"}) with open(input_file, "rb") as sine_input: csv_reader = csv.reader(sine_input) # skip header rows csv_reader.next() csv_reader.next() csv_reader.next() # the real data for row in csv_reader: timestamp = datetime.datetime.strptime(row[0], DATE_FORMAT) mem = float(row[1]) result = model.run({"mem": mem}) prediction = result.inferences["multiStepBestPredictions"][1] anomalyScore = result.inferences['anomalyScore'] output.write(timestamp, mem, prediction, anomalyScore) output.close()
def generate_data(self): """ Runs the data generation script. """ try: self.setWindowStatus("Generating data...") generate_data.run() self.setWindowStatus("Populating GUI elements..") self.init() self.setWindowStatus("Data successfuly generated") except Exception as e: self.setWindowStatus(f"Failed to generate data: {e}")
def run(WinHandle=0, fname="verylargeseism_out"): global N, val, pre, ano p1 = WinHandle[0] p2 = WinHandle[1] p3 = WinHandle[2] blockSize = N # generate a block of data, filename is irrilevant if no write on disk acc_block = gd.run(fname, blockSize) print("generated %d data " % len(acc_block)) #output = NuPICFileOutput(fname, show_anomaly_score=True) # with open(input_file, "rb") as data_input: # csv_reader = csv.reader(data_input) # skip header rows # csv_reader.next() # csv_reader.next() # csv_reader.next() # prepare graphs # the real data for t, acc in enumerate(acc_block): time = float(t) acc_value = float(acc_block[t]) result = model.run({"acc": acc_value}) print(result) #output.write(time, acc_value, result, prediction_step=PSTEPS) #print(OKBLUE+BOLD+"prediction, anomaly:"+ENDC) prediction = result.inferences['multiStepBestPredictions'][PSTEPS] anomaly = result.inferences['anomalyScore'] # append the value and remove head val[t] = acc_value pre[t] = prediction ano[t] = anomaly #print(prediction,anomaly) #raw_input(OKGREEN+"?"+ENDC) #output.close() pg.QtGui.QApplication.processEvents() p1.plot(val, clear=True, symbolSize=2, symbol="x", symbolPen="w") p2.plot(pre, clear=True, symbolSize=2, symbol="x", symbolPen="b") p3.plot(ano, clear=True, symbolSize=2, symbol="x", symbolPen="r") tt = OKBLUE + "time is :%f min" + ENDC print(tt % ((clk.time() - t0) / 60.))
import generate_data if __name__ == '__main__': number_of_geothermal = 10 for i in range(0, number_of_geothermal): generate_data.run()
def generate_data(input_file): import generate_data generate_data.run(input_file)
def generate_data(input_file): import generate_data generate_data.run(input_file)