invenia / Impute.jl

Imputation methods for missing data in julia
https://invenia.github.io/Impute.jl/latest/
Other
76 stars 11 forks source link

impute.Locf() keeps on faiiling with an error MethodError: objects of type Impute.LOCF are not callable #62

Closed AndyAbok closed 4 years ago

AndyAbok commented 4 years ago

commodities = ["crude", "gas", "gold", "silver","other"] last_price = [4.2, 11.3, 12.1, missing,missing] df8 = DataFrame(commod = commodities, price = last_price) df9 = df8 |> Impute.LOCF()

rofinn commented 4 years ago

Yes, having callable imputor types was deprecated several months ago, which is why we made a breaking release. That being said, you can always do:

julia> df9 = df8 |> Impute.locf()
5×2 DataFrame
│ Row │ commod │ price    │
│     │ String │ Float64? │
├─────┼────────┼──────────┤
│ 1   │ crude  │ 4.2      │
│ 2   │ gas    │ 11.3     │
│ 3   │ gold   │ 12.1     │
│ 4   │ silver │ 12.1     │
│ 5   │ other  │ 12.1     │

or

julia> df9 = impute(df8, Impute.LOCF())
5×2 DataFrame
│ Row │ commod │ price    │
│     │ String │ Float64? │
├─────┼────────┼──────────┤
│ 1   │ crude  │ 4.2      │
│ 2   │ gas    │ 11.3     │
│ 3   │ gold   │ 12.1     │
│ 4   │ silver │ 12.1     │
│ 5   │ other  │ 12.1     │
AndyAbok commented 4 years ago

so when i use the first one here is the error i get df9 = df8 |> Impute.locf() UndefVarError: locf not defined on using the second one here is the error i get df9 = impute(df8, Impute.LOCF()) MethodError: no method matching impute!(::DataFrame, ::Impute.LOCF) Closest candidates are:

full code using DataFrames using Impute commodities = ["crude", "gas", "gold", "silver","other"] last_price = [4.2, 11.3, 12.1, missing,missing] df8 = DataFrame(commod = commodities, price = last_price) df9 = df8 |> Impute.locf() df9 = impute(df8, Impute.LOCF()) not quite figuring out what the issue is

rofinn commented 4 years ago

Please provide your output from ] st --manifest and also any other context about how this is being called. The locf not defined error sounds like Impute hasn't been loaded into scope properly.

AndyAbok commented 4 years ago

so this is the first error on using the first option df9 = df8 |> Impute.locf() ERROR: UndefVarError: locf not defined Stacktrace: [1] getproperty(::Module, ::Symbol) at .\Base.jl:26

thats the whole error the second option produces this error df9 = impute(df8, Impute.LOCF()) ERROR: MethodError: no method matching impute!(::DataFrame, ::Impute.LOCF) Closest candidates are: impute!(::Union{DataFrame, AbstractArray}, ::Symbol, ::Any...; limit) at C:\Users\andrewa.julia\packages\Impute\UX99F\src\Impute.jl:52 impute!(::Union{DataFrame, AbstractArray}, ::Function, ::Symbol, ::Any...; limit) at C:\Users\andrewa.julia\packages\Impute\UX99F\src\Impute.jl:72 Stacktrace: [1] impute(::DataFrame, ::Impute.LOCF; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at C:\Users\andrewa.julia\packages\Impute\UX99F\src\Impute.jl:84 [2] impute(::DataFrame, ::Impute.LOCF) at C:\Users\andrewa.julia\packages\Impute\UX99F\src\Impute.jl:84

so i tried updating and re installing the library but still same error

rofinn commented 4 years ago

You're just running this on the REPL and not on a distributed process (julia code loading works differently for that)? What list of symbols shows up if you tab Impute.? Please post the package versions you have installed, so that I can try to reproduce it (ideally, the manifest).

AndyAbok commented 4 years ago

i am not sure i understand how to go about this You're just running this on the REPL and not on a distributed process (julia code loading works differently for that)

AndyAbok commented 4 years ago

about the package version here is the whole update
@v1.4) pkg> up Impute Updating registry at C:\Users\andrewa\.julia\registries\General Updating git-repo https://github.com/JuliaRegistries/General.git Installed TableOperations ── v0.2.1 Installed NearestNeighbors ─ v0.4.4 Installed Parsers ────────── v1.0.5 Installed CSTParser ──────── v2.3.1 Installed JuliaInterpreter ─ v0.7.21 Installed Impute ─────────── v0.5.0 Installed CuArrays ───────── v2.2.1 Installed Distributions ──── v0.23.4 Installed Compat ─────────── v3.11.0 Installed IterTools ──────── v1.3.0 Installed StatsBase ──────── v0.32.2 Installed Colors ─────────── v0.12.2 Installed JuliaFormatter ─── v0.6.2 Updating C:\Users\andrewa\.julia\environments\v1.4\Project.toml [f7bf1975] ↑ Impute v0.1.1 ⇒ v0.5.0 Updating C:\Users\andrewa\.julia\environments\v1.4\Manifest.toml [00ebfdb7] ↑ CSTParser v2.3.0 ⇒ v2.3.1 [5ae59095] ↑ Colors v0.12.1 ⇒ v0.12.2 [34da2185] ↑ Compat v3.10.0 ⇒ v3.11.0 [3a865a2d] ↑ CuArrays v2.2.0 ⇒ v2.2.1 [31c24e10] ↑ Distributions v0.23.3 ⇒ v0.23.4 [f7bf1975] ↑ Impute v0.1.1 ⇒ v0.5.0 [c8e1da08] + IterTools v1.3.0 [98e50ef6] ↑ JuliaFormatter v0.6.1 ⇒ v0.6.2 [aa1ae85d] ↑ JuliaInterpreter v0.7.17 ⇒ v0.7.21 [b8a86587] + NearestNeighbors v0.4.4 [69de0a69] ↑ Parsers v1.0.4 ⇒ v1.0.5 [90137ffa] + StaticArrays v0.12.3 [2913bbd2] ↓ StatsBase v0.33.0 ⇒ v0.32.2 [ab02a1b2] + TableOperations v0.2.1

rofinn commented 4 years ago

Hmmm, 0.1.1 => 0.5.0 is a pretty big update. Did you restart your REPL after updating? I would suggestion 1) start a new REPL session 2) run using Impute and 3) tab complete Impute. to see that you see the list of symbols below.

julia> using Impute

julia> Impute.
AbstractContext         Fill                     LOCF                     _dep_message_Drop        chain!                   dropvars                 filterobs                include                  ismissing!               missing_update!          splitkwargs              vardim
Chain                   ImputeError              NOCB                     _extract_context_kwargs  complete                 dropvars!                filtervars               interp                   knn                      nocb                     srs                      varwise
Context                 Imputor                  SRS                      _impute                  drop!                    eval                     imputation_methods       interp!                  knn!                     nocb!                    srs!
DropObs                 Interpolate              SVD                      _impute!                 dropobs                  fill                     impute                   interpolate              locf                     obsdim                   svd
DropVars                KNN                      WeightedContext          chain                    dropobs!                 fill!                    impute!                  interpolate!             locf!                    obswise                  svd!
rofinn commented 4 years ago

Yeah, if I look at the 0.1.1 release from 2 years ago we didn't have a locf function... you just passed :locf or LOCF() to the impute function.

AndyAbok commented 4 years ago

perfect that sorted it good to go much appreciated.

rofinn commented 4 years ago

Awesome, glad we got it sorted!