예제 #1
0
import sys
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats

from io_helper import open_write, open_read


def usage():
    print >> sys.stderr, "{} <source.npy> [output.npy]"
    exit(1)


if __name__ == '__main__':
    if len(sys.argv) < 2:
        usage()

    src = sys.argv[1]
    out = None
    if len(sys.argv) == 3:
        out = sys.argv[2]

    data = np.load(open_read(src))
    if data.min() <= 0:
        data += data.min() + 1
    boxcox, l = stats.boxcox(data)
    print >> sys.stderr, "Lambda: {}".format(l)
    if out is not None:
        np.save(open_write(out), boxcox)
예제 #2
0
    query = sys.argv[1]
    out = sys.argv[2]

    client = InfluxDBClient('localhost', 8086, 'root', 'root', '')
    result = client.query(query)

    for rs in result:
        cols = [k for k in rs[0].keys() if k != 'time']
        cols_count = len(cols)
        data = np.zeros((len(rs), cols_count))
        r = 0
        for row in rs:
            c = 0
            for col in cols:
                data[r,c] = row[col]
                c += 1
            r += 1

        if len(data.shape) == 2 and data.shape[1] == 1:
            data = data.reshape(data.shape[0])
        np.save(open_write(out), data)








예제 #3
0
# using the Box-Cox method.
# https://en.wikipedia.org/wiki/Power_transform

import sys
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats

from io_helper import open_write,open_read

def usage():
    print >> sys.stderr, "{} <source.npy> [output.npy]"
    exit(1)

if __name__ == '__main__':
    if len(sys.argv) < 2:
        usage()

    src = sys.argv[1]
    out = None
    if len(sys.argv) == 3:
        out = sys.argv[2]

    data = np.load(open_read(src))
    if data.min() <= 0:
        data += data.min() + 1
    boxcox, l = stats.boxcox(data)
    print >> sys.stderr, "Lambda: {}".format(l)
    if out is not None:
        np.save(open_write(out), boxcox)
예제 #4
0
def usage():
    print >> sys.stderr, "{} <query> <output>".format(__file__)
    exit(1)


if __name__ == '__main__':
    if len(sys.argv) != 3:
        usage()

    query = sys.argv[1]
    out = sys.argv[2]

    client = InfluxDBClient('localhost', 8086, 'root', 'root', '')
    result = client.query(query)

    for rs in result:
        cols = [k for k in rs[0].keys() if k != 'time']
        cols_count = len(cols)
        data = np.zeros((len(rs), cols_count))
        r = 0
        for row in rs:
            c = 0
            for col in cols:
                data[r, c] = row[col]
                c += 1
            r += 1

        if len(data.shape) == 2 and data.shape[1] == 1:
            data = data.reshape(data.shape[0])
        np.save(open_write(out), data)