Skip to content

[BUG]: Cannot load guesses with complex numbers #581

@gm89uk

Description

@gm89uk

What happened?

guesses gets confused with "im" if dealing with complex numbers. Example input:
Complexity Loss Equation
1 0.060197003 RC_vector
3 0.017789923 (-0.2052275f0 - 0.016992446f0im) + RC_vector
5 0.017055396 (-0.21000202f0 - 0.016444953f0im) + (RC_vector / (0.97645104f0 + 0.00017897492f0im))

guesses = CSV.read("...\\hall_of_fame.csv", DataFrame).Equation
model = SRRegressor(
    niterations          = 1_000_000,
    binary_operators     = [+, -, *, /],
    maxsize              = 35,
    guesses = guesses,
    parallelism          = :multiprocessing,
    procs                = procs,
    populations          = 32,
    population_size      = 200,
    batch_size = 5000,
    batching = true,
    parsimony            = 0.0005,
)
mach = machine(model, X, y)
fit!(mach)

Code will run fine if I comment out guesses.

Thanks again for your support of this amazing package!

Version

SymbolicRegression v2.0.0-alpha.9

Operating System

Windows

Interface

Julia REPL

Relevant log output

[ Info: It seems an upstream node in a learning network is providing data of incompatible scitype. See above.
ERROR: ArgumentError: Variable `im` not found in `variable_names`. Consider interpolating with $ if passing a value.
Stacktrace:
  [1] parse_leaf(ex::Symbol, variable_names::Vector{String}, node_type::Type{DynamicExpressions.NodeModule.Node{ComplexF32, 2}}, expression_type::Type{Expression}; kws::@Kwargs{})
    @ DynamicExpressions.ParseModule C:\Users\George\.julia\packages\DynamicExpressions\x2aIa\src\Parse.jl:453
  [2] parse_leaf
    @ C:\Users\George\.julia\packages\DynamicExpressions\x2aIa\src\Parse.jl:433 [inlined]
  [3] #_parse_expression#19
    @ C:\Users\George\.julia\packages\DynamicExpressions\x2aIa\src\Parse.jl:430 [inlined]
  [4] _parse_expression
    @ C:\Users\George\.julia\packages\DynamicExpressions\x2aIa\src\Parse.jl:421 [inlined]
  [5] #12
    @ C:\Users\George\.julia\packages\DynamicExpressions\x2aIa\src\Parse.jl:345 [inlined]
  [6] map(f::DynamicExpressions.ParseModule.var"#12#16"{Expression, DynamicExpressions.NodeModule.Node{ComplexF32, 2}, @Kwargs{}, OperatorEnum{Tuple{Tuple{}, Tuple{typeof(+), typeof(-), typeof(*), typeof(/)}}}, Vector{String}, Nothing}, t::Tuple{Float32, Symbol})
    @ Base .\tuple.jl:356

Extra Info

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions