MilesCranmer / SymbolicRegression.jl

Distributed High-Performance Symbolic Regression in Julia
https://ai.damtp.cam.ac.uk/symbolicregression/
Apache License 2.0
644 stars 86 forks source link

EquationSearch not defined #22

Closed MichielStock closed 3 years ago

MichielStock commented 3 years ago

Hi, at Julia 1.5.3, I installed the packge as specified on the readme. It says that EquationSearch is not defined when I run the example:

julia> hallOfFame = EquationSearch(X, y, niterations=5, options=options, numprocs=4)
ERROR: UndefVarError: EquationSearch not defined
Stacktrace:
 [1] top-level scope at REPL[6]:1

Should I install a specific version or so? (master/dev)?

MilesCranmer commented 3 years ago

Hm, did you import the package with using (will work), or import (won't work; need to do SymbolicRegression.EquationSearch)?

MichielStock commented 3 years ago

Yes, I just used the direct example of the readme:

julia> using SymbolicRegression

julia> X = randn(Float32, 5, 100)
5×100 Array{Float32,2}:
 -0.852392   0.47896    0.748648  …  -1.12963    -0.761157   -0.197851
  0.779859   0.984688   0.262384      0.907288   -0.641572    0.191076
  0.60758    0.51913   -0.623348      0.139178   -0.0790888   1.07452
 -0.600319   0.705093   1.27981      -0.0430678   0.0848815   1.40372
 -1.00895   -0.587957  -0.25969      -0.110676   -0.517099    0.125628

julia> y = 2 * cos.(X[4, :]) + X[1, :] .^ 2 .- 2
100-element Array{Float32,1}:
  0.3768823
 -0.24749398
 -0.8657408
  5.1031814
  0.085240364
  0.08334136
  0.71512413
  0.63902736
  1.4767964
  0.2833886
  ⋮
  0.09147143
 -2.457047
  0.28632188
 -0.960955
  0.04397893
  0.5678241
  1.2742057
  0.5721595
 -1.6282557

julia> options = SymbolicRegression.Options(
           binary_operators=(+, *, /, -),
           unary_operators=(cos, exp),
           npopulations=20
       )
Options{Tuple{typeof(+),typeof(*),typeof(/),typeof(-)},Tuple{typeof(cos),typeof(exp)}}((+, *, /, -), (cos, exp), [(-1, -1), (-1, -1), (-1, -1), (-1, -1)], [-1, -1], 10, 0.0001f0, 0.1f0, 20, 20, false, true, true, 0.1f0, true, "hall_of_fame.csv", 20, 3, 1.0f0, true, false, false, 50, false, Real[10.0, 1.0, 1.0, 3.0, 3.0, 0.01, 1.0, 1.0], 0, false, false, 1000, 300, 0.1f0, 10, 1000000000, 0.01f0, 2, 4, false)

julia> hallOfFame = EquationSearch(X, y, niterations=5, options=options, numprocs=4)
ERROR: UndefVarError: EquationSearch not defined
Stacktrace:
 [1] top-level scope at REPL[6]:1

I tried to search whether it is not exported, but the function EquationSearch does not seem to exist in SymbolicRegression. Maybe, there is something wrong with the version in the package manager?

It is curious thing I only observe with this package.

MichielStock commented 3 years ago

I removed some packages and reinstalled this package and now works as advertised! Not sure if this is something at my end (likely) or some other conflict to take note of. Will close. Thanks.