GithubHelp home page GithubHelp logo

[Question] substring search about saxpy HOT 2 CLOSED

nphoff avatar nphoff commented on September 18, 2024
[Question] substring search

from saxpy.

Comments (2)

nphoff avatar nphoff commented on September 18, 2024 1

Hey @kuzeko

Thanks for the question. There was a typo in the readme, which I've fixed which would have made this tough.

What I would do in this example is:

from saxpy import SAX
import math

query = [ math.sin(x)*2 for x in range(2, 5)]
target = [math.sin(x)*2 for x in range(0, 100)]

s = SAX(3, 7) # 3 letter words, 7 letter alphabet
(queryString, queryIndices) = s.to_letter_rep(query)
(targetStrings, targetIndices) = s.sliding_window(target, 33, 0.6)
comparisonScores = s.batch_compare(targetStrings, queryString)

From there, comparisonScores will be a list of comparison scores between subsections of the target and the query.

The lowest comparisonScores values will map to which sections were the most similar. The index of the lowest values can be used with targetIndices to find the position in the original dataset which were the lowest.

For instance when I ran it, comparisonScores[2] and comparisonScores[3] were both 0.0, and targetIndices[2], and targetIndices[3] were respectively (2,5) (exactly the same as the query, which is expected) and (3,6) which is pretty close. There will be other entries in comparisonScores which are 0.0 because the sine function is periodic.

Good luck!

from saxpy.

kuzeko avatar kuzeko commented on September 18, 2024

Fantastic! Thanks a lot!

from saxpy.

Related Issues (6)

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.