Example #1
0
def add_data(num=10):
    data = generate_data(num)
    client = jubatus.Anomaly(HOST, PORT_P, NAME)
    for d in data:
        dt = Datum({"x": d[0], "y": d[1], "z": d[2]})
        result = client.add(dt)
        print('Added {0}, score = {1}'.format(result.id, result.score))
Example #2
0
def clear():
    client = jubatus.Anomaly(HOST, PORT_P, NAME)
    client.clear()
Example #3
0
def do_mix(sleep_sec=3.0):
    client = jubatus.Anomaly(HOST, PORT_1, NAME)
    client.do_mix()
    print('Do MIX and wait {0} sec'.format(sleep_sec))
    time.sleep(sleep_sec)
Example #4
0
def print_rows(port):
    client = jubatus.Anomaly(HOST, port, NAME)
    rows = client.get_all_rows()
    print(' - ID in {0}: {1}'.format(port, ' '.join(sorted(rows, key=int))))
Example #5
0
import jubatus
from jubatus.common import Datum

import random

cl = jubatus.Anomaly('127.0.0.1', 9199, 'test', 0)

random.seed(1)
datum_length = 100

for i in range(3):
    d = Datum()
    for x in range(datum_length):
        d.add_number("{}".format(x), random.random())
    cl.add(d)

print('ids:{}'.format(','.join(cl.get_all_rows())))  # 1, 2, 3

d = Datum()
for x in range(datum_length):
    d.add_number("{}".format(x), random.random())
cl.add(d)
print('ids:{}'.format(','.join(cl.get_all_rows())))  # unlearn 1 id

cl.save('test')
cl.clear()
cl.load('test')

print('ids:{}'.format(','.join(cl.get_all_rows())))  # should be same as before `save`

d = Datum()