GithubHelp home page GithubHelp logo

nla-group / abba Goto Github PK

View Code? Open in Web Editor NEW
17.0 7.0 6.0 44.52 MB

A symbolic time series representation building Brownian bridges

License: MIT License

Python 81.75% Makefile 0.97% C++ 16.60% SWIG 0.67%
time-series time-series-clustering

abba's People

Contributors

chenxinye avatar guettel avatar stevenelsworth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

abba's Issues

Order of cluster names

Assign cluster symbols a,b,c... ordered by the number of pieces in each cluster so that a is the most populated cluster, followed by b, etc.

TypeError: ord() expected string of length

It is found that code with the problem:

ts = np.sin(7np.linspace(0,41.8*np.pi,2400))
ts = np.array(ts)
ts -= np.median(ts)
ts *= len(ts)/norm(ts,1)

TOL = .333
abba = ABBA.ABBA(tol=TOL, norm=1);
pieces = abba.compress(ts)
polyg = abba.inverse_compress(ts[0], pieces)
polyg = np.array(polyg)

string, centers = abba.digitize_incremental(pieces)
print('Polygon now represented by the string', string) # output: " Polygon now represented by the string [0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2]"

approx = abba.inverse_transform(string, centers, ts[0]) # TypeError: ord() expected string of length 1, but int found

Add dtw function to module

Add dtw function which can be used to compute warping paths in general distances (e.g. using dist function handle).

Average shape of each cluster

It would be nice to have a way of computing an average shape of the ABBA pieces in each cluster and then use these for visualisation.

Quantize function does not work as stated in the paper

Hello, I am reimplementing all of the code and I just found that the quantize function does not work as it is supposed to be according to the paper.

def quantize(self, pieces):
       if len(pieces) == 1:
           pieces[0,0] = round(pieces[0,0])
       else:
           for p in range(len(pieces)-1):
               corr = round(pieces[p,0]) - pieces[p,0]
               pieces[p,0] = round(pieces[p,0] + corr)
               pieces[p+1,0] = pieces[p+1,0] - corr
               if pieces[p,0] == 0:
                   pieces[p,0] = 1
                   pieces[p+1,0] -= 1
           pieces[-1,0] = round(pieces[-1,0])
       return pieces

The paper states that $len_1$ should become $\text{round}(len_1)$ which is not the case here.

Fix convergenceWarning

I fix a bug arisen from the number unique pieces is more than the specified number of kmeans clusters:

ConvergenceWarning: Number of distinct clusters (6) found smaller than n_clusters (9). Possibly due to duplicate points in X.
kmeans = KMeans(n_clusters=k, tol=0, random_state=0).fit(data)

ConvergenceWarning: Number of distinct clusters (8) found smaller than n_clusters (9). Possibly due to duplicate points in X.
kmeans = KMeans(n_clusters=k, tol=0, random_state=0).fit(data)
file: ShakeGestureWiimoteZ_TEST.tsv

ABBA symmetric param error

abba has a bug when setting symmetric as False:

#---------------------------------------------------------
define time series
ts = np.sin(7np.linspace(0,41.8*np.pi,2400))
ts = np.array(ts)
ts -= np.median(ts)
ts *= len(ts)/norm(ts,1)

abba = ABBA.ABBA(tol=TOL, norm=1,min_k=1, max_k=2, weighted=True, symmetric=False)
string, centers = abba.transform(ts)

reconstructed_ts = abba.inverse_transform(string, centers, ts[0])
plt.figure(figsize=(10,5))
plt.plot(ts,label='original')
plt.plot(reconstructed_ts,label='reconstruction')
plt.legend()
plt.show()
#---------------------------------------------------------

And run this code you will find that the series reconstructed will far away from the original series.

Split digitization

Split digitization function into two:

  1. Form clusters
  2. Apply clusters.
    This will allow us to use ABBA to convert time series with previously formed clusters.

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.