midas-edge 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/NOTICE.txt +1 -1
- data/README.md +2 -2
- data/ext/midas/ext.cpp +19 -22
- data/ext/midas/extconf.rb +1 -1
- data/lib/midas/version.rb +1 -1
- metadata +7 -63
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d4056b117cffbbbf0e5f9f97988789f9b2d53fc78753122ce7a03a45f532eff
|
4
|
+
data.tar.gz: f218bd317db9c4b3a792924e4312e35d84233bcb81198ea0a8f2a2551ef83452
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eede2417d3bce099af436eee2fb97497675c7056ae7adf5b496cfaf7e170533242a32f0dcda017c58847eb279af48f2dc1b61bff0bab81e0397250f8200518ed
|
7
|
+
data.tar.gz: 5b2bf24281919ae2f80f460bb7566bdf9d25b8bec145f2b43e59c8abb24a4f30e62c0d5ac2a8b6ecb8561d76e993a0facd6b0b2f177c3cee476daf2809bc4f7c
|
data/CHANGELOG.md
CHANGED
data/NOTICE.txt
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
Copyright 2020 Rui Liu (liurui39660) and Siddharth Bhatia (bhatiasiddharth)
|
2
|
-
Copyright 2020 Andrew Kane
|
2
|
+
Copyright 2020-2021 Andrew Kane
|
3
3
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
5
5
|
you may not use this file except in compliance with the License.
|
data/README.md
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
[MIDAS](https://github.com/bhatiasiddharth/MIDAS) - edge stream anomaly detection - for Ruby
|
4
4
|
|
5
|
-
[![Build Status](https://
|
5
|
+
[![Build Status](https://github.com/ankane/midas/workflows/build/badge.svg?branch=master)](https://github.com/ankane/midas/actions)
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
9
|
-
Add
|
9
|
+
Add this line to your application’s Gemfile:
|
10
10
|
|
11
11
|
```ruby
|
12
12
|
gem 'midas-edge'
|
data/ext/midas/ext.cpp
CHANGED
@@ -8,15 +8,10 @@
|
|
8
8
|
#include <RelationalCore.hpp>
|
9
9
|
|
10
10
|
// rice
|
11
|
-
#include <rice/
|
12
|
-
#include <rice/
|
11
|
+
#include <rice/rice.hpp>
|
12
|
+
#include <rice/stl.hpp>
|
13
13
|
|
14
|
-
|
15
|
-
using Rice::String;
|
16
|
-
using Rice::define_module;
|
17
|
-
using Rice::define_class_under;
|
18
|
-
|
19
|
-
void load_str(std::vector<int>& src, std::vector<int>& dst, std::vector<int>& times, std::string input, bool directed) {
|
14
|
+
void load_str(std::vector<int>& src, std::vector<int>& dst, std::vector<int>& times, const std::string& input, bool directed) {
|
20
15
|
int* input_ptr = (int*) input.data();
|
21
16
|
size_t n = input.size() / sizeof(int);
|
22
17
|
|
@@ -41,8 +36,7 @@ void load_str(std::vector<int>& src, std::vector<int>& dst, std::vector<int>& ti
|
|
41
36
|
// load_data from main.cpp
|
42
37
|
// modified to throw std::runtime_error when cannot find file
|
43
38
|
// instead of exiting
|
44
|
-
void load_file(std::vector<int>& src, std::vector<int>& dst, std::vector<int>& times, std::string input_file, bool undirected)
|
45
|
-
{
|
39
|
+
void load_file(std::vector<int>& src, std::vector<int>& dst, std::vector<int>& times, const std::string& input_file, bool undirected) {
|
46
40
|
FILE* infile = fopen(input_file.c_str(), "r");
|
47
41
|
if (infile == NULL) {
|
48
42
|
throw std::runtime_error("Could not read file: " + input_file);
|
@@ -56,8 +50,7 @@ void load_file(std::vector<int>& src, std::vector<int>& dst, std::vector<int>& t
|
|
56
50
|
dst.push_back(d);
|
57
51
|
times.push_back(t);
|
58
52
|
}
|
59
|
-
}
|
60
|
-
else {
|
53
|
+
} else {
|
61
54
|
while (fscanf(infile, "%d,%d,%d", &s, &d, &t) == 3) {
|
62
55
|
src.push_back(s);
|
63
56
|
dst.push_back(d);
|
@@ -67,12 +60,15 @@ void load_file(std::vector<int>& src, std::vector<int>& dst, std::vector<int>& t
|
|
67
60
|
times.push_back(t);
|
68
61
|
}
|
69
62
|
}
|
63
|
+
|
64
|
+
fclose(infile);
|
70
65
|
}
|
71
66
|
|
72
67
|
std::string fit_predict(std::vector<int>& src, std::vector<int>& dst, std::vector<int>& times, int num_rows, int num_buckets, float factor, float threshold, bool relations, int seed) {
|
73
68
|
srand(seed);
|
74
69
|
size_t n = src.size();
|
75
|
-
|
70
|
+
std::vector<float> result;
|
71
|
+
result.reserve(n);
|
76
72
|
|
77
73
|
if (!std::isnan(threshold)) {
|
78
74
|
MIDAS::FilteringCore midas(num_rows, num_buckets, threshold, factor);
|
@@ -90,25 +86,26 @@ std::string fit_predict(std::vector<int>& src, std::vector<int>& dst, std::vecto
|
|
90
86
|
result[i] = midas(src[i], dst[i], times[i]);
|
91
87
|
}
|
92
88
|
}
|
93
|
-
|
89
|
+
|
90
|
+
// std::string copies data
|
91
|
+
return std::string((char*) result.data(), sizeof(float) / sizeof(char) * n);
|
94
92
|
}
|
95
93
|
|
96
94
|
extern "C"
|
97
|
-
void Init_ext()
|
98
|
-
|
99
|
-
Module rb_mMidas = define_module("Midas");
|
95
|
+
void Init_ext() {
|
96
|
+
auto rb_mMidas = Rice::define_module("Midas");
|
100
97
|
|
101
|
-
define_class_under(rb_mMidas, "Detector")
|
102
|
-
.
|
98
|
+
Rice::define_class_under(rb_mMidas, "Detector")
|
99
|
+
.define_function(
|
103
100
|
"_fit_predict_str",
|
104
|
-
|
101
|
+
[](const std::string& input, int num_rows, int num_buckets, float factor, float threshold, bool relations, bool directed, int seed) {
|
105
102
|
std::vector<int> src, dst, times;
|
106
103
|
load_str(src, dst, times, input, directed);
|
107
104
|
return fit_predict(src, dst, times, num_rows, num_buckets, factor, threshold, relations, seed);
|
108
105
|
})
|
109
|
-
.
|
106
|
+
.define_function(
|
110
107
|
"_fit_predict_file",
|
111
|
-
|
108
|
+
[](const std::string& input, int num_rows, int num_buckets, float factor, float threshold, bool relations, bool directed, int seed) {
|
112
109
|
std::vector<int> src, dst, times;
|
113
110
|
load_file(src, dst, times, input, !directed);
|
114
111
|
return fit_predict(src, dst, times, num_rows, num_buckets, factor, threshold, relations, seed);
|
data/ext/midas/extconf.rb
CHANGED
data/lib/midas/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: midas-edge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rice
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 4.0.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 4.0.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: numo-narray
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,64 +38,8 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: bundler
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rake
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rake-compiler
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: minitest
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '5'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '5'
|
97
41
|
description:
|
98
|
-
email: andrew@
|
42
|
+
email: andrew@ankane.org
|
99
43
|
executables: []
|
100
44
|
extensions:
|
101
45
|
- ext/midas/extconf.rb
|
@@ -128,14 +72,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
128
72
|
requirements:
|
129
73
|
- - ">="
|
130
74
|
- !ruby/object:Gem::Version
|
131
|
-
version: '2.
|
75
|
+
version: '2.6'
|
132
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
77
|
requirements:
|
134
78
|
- - ">="
|
135
79
|
- !ruby/object:Gem::Version
|
136
80
|
version: '0'
|
137
81
|
requirements: []
|
138
|
-
rubygems_version: 3.
|
82
|
+
rubygems_version: 3.2.3
|
139
83
|
signing_key:
|
140
84
|
specification_version: 4
|
141
85
|
summary: Edge stream anomaly detection for Ruby
|