Esempio n. 1
0
def run(fname="verylargeseism_out"):
    print("reading %s" % input_file)
    print("using this model: ", model_params)
    model = ModelFactory.create(model_params)
    model.enableInference({"predictedField": "acc"})
    print("created nupic model in :%f min" % ((clk.time() - t0) / 60.))
    print("will output predictions and anomalies \n in this file: %s" % fname)

    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()

        # 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.))
Esempio n. 2
0
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.))
Esempio n. 3
0
def predict():
    from model_0 import model_params
    input_file = "sine.csv"
    model = ModelFactory.create(model_params.MODEL_PARAMS)
    model.enableInference({"predictedField": "sine"})

    output = NuPICFileOutput("sine_output", show_anomaly_score=True)

    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()