@@ -3,7 +3,6 @@ using ArgParse
33using CSV
44using DataFrames
55using Statistics
6- using AutoAD
76
87
98function parse_commandline ()
@@ -12,23 +11,26 @@ function parse_commandline()
1211 " --url" , " -u"
1312 help = " mlflow server url"
1413 arg_type = String
15- default = " http://localhost:8080"
16- " --prediction_type" , " -t"
17- help = " timeseriesprediction, anomalydetection"
18- arg_type = String
19- default = " anomalydetection"
14+ default = " http://localhost:8081"
2015 " --output_file" , " -o"
2116 help = " output location"
2217 arg_type = String
2318 default = " NONE"
24- " --votepercent" , " -v"
25- help = " votepercent for anomalydetection ensembles"
26- arg_type = Float64
27- default = 0.0
28- " --runid"
19+ " --learner" , " -l"
20+ help = " learner"
21+ arg_type = String
22+ default = " auto"
23+ " --forecast_horizon" , " -f"
24+ help = " forecast horizon"
25+ arg_type = Int64
26+ default = 10
27+ " --runid" , " -r"
2928 help = " runid of experiment for trained model"
3029 arg_type = String
3130 default = " NONE"
31+ " --predict_only" , " -p"
32+ help = " no training, predict only"
33+ action = :store_true
3234 " csvfile"
3335 help = " input csv file"
3436 required = true
@@ -37,30 +39,47 @@ function parse_commandline()
3739end
3840
3941const _cliargs = parse_commandline ()
42+ _cliargs[:csvfile ]= " ./../AutoAD/data/node_cpu_ratio_rate_5m_1d_1m.csv"
43+
4044
41- function autoadmode (args:: Dict )
45+ function doprediction_only (args:: Dict )
46+ fname = args[:csvfile ]
47+ X = CSV. read (fname, DataFrame)
48+ run_id = args[:runid ]
4249 url = args[:url ]
43- votepercent = args[:votepercent ]
50+ predtype = args[:prediction_type ]
51+ mlf= AutoMLFlowTSPrediction ((Dict (:rund_id => run_id,:url => url)))
52+ Yn = transform! (mlf, X)
53+ ofile = args[:output_file ]
54+ if ofile != " NONE"
55+ open (ofile, " w" ) do stfile
56+ println (stfile, " prediction: $Yn " )
57+ end
58+ end
59+ println (stdout , " prediction: $Yn " )
60+ return Yn
61+ end
62+
63+ function dotrainandpredict (args:: Dict )
64+ url = args[:url ]
65+ learner= args[:learner ]
66+ forecast_horizon = args[:forecast_horizon ]
4467 fname = args[:csvfile ]
4568 df = CSV. read (fname, DataFrame)
4669 X = df[:, 1 : 1 ]
47- autoad = AutoMLFlowAnomalyDetection (Dict (:url => url, :impl_args => Dict (:votepercent => votepercent )))
48- Yc = fit_transform! (autoad , X)
70+ autots = AutoMLFlowTSPrediction (Dict (:url => url, :impl_args => Dict (:forecast_horizon => forecast_horizon, :learner => learner )))
71+ Yc = fit_transform! (autots , X)
4972 println (" output:" , Yc |> x -> first (x, 5 ))
5073 return Yc
5174end
5275
53- function autotsmode (args:: Dict )
54- end
55-
5676function main (args)
57- predtype = args[:prediction_type ]
58- if predtype == " anomalydetection"
59- autoadmode (args)
60- elseif predtype == " timeseriesprediction"
61- autotsmode (args)
62- else
63- @error " check cli arguments: $args "
77+ if args[:predict_only ] == true
78+ # predict only using run_id of model in the artifact
79+ doprediction_only (args)
80+ else
81+ # train and predict
82+ dotrainandpredict (args)
6483 end
6584end
6685
0 commit comments