-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy paththread_example.jl
53 lines (46 loc) · 1.11 KB
/
thread_example.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# note: this example only works on pure julia implementations of
# preprocessing elements and learners. Scikitlearn and other
# PyCall functions are not thread-safe and cannot be used inside
# the threads loop.
# activate local env
using Pkg
Pkg.activate(".")
using AutoMLPipeline
using AutoMLPipeline.Utils
using Base.Threads
using DataFrames
# disable warnings
import PythonCall
const PYC=PythonCall
warnings = PYC.pyimport("warnings")
warnings.filterwarnings("ignore")
begin
profbdata = getprofb()
X = profbdata[:,2:end]
Y = profbdata[:,1] |> Vector;
head(x)=first(x,5)
head(profbdata)
end
#### Column selector
catf = CatFeatureSelector();
numf = NumFeatureSelector()
ohe = OneHotEncoder()
#### Learners
rf = RandomForest();
ada = Adaboost()
dt=PrunedTree()
accuracy(X,Y)=score(:accuracy,X,Y)
acc=[]
learners=[rf,ada,dt]
@threads for i in 1:30
@threads for lr in learners
println(lr.name)
pipe=@pipeline ((catf |> ohe) +(numf )) |> lr
m=crossvalidate(pipe,X,Y,accuracy,10,true)
push!(acc,(m...,name=lr.name))
println(m)
end
end
res = DataFrame(acc)
sort!(res, :mean, rev=true)
res