Skip to content

cross_entropy leads to ERROR: UndefVarError: isinvalid not defined in StatisticalMeasuresBase #58

@jbrea

Description

@jbrea
julia> using Pkg

julia> Pkg.activate(temp = true)
  Activating new project at `/tmp/jl_OTYlzG`

julia> Pkg.add(["StatisticalMeasures", "CategoricalDistributions"])
   Resolving package versions...
    Updating `/tmp/jl_OTYlzG/Project.toml`
  [af321ab8] + CategoricalDistributions v0.2.0
  [a19d573c] + StatisticalMeasures v0.3.2
    Updating `/tmp/jl_OTYlzG/Manifest.toml`
  [7d9f7c33] + Accessors v0.1.42
  [79e6a3ab] + Adapt v4.4.0
  [66dad0bd] + AliasTables v1.1.3
  [dce04be8] + ArgCheck v2.5.0
  [a9b6321e] + Atomix v1.1.2
  [198e06fe] + BangBang v0.4.6
  [9718e550] + Baselet v0.1.1
  [324d7699] + CategoricalArrays v1.0.2
  [af321ab8] + CategoricalDistributions v0.2.0
  [d360d2e6] + ChainRulesCore v1.26.0
  [3da002f7] + ColorTypes v0.12.1
  [34da2185] + Compat v4.18.1
  [a33af91c] + CompositionsBase v0.1.2
  [187b0558] + ConstructionBase v1.6.0
  [6add18c4] + ContextVariablesX v0.1.3
  [a8cc5b0e] + Crayons v4.1.1
  [9a962f9c] + DataAPI v1.16.0
  [864edb3b] + DataStructures v0.19.1
  [e2d170a0] + DataValueInterfaces v1.0.0
  [244e2a9f] + DefineSingletons v0.1.2
  [8bb1440f] + DelimitedFiles v1.9.1
  [31c24e10] + Distributions v0.25.122
  [ffbed154] + DocStringExtensions v0.9.5
  [cc61a311] + FLoops v0.2.2
  [b9860ae5] + FLoopsBase v0.1.1
  [1a297f60] + FillArrays v1.14.0
  [53c48c17] + FixedPointNumbers v0.8.5
  [46192b85] + GPUArraysCore v0.2.0
  [076d061b] + HashArrayMappedTries v0.2.0
  [34004b35] + HypergeometricFunctions v0.3.28
  [22cec73e] + InitialValues v0.3.1
  [3587e190] + InverseFunctions v0.1.17
  [92d709cd] + IrrationalConstants v0.2.6
  [82899510] + IteratorInterfaceExtensions v1.0.0
  [692b3bcd] + JLLWrappers v1.7.1
  [b14d175d] + JuliaVariables v0.2.4
  [63c18a36] + KernelAbstractions v0.9.38
  [b964fa9f] + LaTeXStrings v1.4.0
  [92ad9a40] + LearnAPI v2.0.1
  [2ab3a3ac] + LogExpFunctions v0.3.29
  [c2834f40] + MLCore v1.0.0
  [d8e11817] + MLStyle v0.4.17
  [f1d291b0] + MLUtils v0.4.8
  [1914dd2f] + MacroTools v0.5.16
  [128add7d] + MicroCollections v0.2.0
  [e1d29d7a] + Missings v1.2.0
  [872c559c] + NNlib v0.9.31
  [71a1bf82] + NameResolution v0.1.5
  [bac558e1] + OrderedCollections v1.8.1
  [90014a1f] + PDMats v0.11.36
  [aea7be01] + PrecompileTools v1.3.3
  [21216c6a] + Preferences v1.5.0
  [8162dcfd] + PrettyPrint v0.2.0
