SciML / DataDrivenDiffEq.jl

Data driven modeling and automated discovery of dynamical systems for the SciML Scientific Machine Learning organization
https://docs.sciml.ai/DataDrivenDiffEq/stable/
MIT License
405 stars 57 forks source link

OccamNet Example #282

Open Gregliest opened 3 years ago

Gregliest commented 3 years ago

It looks like the OccamNet example is working in the new version of the docs. However, running locally, I can't get the basis to show up from the result. Running the following:

using DataDrivenDiffEq, LinearAlgebra, ModelingToolkit, Random
using Flux

Random.seed!(1223)

# Generate a multivariate dataset
X = rand(2,10)
f(x) = [sin(π*x[2]+x[1]); exp(x[2])]
Y = hcat(map(f, eachcol(X))...)

net = OccamNet(2, 2, 3, Function[sin, +, *, exp], skip = true, constants = Float64[π])

ddprob = DirectDataDrivenProblem(X, Y)
# Define the algorithm
sr_alg = OccamSR(functions = Function[sin, +, *, exp], skip = true, layers = 3, constants = [π])
# Solve the problem
res = solve(ddprob, sr_alg, ADAM(1e-2), max_iter = 1000, routes = 100, nbest = 3)
metrics(res)
result(res)

results in:

...
(Probability = 0.8476026045508704, Error = 0.0, AICC = Inf, Probabilities = [0.8964230501159264, 0.9455386097459872], Errors = [0.0, 0.0], AICCs = [Inf, Inf])

Model ##Basis#288 with 2 equations
States (2):
  x[1]
  x[2]
Parameters (0):

I'd expect the full basis to show up with the equations. What's going on here?

AlCap23 commented 2 years ago

I think this is related to the REPL (assuming you are using it here) and since we are reusing the AbstractSystem this falls back to show.