Comments (1)
As a first draft inside sindy.jl
using Hyperopt
function SInDy_2(X::AbstractArray{S, 2}, DX::AbstractArray{S, 2}, Ψ::Basis, thresholds::AbstractArray ; f_target = (du, θ, ξ)->norm([norm(ξ, 0); norm(du .- θ'ξ, 2)]), p::AbstractArray = [], t::AbstractVector = [], maxiter::Int64 = 10, opt::T = Optimize.STRRidge(),denoise::Bool = false, normalize::Bool = true, convergence_error = eps()) where {T <: Optimize.AbstractOptimizer, S <: Number}
@assert size(X)[end] == size(DX)[end]
nx, nm = size(X)
ny, nm = size(DX)
θ = Ψ(X, p, t)
scales = ones(eltype(X), length(Ψ))
#ξ = zeros(eltype(X), length(Ψ))
Ξ = zeros(eltype(X), length(Ψ), ny)
iters = 0
denoise ? optimal_shrinkage!(θ') : nothing
normalize ? DataDrivenDiffEq.normalize_theta!(scales, θ) : nothing
for j in 1:ny
ho = @hyperopt for i = length(thresholds), sampler = RandomSampler(), t = thresholds
set_threshold!(opt, t)
iters_ = sparse_regression!(view(Ξ, :, j), view(θ, :, :), DX[j, :]', maxiter, opt, false, false, convergence_error)
f_target(view(DX, j, :), view(θ, :, :), view(Ξ, :, j))
end
t_, f_ = minimum(ho)
set_threshold!(opt, t_[1])
iters_ = sparse_regression!(view(Ξ, :, j), view(θ, :, :), DX[j, :]', maxiter, opt, false, false, convergence_error)
iters_ > iters ? iters = iters_ : nothing
end
return SparseIdentificationResult(Ξ, Ψ, iters, opt, iters < maxiter, DX, X, p = p)
end
For comparision from the pendulum example
# Vary the sparsity threshold -> gives better results
# Use SR3 with high relaxation (allows the solution to diverge from LTSQ) and high iterations
using BenchmarkTools
using Hyperopt
λs = exp10.(-5:0.1:-1)
opt = STRRidge(1e-2)
# With ParetoFront
@btime SInDy(sol[:,:], DX[:, :], basis, λs, p = [1.0; 1.0], maxiter = 1500, opt = opt)
# Output
12.790 s (8700924 allocations: 489.95 MiB)
Sparse Identification Result with 4 active terms.
# With Hyperopt
@btime SInDy_2(sol[:,:], DX[:, :], basis, λs, p = [1.0; 1.0], maxiter = 1500, opt = opt)
16.494 s (8712305 allocations: 496.01 MiB)
Sparse Identification Result with 4 active terms.
from datadrivendiffeq.jl.
Related Issues (20)
- DMD-like solves fail for systems with at least 32 variables HOT 5
- main branch HOT 2
- Linear Time Continuous System Documentation Example Errors in ODESystem Creation HOT 1
- indirect dependency RegularizationTools has GPL license HOT 4
- Unable to reconstruct system from result HOT 3
- Typo in naming STLSQ in documentation
- Basic Usage example fails HOT 1
- Understanding controls HOT 3
- Using DataDrivenSolution for forward modelling HOT 12
- How to get error estimate? HOT 1
- SymbolicUtils v1 upgrade
- Unable to recover the dynamic and predict, when DataDrivenSolution's problem is Discrete DataDrivenProblem HOT 1
- Result printing of Quick Demonstration in README.md is not reproduced HOT 1
- STLSQ method results in different models from pySINDy? HOT 4
- References for underlying methids
- Using DataDrivenDataset for DMD and SR
- Improve docstrings
- DataDrivenProblem takes a very long time HOT 2
- Model discovery using Sparse Regression on a UDE model
- Problem with dimension
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from datadrivendiffeq.jl.