1
1
module AutoAnomalyDetectors
2
- # classification search blocks
3
-
4
-
5
2
using Distributed
6
3
using AutoMLPipeline
7
4
using DataFrames: DataFrame, nrow, rename!
@@ -26,7 +23,7 @@ mutable struct AutoAnomalyDetector <: Workflow
26
23
function AutoAnomalyDetector (args= Dict ())
27
24
default_args = Dict (
28
25
:name => " autoad" ,
29
- :votepercent => 0.3 ,
26
+ :votepercent => 0.0 , # output all votepercent if 0.0, otherwise get specific votepercent
30
27
:impl_args => Dict ()
31
28
)
32
29
cargs = nested_dict_merge (default_args, args)
@@ -68,22 +65,27 @@ function transform!(autodt::AutoAnomalyDetector, X::DataFrame)
68
65
mdf = hcat (dfres1, dfres2)
69
66
mdfm = hcat (mdf, DataFrame (admean= mean .(eachrow (mdf))))
70
67
# filter anomalies based on mean cut-off
71
- # cutoff = autodt.model[:votepercent]
72
- dfad = DataFrame ()
73
- for cutoff in 0.1 : 0.1 : 1.0
74
- ndx = map (x -> x >= cutoff, mdfm. admean)
75
- dfad = hcat (dfad, DataFrame (n= ndx); makeunique= true )
68
+ votepercent = autodt. model[:votepercent ]
69
+ if votepercent == 0.0
70
+ dfad = @distributed (hcat) for cutoff in 0.1 : 0.1 : 1.0
71
+ ndx = map (x -> x >= cutoff, mdfm. admean)
72
+ n = string (cutoff)
73
+ DataFrame (n => ndx)
74
+ end
75
+ return dfad
76
+ else
77
+ ndx = map (x -> x >= votepercent, mdfm. admean)
78
+ n = string (votepercent)
79
+ dfad = DataFrame (n => ndx)
80
+ return dfad
76
81
end
77
- names = map (x -> string (x), 0.1 : 0.1 : 1.0 )
78
- rename! (dfad, names)
79
- return dfad
80
82
end
81
83
82
84
function transform (autodt:: AutoAnomalyDetector , X:: DataFrame )
83
85
end
84
86
85
87
function autoaddriver ()
86
- autoaddt = AutoAnomalyDetector (Dict (:votepercent => 0.1 ))
88
+ autoaddt = AutoAnomalyDetector (Dict (:votepercent => 0.0 ))
87
89
X = vcat (5 * cos .(- 10 : 10 ), sin .(- 30 : 30 ), 3 * cos .(- 10 : 10 ), 2 * tan .(- 10 : 10 ), sin .(- 30 : 30 )) |> x -> DataFrame ([x], :auto )
88
90
fit_transform! (autoaddt, X)
89
91
end
0 commit comments