Closed azev77 closed 3 years ago
julia> using MLJTime julia> # load data X, y = ts_dataset("Chinatown"); julia> # split data into training and test set train, test = partition(eachindex(y), 0.7, shuffle=true, rng=1234); #70:30 split julia> X_train, y_train = X[train], y[train]; julia> X_test, y_test = X[test], y[test]; julia> # train model model = TimeSeriesForestClassifier(n_trees=3) TimeSeriesForestClassifier( n_trees = 3, random_state = nothing, min_interval = 3, max_depth = -1, min_samples_leaf = 1, min_samples_split = 2, min_purity_increase = 0.0, n_subfeatures = 0, post_prune = false, merge_purity_threshold = 1.0, pdf_smoothing = 0.0, display_depth = 5) @784 julia> mach = machine(model, X_train, y_train) Machine{TimeSeriesForestClassifier} @035 trained 0 times. args: 1: Source @887 ⏎ `ScientificTypes.Table{AbstractArray{ScientificTypes.Continuous,1}}` 2: Source @175 ⏎ `AbstractArray{ScientificTypes.Multiclass{2},1}` julia> fit!(mach) [ Info: Training Machine{TimeSeriesForestClassifier} @035. ┌ Error: Problem fitting the machine Machine{TimeSeriesForestClassifier} @035, possibly because an upstream node in a learning network is providing data of incompatible scitype. └ @ MLJBase ~/.julia/packages/MLJBase/Ov46j/src/machines.jl:422 [ Info: Running type checks... [ Info: Type checks okay. ERROR: MethodError: no method matching TimeSeriesForestClassifier(::TimeSeriesForestClassifier, ::IndexedTables.IndexedTable{StructArrays.StructArray{NTuple{24,Float64},1,NTuple{24,Array{Float64,1}},Int64}}, ::Array{UInt32,1}) Closest candidates are: TimeSeriesForestClassifier(::Any, ::Array, ::Array) at /Users/AZevelev/.julia/packages/MLJTime/61x0z/src/interval_based_forest.jl:12 Stacktrace: [1] fit_only!(::MLJBase.Machine{TimeSeriesForestClassifier}; rows::Nothing, verbosity::Int64, force::Bool) at /Users/AZevelev/.julia/packages/MLJBase/Ov46j/src/machines.jl:433 [2] fit_only! at /Users/AZevelev/.julia/packages/MLJBase/Ov46j/src/machines.jl:386 [inlined] [3] #fit!#85 at /Users/AZevelev/.julia/packages/MLJBase/Ov46j/src/machines.jl:478 [inlined] [4] fit!(::MLJBase.Machine{TimeSeriesForestClassifier}) at /Users/AZevelev/.julia/packages/MLJBase/Ov46j/src/machines.jl:476 [5] top-level scope at none:1 julia> # make predictions y_pred = predict_mod(mach, X_test) ERROR: UndefVarError: predict_mod not defined Stacktrace: [1] top-level scope at none:1 julia>
It works if you replace: mach = machine(model, X_train, y_train) With: mach = machine(model, matrix(X[train]), y[train])
mach = machine(model, X_train, y_train)
mach = machine(model, matrix(X[train]), y[train])
https://github.com/alan-turing-institute/MLJTime.jl/pull/12
Thank you very much:)