using DataFrames using Dates using Random ENV["COLUMNS"]=1000 # for dataframe column size function generateXY() Random.seed!(123) gdate = DateTime(2014,1,1):Dates.Minute(15):DateTime(2014,1,5) gval = Array{Union{Missing,Float64}}(rand(length(gdate))) gmissing = floor(0.30*length(gdate)) |> Integer gndxmissing = Random.shuffle(1:length(gdate))[1:gmissing] X = DataFrame(Date=gdate,Value=gval) X.Value[gndxmissing] .= missing Y = rand(length(gdate)) (X,Y) end; (df,outY)=generateXY(); first(df,10) using TSML pltr=Plotter(Dict(:interactive => true)) mypipeline = Pipeline(Dict( :transformers => [pltr] ) ) fit!(mypipeline, df) transform!(mypipeline, df) statfier = Statifier(Dict(:processmissing=>false)) mypipeline = Pipeline(Dict( :transformers => [statfier] ) ) fit!(mypipeline, df) res = transform!(mypipeline, df) valgator = DateValgator(Dict(:dateinterval=>Dates.Hour(1))) mypipeline = Pipeline(Dict( :transformers => [valgator,pltr] ) ) fit!(mypipeline, df) transform!(mypipeline, df) fname = joinpath(dirname(pathof(TSML)),"../data/testdata.csv") csvreader = CSVDateValReader(Dict(:filename=>fname,:dateformat=>"dd/mm/yyyy HH:MM")) outputname = joinpath(dirname(pathof(TSML)),"/tmp/testdata_output.csv") csvwriter = CSVDateValWriter(Dict(:filename=>outputname)) valgator = DateValgator(Dict(:dateinterval=>Dates.Hour(1))) valputer = DateValNNer(Dict(:dateinterval=>Dates.Hour(1))) stfier = Statifier(Dict(:processmissing=>true)) outliernicer = Outliernicer(Dict(:dateinterval=>Dates.Hour(1))); mpipeline1 = Pipeline(Dict( :transformers => [csvreader,valgator,pltr] ) ) fit!(mpipeline1) transform!(mpipeline1) mpipeline1 = Pipeline(Dict( :transformers => [csvreader,valgator,stfier] ) ) fit!(mpipeline1) respipe1 = transform!(mpipeline1) mpipeline2 = Pipeline(Dict( :transformers => [csvreader,valgator,valputer,statfier] ) ) fit!(mpipeline2) respipe2 = transform!(mpipeline2) mpipeline2 = Pipeline(Dict( :transformers => [csvreader,valgator,valputer,pltr] ) ) fit!(mpipeline2) transform!(mpipeline2) regularfile = joinpath(dirname(pathof(TSML)),"../data/typedetection/regular.csv") monofile = joinpath(dirname(pathof(TSML)),"../data/typedetection/monotonic.csv") dailymonofile = joinpath(dirname(pathof(TSML)),"../data/typedetection/dailymonotonic.csv") regularfilecsv = CSVDateValReader(Dict(:filename=>regularfile,:dateformat=>"dd/mm/yyyy HH:MM")) monofilecsv = CSVDateValReader(Dict(:filename=>monofile,:dateformat=>"dd/mm/yyyy HH:MM")) dailymonofilecsv = CSVDateValReader(Dict(:filename=>dailymonofile,:dateformat=>"dd/mm/yyyy HH:MM")) valgator = DateValgator(Dict(:dateinterval=>Dates.Hour(1))) valputer = DateValNNer(Dict(:dateinterval=>Dates.Hour(1))) stfier = Statifier(Dict(:processmissing=>true)) mononicer = Monotonicer(Dict()) stfier = Statifier(Dict(:processmissing=>true)) outliernicer = Outliernicer(Dict(:dateinterval=>Dates.Hour(1))); monopipeline = Pipeline(Dict( :transformers => [monofilecsv,valgator,valputer,pltr] ) ) fit!(monopipeline) transform!(monopipeline) monopipeline = Pipeline(Dict( :transformers => [monofilecsv,valgator,valputer,mononicer, pltr] ) ) fit!(monopipeline) transform!(monopipeline) monopipeline = Pipeline(Dict( :transformers => [monofilecsv,valgator,valputer,mononicer,outliernicer,pltr] ) ) fit!(monopipeline) transform!(monopipeline) dailymonopipeline = Pipeline(Dict( :transformers => [dailymonofilecsv,valgator,valputer,pltr] ) ) fit!(dailymonopipeline) transform!(dailymonopipeline) dailymonopipeline = Pipeline(Dict( :transformers => [dailymonofilecsv,valgator,valputer,mononicer,pltr] ) ) fit!(dailymonopipeline) transform!(dailymonopipeline) dailymonopipeline = Pipeline(Dict( :transformers => [dailymonofilecsv,valgator,valputer,mononicer,outliernicer,pltr] ) ) fit!(dailymonopipeline) transform!(dailymonopipeline) using TSML: TSClassifier Random.seed!(12) trdirname = joinpath(dirname(pathof(TSML)),"../data/realdatatsclassification/training") tstdirname = joinpath(dirname(pathof(TSML)),"../data/realdatatsclassification/testing") modeldirname = joinpath(dirname(pathof(TSML)),"../data/realdatatsclassification/model") tscl = TSClassifier(Dict(:trdirectory=>trdirname, :tstdirectory=>tstdirname, :modeldirectory=>modeldirname, :feature_range => 6:20, :num_trees=>50) ) fit!(tscl) dfresults = transform!(tscl); apredict = dfresults.predtype fnames = dfresults.fname myregex = r"(?[A-Z _ - a-z]+)(?\d*).(?\w+)" mtypes=map(fnames) do fname mymatch=match(myregex,fname) mymatch[:dtype] end sum(mtypes .== apredict)/length(mtypes) * 100 |> x-> round(x,digits=2)