Skip to content

Commit 103c58f

Browse files
committed
refactor skanomalydetector
1 parent 52bde1a commit 103c58f

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

AutoAI/src/autoanomalydetector.jl

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
module AutoAnomalyDetectors
2-
# classification search blocks
3-
4-
52
using Distributed
63
using AutoMLPipeline
74
using DataFrames: DataFrame, nrow, rename!
@@ -26,7 +23,7 @@ mutable struct AutoAnomalyDetector <: Workflow
2623
function AutoAnomalyDetector(args=Dict())
2724
default_args = Dict(
2825
:name => "autoad",
29-
:votepercent => 0.3,
26+
:votepercent => 0.0, # output all votepercent if 0.0, otherwise get specific votepercent
3027
:impl_args => Dict()
3128
)
3229
cargs = nested_dict_merge(default_args, args)
@@ -68,22 +65,27 @@ function transform!(autodt::AutoAnomalyDetector, X::DataFrame)
6865
mdf = hcat(dfres1, dfres2)
6966
mdfm = hcat(mdf, DataFrame(admean=mean.(eachrow(mdf))))
7067
# 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
7681
end
77-
names = map(x -> string(x), 0.1:0.1:1.0)
78-
rename!(dfad, names)
79-
return dfad
8082
end
8183

8284
function transform(autodt::AutoAnomalyDetector, X::DataFrame)
8385
end
8486

8587
function autoaddriver()
86-
autoaddt = AutoAnomalyDetector(Dict(:votepercent => 0.1))
88+
autoaddt = AutoAnomalyDetector(Dict(:votepercent => 0.0))
8789
X = vcat(5 * cos.(-10:10), sin.(-30:30), 3 * cos.(-10:10), 2 * tan.(-10:10), sin.(-30:30)) |> x -> DataFrame([x], :auto)
8890
fit_transform!(autoaddt, X)
8991
end

AutoAI/src/skanomalydetector.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ function transform!(adl::SKAnomalyDetector, xx::DataFrame)::Vector
103103
adlearner = adl.model[:adlearner]
104104
if adl.model[:learner] == "LocalOutlierFactor"
105105
res = adlearner.fit_predict(x)
106-
println(typeof(res))
107106
else
108107
res = adlearner.predict(x)
109108
end

0 commit comments

Comments
 (0)