norikra-udf-anomaly 0.0.1-java → 0.0.2-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d812b73e00a3f7b1287c708952d2890ffc814ad3
4
- data.tar.gz: 41a8a1019738809017a755a9c7bdab9193e1af15
3
+ metadata.gz: 59c9bf935aeae9d0a305b7a2f9f1652e14dd7c19
4
+ data.tar.gz: bdd3674cb18e46990c9efc93a8ce6c5dba1ecb1b
5
5
  SHA512:
6
- metadata.gz: 986c8fde849eddd09e8d54f2de607c8901d8e7b98d9ac19664a2a1c87e5cdf516a7b2f431bb2eef04359c06594e1186de25b29473a9df6c8fbea7fa73cf546f9
7
- data.tar.gz: cf0a5fc0a51bda696fbd88a3886de36d0565356830aec3f6c08295cd95a714dfb030d01c94a52771665170223e5e02d1debdb44da22a658fc6064216ebf2638b
6
+ metadata.gz: a66e5d71ff389dea2f50291e0b521bf30cd24335f1ff9abddac0fe0c3cafb46578b92fec4d2883e48297df4bb585ea749ebd6f27b59738f379968cbfca5b9e5d
7
+ data.tar.gz: 40a412a863df5721d71cd5844d0fd92b756d153596bddc0274eeb458556b3d42560faf4f65d557c33dd0c405413f720938218d21bd6f865c4510d03077102627
@@ -4,13 +4,13 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "norikra-udf-anomaly"
7
- spec.version = "0.0.1"
7
+ spec.version = "0.0.2"
8
8
  spec.authors = ["baba5246"]
9
9
  spec.email = ["baba_writer@yahoo.co.jp"]
10
10
  spec.summary = %q{Norikra UDF anomaly()}
11
11
  spec.description = %q{This plugin adds a function named anomaly, which calculates anomaly scores for specified fields}
12
- spec.homepage = "https://github.com/tagomoris/norikra-udf-anomaly"
13
- spec.license = "MIT"
12
+ spec.homepage = "https://github.com/baba5246/norikra-udf-anomaly"
13
+ spec.license = "GPLv2"
14
14
  spec.platform = "java"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib", "jar"]
20
20
 
21
- spec.add_runtime_dependency "norikra"
21
+ spec.add_runtime_dependency "norikra", ">= 0.0.11"
22
22
 
23
23
  spec.add_development_dependency "bundler", "~> 1.10"
24
24
  spec.add_development_dependency "rake", "~> 10.0"
data/spec/anomaly_spec.rb CHANGED
@@ -16,13 +16,13 @@ describe Norikra::UDF::Anomaly do
16
16
  expect(f.getValueType).to eql(java.lang.Integer.java_class)
17
17
  end
18
18
 
19
- it 'returns 1 value as mean' do
19
+ it 'returns 1 value as cumulativeDeviation' do
20
20
  (0...100).each do |i|
21
21
  f._call(:enter, i.to_java())
22
22
  end
23
23
 
24
24
  r = f.getValue
25
- expect(r).to eql(49)
25
+ expect(r).to eql(0)
26
26
 
27
27
  (0...100).each do |i|
28
28
  f._call(:leave, i.to_java())
@@ -62,19 +62,34 @@ public class Anomaly implements AggregationMethod {
62
62
  if (counts.length == 0)
63
63
  return null;
64
64
 
65
- Integer mean = mean(counts);
66
- return mean;
65
+ Integer score = cumulateDeviation(counts);
66
+ return score;
67
67
  }
68
68
 
69
69
  public void clear() {
70
70
  countList = null;
71
71
  }
72
72
 
73
- public Integer mean(Integer[] m) {
73
+ public double mean(Integer[] m) {
74
74
  Integer sum = 0;
75
75
  for (int i = 0; i < m.length; i++) {
76
76
  sum += m[i];
77
77
  }
78
- return sum / m.length;
78
+ return sum.doubleValue() / m.length;
79
+ }
80
+
81
+ public Integer cumulateDeviation(Integer[] counts) {
82
+ double mean = mean(counts);
83
+ double cumulativeSum = 0;
84
+ double maxSum = cumulativeSum;
85
+
86
+ for (int i = 0; i < counts.length; i++) {
87
+ double dev = counts[i].doubleValue() - mean;
88
+ cumulativeSum += dev;
89
+ if (i == 0) maxSum = cumulativeSum;
90
+ else maxSum = Math.max(maxSum, cumulativeSum);
91
+ }
92
+
93
+ return new Integer((int) maxSum);
79
94
  }
80
95
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: norikra-udf-anomaly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: java
6
6
  authors:
7
7
  - baba5246
@@ -16,12 +16,12 @@ dependencies:
16
16
  requirements:
17
17
  - - '>='
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 0.0.11
20
20
  requirement: !ruby/object:Gem::Requirement
21
21
  requirements:
22
22
  - - '>='
23
23
  - !ruby/object:Gem::Version
24
- version: '0'
24
+ version: 0.0.11
25
25
  prerelease: false
26
26
  type: :runtime
27
27
  - !ruby/object:Gem::Dependency
@@ -88,9 +88,9 @@ files:
88
88
  - spec/spec_helper.rb
89
89
  - src/is/tagomor/norikra/udf/Anomaly.java
90
90
  - src/is/tagomor/norikra/udf/AnomalyFactory.java
91
- homepage: https://github.com/tagomoris/norikra-udf-anomaly
91
+ homepage: https://github.com/baba5246/norikra-udf-anomaly
92
92
  licenses:
93
- - MIT
93
+ - GPLv2
94
94
  metadata: {}
95
95
  post_install_message:
96
96
  rdoc_options: []