1+ using AutoAD: AutoMLFlowAnomalyDetections
12using Distributed
23using ArgParse
34using CSV
@@ -14,108 +15,63 @@ function parse_commandline()
1415 arg_type = String
1516 default = " http://localhost:8080"
1617 " --prediction_type" , " -t"
17- help = " classification, regression , anomalydetection"
18+ help = " timeseriesprediction , anomalydetection"
1819 arg_type = String
19- default = " classification"
20- # default = "anomalydetection"
21- # default = "regression"
22- " --complexity" , " -c"
23- help = " pipeline complexity"
24- arg_type = String
25- default = " low"
20+ default = " anomalydetecion"
2621 " --output_file" , " -o"
2722 help = " output location"
2823 arg_type = String
2924 default = " NONE"
30- " --nfolds" , " -f"
31- help = " number of crossvalidation folds"
32- arg_type = Int64
33- default = 3
34- " --nworkers" , " -w"
35- help = " number of workers"
36- arg_type = Int64
37- default = 5
3825 " --votepercent" , " -v"
3926 help = " votepercent for anomalydetection ensembles"
4027 arg_type = Float64
4128 default = 0.0
42- " --no_save"
43- help = " save model"
44- action = :store_true
45- " --predict_only"
46- help = " no training, predict only"
47- action = :store_true
4829 " --runid"
4930 help = " runid of experiment for trained model"
5031 arg_type = String
5132 default = " NONE"
5233 " csvfile"
5334 help = " input csv file"
5435 required = true
55- # default = "iris.csv"
56- # default = "iris_reg.csv"
5736 end
5837 return parse_args (s; as_symbols= true )
5938end
6039
61- # const _cliargs = (; parse_commandline()...)
62- _cliargs = parse_commandline ()
63- # const _workers = _cliargs[:workers]
64- _workers = _cliargs[:nworkers ]
40+ const _cliargs = (; parse_commandline ()... )
41+ # _cliargs = parse_commandline()
42+ const _workers = _cliargs[:workers ]
43+ # _workers = _cliargs[:nworkers]
6544
6645nprocs () == 1 && addprocs (_workers; exeflags= [" --project=$(Base. active_project ()) " ])
6746
68- @everywhere using AutoAI
69-
70- function autoclassmode (args:: Dict )
71- url = args[:url ]
72- complexity = args[:complexity ]
73- nfolds = args[:nfolds ]
74- nworkers = args[:nworkers ]
75- prediction_type = args[:prediction_type ]
76- impl_args = (; complexity, nfolds, nworkers, prediction_type) |> pairs |> Dict
77- fname = _cliargs[:csvfile ]
78- df = CSV. read (fname, DataFrame)
79- X = df[:, 1 : end - 1 ]
80- Y = df[:, end ] |> collect
81- autoclass = AutoMLFlowClassification (Dict (:url => url, :impl_args => impl_args))
82- Yc = fit_transform! (autoclass, X, Y)
83- println (" accuracy = " , mean (Y .== Yc))
84- end
47+ @everywhere using AutoAD
8548
86- function autoregmode (args:: Dict )
49+ function autoadmode (args:: Dict )
8750 url = args[:url ]
88- complexity = args[:complexity ]
89- nfolds = args[:nfolds ]
90- nworkers = args[:nworkers ]
9151 prediction_type = args[:prediction_type ]
92- impl_args = (; complexity, nfolds, nworkers, prediction_type) |> pairs |> Dict
93- fname = _cliargs[:csvfile ]
52+ votepercent = args[:votepercent ]
53+ dictargs = (; votepercent, prediction_type) |> pairs |> Dict
54+ fname = args[:csvfile ]
9455 df = CSV. read (fname, DataFrame)
95- X = df[:, 1 : end - 1 ]
96- Y = df[:, end ] |> collect
97- autoreg = AutoMLFlowRegression ( Dict ( :url => url, :impl_args => impl_args) )
98- Yc = fit_transform! (autoreg, X, Y )
99- println ( " mse = " , mean ((Y - Yc) .^ 2 ))
56+ X = df[:, 1 : 1 ]
57+ autoad = AutoMLFlowAnomalyDetections ( Dict ( :url => url, dictargs ... ))
58+ Yc = fit_transform! (autoad, X )
59+ println ( " output: " , Yc |> x -> first (x, 5 ) )
60+ return Yc
10061end
10162
102- function autoadmode (args:: Dict )
103- url = args[:url ]
104- votepercent = args[:votepercent ]
105- X = vcat (5 * cos .(- 10 : 10 ), sin .(- 30 : 30 ), 3 * cos .(- 10 : 10 ), 2 * tan .(- 10 : 10 ), sin .(- 30 : 30 )) |> x -> DataFrame ([x], :auto )
106- mlfad = AutoMLFlowAnomalyDetection (Dict (:url => url, :impl_args => Dict (:votepercent => votepercent)))
107- Yc = fit_transform! (mlfad, X)
108- println (Yc |> x -> first (x, 5 ))
63+ function autotsmode (args:: Dict )
10964end
11065
111- function main ()
112- predtype = _cliargs [:prediction_type ]
113- if predtype == " classification "
114- autoclassmode (_cliargs )
115- elseif predtype == " regression "
116- autoregmode (_cliargs)
66+ function main (args )
67+ predtype = args [:prediction_type ]
68+ if predtype == " anomalydetection "
69+ autoadmode (args )
70+ elseif predtype == " timeseriesprediction "
71+ autotsmode (_cliargs)
11772 elseif predtype == " anomalydetection"
11873 autoadmode (_cliargs)
11974 end
12075end
121- main ()
76+
77+ main (_cliargs)
0 commit comments