nla-group / abba Goto Github PK
View Code? Open in Web Editor NEWA symbolic time series representation building Brownian bridges
License: MIT License
A symbolic time series representation building Brownian bridges
License: MIT License
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.
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 which can be used to compute warping paths in general distances (e.g. using dist function handle).
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.
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
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 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 function into two:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.