Skip to content

Instantly share code, notes, and snippets.

@TkrUdagawa
Created August 9, 2017 07:02
Show Gist options
  • Save TkrUdagawa/efa80a814cbd173b05403846d5a6b315 to your computer and use it in GitHub Desktop.
Save TkrUdagawa/efa80a814cbd173b05403846d5a6b315 to your computer and use it in GitHub Desktop.
jubakit anomaly
import subprocess
import time
import jubatus
from jubatus.common import Datum
cmd = "jubaanomaly"
juba = subprocess.Popen([cmd, "-f", "light_lof.json"])
time.sleep(5)
cl = jubatus.Anomaly("localhost", 9199, "hoge")
with open("iris.csv") as f:
for line in f:
a, b, c, d, e = line.split(",")
datum = Datum({
"a": float(a),
"b": float(b),
"c": float(c),
"d": float(d),
"e": e
})
print(cl.add(datum))
juba.terminate()
{
"converter" : {
"string_filter_types" : {},
"string_filter_rules" : [],
"num_filter_types" : {},
"num_filter_rules" : [],
"string_types" : {},
"string_rules" : [
{ "key" : "*", "type" : "str", "sample_weight" : "bin", "global_weight" : "bin" }
],
"num_types" : {},
"num_rules" : [
{ "key" : "*", "type" : "num" }
]
},
"parameter" : {
"nearest_neighbor_num" : 10,
"reverse_nearest_neighbor_num" : 30,
"method" : "euclid_lsh",
"parameter" : {
"hash_num" : 64,
"threads": -1
}
},
"method" : "light_lof"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment