Code Monkey home page Code Monkey logo

Comments (5)

rusandris avatar rusandris commented on June 17, 2024 1

We could potentially also add a specific method for StateSpaceSet{1}

Yep, seems reasonable. The method could look like something like this:

function codify(est::OrdinalOutcomeSpace{m}, x::StateSpaceSet{1})
  throw(ArgumentError("A `StateSpaceSet` input is assumed to be already embedded. Convert your univariate time series to a subtype of `AbstractVector` to codify with ordinal patterns!"))
end

from complexitymeasures.jl.

rusandris avatar rusandris commented on June 17, 2024 1

We should probably also add a comment that ordinal pattern outcome spaces are only defined for m >= 2

Added this to the PR #359

from complexitymeasures.jl.

kahaaga avatar kahaaga commented on June 17, 2024

Thanks for opening this, @rusandris. The problem is here:

function codify(est::OrdinalOutcomeSpace{m}, x) where m
    if x isa AbstractVector
        dataset = embed(x, m, est.τ)
    else
        dataset = x
    end
    m != dimension(dataset) && throw(ArgumentError(
        "Order of ordinal patterns and dimension of `StateSpaceSet` must match!"
    ))
    πs = zeros(Int, length(dataset))
    @inbounds for (i, χ) in enumerate(dataset)
        πs[i] = encode(est.encoding, χ)
    end
    return πs
end

As per the docstring of OrdinalPatterns , we have:

  • If the input is an AbstractVector, then it is assumed that embedding should be done.
  • If the input x is a StateSpaceSet, then codify treats it as is: assuming that the user has pre-embedded their data. This is essentially what you've done here by generating data using trajectory, which always returns a StateSpaceSet (although in the case of 1D systems, it is just the identity embedding).

This behavior will not change.

However, we could perhaps add an extra error message for when the input is a state-space set whose dimension doesn't match m. Perhaps we could add a method like:

function codify(est::OrdinalOutcomeSpace{m}, x::StateSpaceSet{D}) where {m, D}
    if (m != D) 
      throw(ArgumentError("A `D`-dimensional `StateSpaceSet` was given as input, but the outcome space has ordinal pattern length `m = $m`. These must match."))
  end
end 

What do you think, @rusandris? The precise wording of the error message can be discussed, of course. We could potentially also add a specific method for StateSpaceSet{1} with a gentle reminder to the user that they have to convert their 1D state space set to a vector, if they've forgotten (EDIT: if they want the data to be embedded).

from complexitymeasures.jl.

kahaaga avatar kahaaga commented on June 17, 2024

Yep, seems reasonable. The method could look like something like this:

Looks good to me. Feel like doing the PR, @rusandris?

from complexitymeasures.jl.

kahaaga avatar kahaaga commented on June 17, 2024

We should probably also add a comment that ordinal pattern outcome spaces are only defined for m >= 2, so they will never work with one-dimensional state space sets anyways (or something along those lines). I'm not sure if this is immediately obvious to a user that tries what you did and gets this warning.

from complexitymeasures.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.