⌅ [08abe8d2] + PrettyTables v2.4.0
  [43287f4e] + PtrArrays v1.3.0
  [1fd47b50] + QuadGK v2.11.2
  [189a3867] + Reexport v1.2.2
  [ae029012] + Requires v1.3.1
  [79098fc4] + Rmath v0.9.0
  [321657f4] + ScientificTypes v3.1.1
  [30f210dd] + ScientificTypesBase v3.0.0
  [7e506255] + ScopedValues v1.5.0
  [efcf1570] + Setfield v1.1.2
  [605ecd9f] + ShowCases v0.1.0
  [699a6c99] + SimpleTraits v0.9.5
  [a2af1166] + SortingAlgorithms v1.2.2
  [276daf66] + SpecialFunctions v2.6.1
  [171d559e] + SplittablesBase v0.1.15
  [90137ffa] + StaticArrays v1.9.15
  [1e83bf80] + StaticArraysCore v1.4.4
  [a19d573c] + StatisticalMeasures v0.3.2
  [c062fc1d] + StatisticalMeasuresBase v0.1.3
  [64bff920] + StatisticalTraits v3.5.0
  [10745b16] + Statistics v1.11.1
  [82ae8749] + StatsAPI v1.7.1
  [2913bbd2] + StatsBase v0.34.7
  [4c63d2b9] + StatsFuns v1.5.2
  [892a3eda] + StringManipulation v0.4.1
  [3783bdb8] + TableTraits v1.0.1
  [bd369af6] + Tables v1.12.1
  [28d57a85] + Transducers v0.4.85
  [013be700] + UnsafeAtomics v0.3.0
  [efe28fd5] + OpenSpecFun_jll v0.5.6+0
  [f50d1b31] + Rmath_jll v0.5.1+0
  [56f22d72] + Artifacts v1.11.0
  [2a0f44e3] + Base64 v1.11.0
  [ade2ca70] + Dates v1.11.0
  [8ba89e20] + Distributed v1.11.0
  [9fa8497b] + Future v1.11.0
  [b77e0a4c] + InteractiveUtils v1.11.0
  [ac6e5ff7] + JuliaSyntaxHighlighting v1.12.0
  [8f399da3] + Libdl v1.11.0
  [37e2e46d] + LinearAlgebra v1.12.0
  [56ddb016] + Logging v1.11.0
  [d6f4376e] + Markdown v1.11.0
  [a63ad114] + Mmap v1.11.0
  [de0858da] + Printf v1.11.0
  [9a3f8284] + Random v1.11.0
  [ea8e919c] + SHA v0.7.0
  [9e88b42a] + Serialization v1.11.0
  [6462fe0b] + Sockets v1.11.0
  [2f01184e] + SparseArrays v1.12.0
  [f489334b] + StyledStrings v1.11.0
  [4607b0f0] + SuiteSparse
  [fa267f1f] + TOML v1.0.3
  [8dfed614] + Test v1.11.0
  [cf7118a7] + UUIDs v1.11.0
  [4ec0a83e] + Unicode v1.11.0
  [e66e0078] + CompilerSupportLibraries_jll v1.3.0+1
  [4536629a] + OpenBLAS_jll v0.3.29+0
  [05823500] + OpenLibm_jll v0.8.7+0
  [bea87d4a] + SuiteSparse_jll v7.8.3+2
  [8e850b90] + libblastrampoline_jll v5.15.0+0
        Info Packages marked with ⌅ have new versions available but compatibility constraints restrict them from upgrading. To see why use `status --outdated -m`

julia> using StatisticalMeasures, CategoricalDistributions

julia> y = categorical(["a", "b"])
2-element CategoricalArray{String,1,UInt32}:
 "a"
 "b"

julia> yhat = [UnivariateFinite(["a", "b"], [.2, .8], pool = missing), UnivariateFinite(["a", "b"], [.3, .7], pool = missing)]
2-element Vector{UnivariateFinite{Multiclass{2}, String, UInt8, Float64}}:
 UnivariateFinite{Multiclass{2}}(a=>0.2, b=>0.8)
 UnivariateFinite{Multiclass{2}}(a=>0.3, b=>0.7)

julia> cross_entropy(y, yhat)
ERROR: UndefVarError: `isinvalid` not defined in `StatisticalMeasuresBase`
Suggestion: check for spelling errors or missing imports.
Stacktrace:
 [1] getproperty
   @ ./Base_compiler.jl:47 [inlined]
 [2] (::StatisticalMeasures.var"#l2_check##0#l2_check##1")(x::CategoricalValue{String, UInt32})
   @ StatisticalMeasures ~/.julia/packages/StatisticalMeasures/ToX5w/src/probabilistic.jl:44
 [3] findnext
   @ ./array.jl:2390 [inlined]
 [4] findfirst
   @ ./array.jl:2441 [inlined]
 [5] l2_check(::StatisticalMeasuresBase.FussyMeasure{…}, ::CategoricalVector{…}, ::Vector{…})
   @ StatisticalMeasures ~/.julia/packages/StatisticalMeasures/ToX5w/src/probabilistic.jl:43
 [6] _call
   @ ~/.julia/packages/StatisticalMeasuresBase/GOCHI/src/fussy_measure.jl:56 [inlined]
 [7] call(::StatisticalMeasuresBase.FussyMeasure{…}, ::CategoricalVector{…}, ::Vector{…})
   @ StatisticalMeasuresBase ~/.julia/packages/StatisticalMeasuresBase/GOCHI/src/fussy_measure.jl:60
 [8] (::StatisticalMeasuresBase.FussyMeasure{…})(arg::CategoricalVector{…}, args::Vector{…})
   @ StatisticalMeasuresBase ~/.julia/packages/StatisticalMeasuresBase/GOCHI/src/wrappers.jl:26
 [9] top-level scope
   @ REPL[7]:1
Some type information was truncated. Use `show(err)` to see complete types.

julia> versioninfo()
Julia Version 1.12.1
Commit ba1e628ee49 (2025-10-17 13:02 UTC)
Build Info:
  Official https://julialang.org release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 16 × AMD Ryzen 7 PRO 5850U with Radeon Graphics
  WORD_SIZE: 64
  LLVM: libLLVM-18.1.7 (ORCJIT, znver3)
  GC: Built with stock GC
Threads: 1 default, 1 interactive, 1 GC (on 16 virtual cores)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions