Giter Club home page Giter Club logo

Comments (5)

Datseris avatar Datseris commented on June 14, 2024 1

What did you do about the fact that this implements forward embedding?

Hmmmmmmmmmmmmmmm

from timeseriesprediction.jl.

JonasIsensee avatar JonasIsensee commented on June 14, 2024
function indices_within(radius, dimension)
    #Return indices β within hypersphere with radius
    #Floor radius to nearest integer. Does not lose points
    r = floor(Int,radius)
    #Hypercube of indices
    hypercube = CartesianIndices((repeat([-r:r], dimension)...,))
    #Select subset of hc which is in Hypersphere

    βs = [ β for β ∈ hypercube if norm(β.I) <= radius ]
end


function TimeseriesPrediction.SpatioTemporalEmbedding(
    s::AbstractArray{<:AbstractArray{T,Φ}}, ΔT, τ, speed, boundary::BC
    ) where {T,Φ, BC<:AbstractBoundaryCondition}
    if !(BC <: PeriodicBoundary) && typeof(boundary.c) != T
        throw(ArgumentError(
        "Boundary value must be same element type as the timeseries data."))
    end

    τs = Int[]
    βs = CartesianIndex{Φ}[]
    for delay = ΔT:-τ:1 # Backwards for forward embedding 1:τ:ΔT
        radius = max(speed*delay, 1.) # No radius lower than 1
        β = indices_within(radius, Φ)
        push!(βs, β...)
        push!(τs, repeat([ΔT - delay], length(β))...)
    end
    X = length(τs)
    return SpatioTemporalEmbedding{X}(τs, βs, boundary, size(s[1]))
end



function visualize_STE(em::STE{2})
    figure()
    grid()
    axis("equal")
    r = maximum([max(β.I...) for β in em.β])
    xticks(-r:r)
    yticks(-r:r)
    for τ in em.τ
        points = [ β.I for (delay,β) in zip(em.τ,em.β) if delay == τ]
        x = map(xy -> xy[1], points)
        y = map(xy -> xy[2], points)
        scatter(x,y, c="C$τ", s=100)

        #Plot Circle
        radius = maximum(norm.(points))
        x = radius*cos.(0:0.1:2π)
        y = radius*sin.(0:0.1:2π)
        plot(x,y, c="C$τ")
    end
    scatter([0],[0], color="black", s=200)
end


s = [rand(10,10) for i =1:5];
em = SpatioTemporalEmbedding(s, 5,1,1,PeriodicBoundary())

visualize_STE(em)

from timeseriesprediction.jl.

JonasIsensee avatar JonasIsensee commented on June 14, 2024

@Datseris : This Constructor is quite simple.
I think we could also just add it into the library on top of highlighting it as as example in the docs.

from timeseriesprediction.jl.

JonasIsensee avatar JonasIsensee commented on June 14, 2024

example_cone
Example with ΔT = 1, τ = 1 and speed =1

from timeseriesprediction.jl.

JonasIsensee avatar JonasIsensee commented on June 14, 2024

Not sure what your comment means.
To clarify:
AFAICT DynamicalSystemsBase.jl implements a forward embedding such as

x[t] = (s[t], s[t+τ], ... , s[t+D*τ])

or in the new implementation with

x[t] = (s[t], s[t+τ[1]], ..., s[t+τ[D]])

with all τ > 0 and the largest τ referring the most recent measurement.

The same is true for TimeseriesPrediction.jl: Only positive τ that are used as s[t+τ] (instead of s[t-τ] which could also be done)

This is important for this type of embedding. If I do it the wrong way around, we end up with a cone that expands in the wrong direction of time.

from timeseriesprediction.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.