GithubHelp home page GithubHelp logo

klon / ucrdtw Goto Github PK

View Code? Open in Web Editor NEW
120.0 9.0 54.0 3.87 MB

Python extension for UCR Suite highly optimized subsequence search using Dynamic Time Warping (DTW)

Makefile 0.61% Python 5.16% C 94.23%

ucrdtw's Introduction

ucrdtw

Python extension for UCR Suite highly optimized subsequence search using Dynamic Time Warping (DTW)

Based on the paper Searching and Mining Trillions of Time Series Subsequences under Dynamic Time Warping

More info on the UCR Suite web page http://www.cs.ucr.edu/~eamonn/UCRsuite.html

Requirements

Python 2.7+, numpy 1.8+

Installation

python setup.py build && python setup.py install

Usage

import _ucrdtw
import numpy as np
import matplotlib.pyplot as plt

data = np.cumsum(np.random.uniform(-0.5, 0.5, 1000000))
query = np.cumsum(np.random.uniform(-0.5, 0.5, 100))
loc, dist = _ucrdtw.ucrdtw(data, query, 0.05, True)
query = np.concatenate((np.linspace(0.0, 0.0, loc), query)) + (data[loc] - query[0])

plt.figure()
plt.plot(data)
plt.plot(query)
plt.show()

ucrdtw's People

Contributors

elyase avatar grzegorzgoldapl avatar klon avatar ltobalina avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar

ucrdtw's Issues

Compile ucrdtw for Windows?

Has anyone built this library on Windows 7, 64bit O/S?
The output from python setup.py build follows:

C:\Users\p\Downloads\ucrdtw-master>python setup.py build
running build
running build_ext
No module named msvccompiler in numpy.distutils; trying from distutils
building '_ucrdtw' extension
C:\Users\p\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Python27\lib\site-packages\numpy\core\include -IC:\Python27\include -IC:\Python27\PC /Tcsrc/_ucrdtw.c /Fobuild\temp.
win-amd64-2.7\Release\src/_ucrdtw.obj
Found executable C:\Users\p\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe
_ucrdtw.c
c:\python27\lib\site-packages\numpy\core\include\numpy\npy_1_7_deprecated_api.h(12) : Warning Msg: Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
src/_ucrdtw.c(73) : error C2275: 'PyObject' : illegal use of this type as an expression
c:\python27\include\object.h(108) : see declaration of 'PyObject'
src/_ucrdtw.c(73) : error C2065: 'data_array' : undeclared identifier
src/_ucrdtw.c(74) : error C2065: 'data_array' : undeclared identifier
src/_ucrdtw.c(74) : warning C4047: '==' : 'int' differs in levels of indirection from 'void *'
src/_ucrdtw.c(75) : error C2065: 'data_array' : undeclared identifier
src/_ucrdtw.c(75) : warning C4047: '==' : 'int' differs in levels of indirection from 'void *'
src/_ucrdtw.c(75) : error C2065: 'data_array' : undeclared identifier
src/_ucrdtw.c(75) : error C2065: 'data_array' : undeclared identifier
src/_ucrdtw.c(75) : error C2065: 'data_array' : undeclared identifier
src/_ucrdtw.c(81) : error C2065: 'data_array' : undeclared identifier
src/_ucrdtw.c(81) : warning C4047: '==' : 'int' differs in levels of indirection from 'void *'
src/_ucrdtw.c(81) : error C2065: 'data_array' : undeclared identifier
src/_ucrdtw.c(81) : error C2065: 'data_array' : undeclared identifier
src/_ucrdtw.c(81) : error C2065: 'data_array' : undeclared identifier
src/_ucrdtw.c(85) : error C2275: 'PyObject' : illegal use of this type as an expression
c:\python27\include\object.h(108) : see declaration of 'PyObject'
src/_ucrdtw.c(85) : error C2065: 'query_array' : undeclared identifier
src/_ucrdtw.c(86) : error C2065: 'query_array' : undeclared identifier
src/_ucrdtw.c(86) : warning C4047: '==' : 'int' differs in levels of indirection from 'void *'
src/_ucrdtw.c(87) : error C2065: 'data_array' : undeclared identifier
src/_ucrdtw.c(87) : warning C4047: '==' : 'int' differs in levels of indirection from 'void *'
src/_ucrdtw.c(87) : error C2065: 'data_array' : undeclared identifier
src/_ucrdtw.c(87) : error C2065: 'data_array' : undeclared identifier
src/_ucrdtw.c(87) : error C2065: 'data_array' : undeclared identifier
src/_ucrdtw.c(88) : error C2065: 'query_array' : undeclared identifier
src/_ucrdtw.c(88) : warning C4047: '==' : 'int' differs in levels of indirection from 'void *'
src/_ucrdtw.c(88) : error C2065: 'query_array' : undeclared identifier
src/_ucrdtw.c(88) : error C2065: 'query_array' : undeclared identifier
src/_ucrdtw.c(88) : error C2065: 'query_array' : undeclared identifier
src/_ucrdtw.c(94) : error C2143: syntax error : missing ';' before 'type'
src/_ucrdtw.c(95) : error C2143: syntax error : missing ';' before 'type'
src/_ucrdtw.c(97) : error C2143: syntax error : missing ';' before 'type'
src/_ucrdtw.c(98) : error C2143: syntax error : missing ';' before 'type'
src/_ucrdtw.c(100) : error C2143: syntax error : missing ';' before 'type'
src/_ucrdtw.c(103) : error C2143: syntax error : missing ';' before 'type'
src/_ucrdtw.c(104) : error C2143: syntax error : missing ';' before 'type'
src/_ucrdtw.c(105) : error C2143: syntax error : missing ';' before 'type'
src/_ucrdtw.c(108) : error C2065: 'data_array' : undeclared identifier
src/_ucrdtw.c(108) : warning C4047: '==' : 'int' differs in levels of indirection from 'void *'
src/_ucrdtw.c(108) : error C2065: 'data_array' : undeclared identifier
src/_ucrdtw.c(108) : error C2065: 'data_array' : undeclared identifier
src/_ucrdtw.c(108) : error C2065: 'data_array' : undeclared identifier
src/_ucrdtw.c(109) : error C2065: 'query_array' : undeclared identifier
src/_ucrdtw.c(109) : warning C4047: '==' : 'int' differs in levels of indirection from 'void *'
src/_ucrdtw.c(109) : error C2065: 'query_array' : undeclared identifier
src/_ucrdtw.c(109) : error C2065: 'query_array' : undeclared identifier
src/_ucrdtw.c(109) : error C2065: 'query_array' : undeclared identifier
src/_ucrdtw.c(111) : error C2065: 'status' : undeclared identifier
src/_ucrdtw.c(117) : error C2275: 'PyObject' : illegal use of this type as an expression
c:\python27\include\object.h(108) : see declaration of 'PyObject'
src/_ucrdtw.c(117) : error C2065: 'ret' : undeclared identifier
src/_ucrdtw.c(117) : error C2065: 'location' : undeclared identifier
src/_ucrdtw.c(117) : error C2065: 'distance' : undeclared identifier
src/_ucrdtw.c(118) : error C2065: 'ret' : undeclared identifier
src/_ucrdtw.c(118) : warning C4047: 'return' : 'PyObject *' differs in levels of indirection from 'int'
error: Command "C:\Users\p\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Python27\lib\site-packages\numpy\core\include -IC:\Python27\include -IC:\Python27\PC /Tcsrc/_ucrdtw.
c /Fobuild\temp.win-amd64-2.7\Release\src/_ucrdtw.obj" failed with exit status 2

Error while installing on Py 2.7

Hey
I could succesfully use this great package on python 3.5 but unfortunately I had to change to 2.7.

After several hours of trying I cant fix this emerging error:
src/_ucrdtw.c(73) : error C2275: 'PyObject' : illegal use of this type as an
expression
c:\users\marty.kuentzel\appdata\local\continuum\anaconda3\envs\py27
include\object.h(108) : see declaration of 'PyObject'
src/_ucrdtw.c(73) : error C2065: 'data_array' : undeclared identifier
src/_ucrdtw.c(74) : error C2065: 'data_array' : undeclared identifier
src/_ucrdtw.c(74) : warning C4047: '==' : 'int' differs in levels of indirec
tion from 'void *'
src/_ucrdtw.c(75) : error C2065: 'data_array' : undeclared identifier
src/_ucrdtw.c(75) : warning C4047: '==' : 'int' differs in levels of indirec
tion from 'void *'
src/_ucrdtw.c(75) : error C2065: 'data_array' : undeclared identifier
src/_ucrdtw.c(75) : error C2065: 'data_array' : undeclared identifier
src/_ucrdtw.c(75) : error C2065: 'data_array' : undeclared identifier
src/_ucrdtw.c(81) : error C2065: 'data_array' : undeclared identifier
src/_ucrdtw.c(81) : warning C4047: '==' : 'int' differs in levels of indirec
tion from 'void *'
src/_ucrdtw.c(81) : error C2065: 'data_array' : undeclared identifier
src/_ucrdtw.c(81) : error C2065: 'data_array' : undeclared identifier
src/_ucrdtw.c(81) : error C2065: 'data_array' : undeclared identifier
src/_ucrdtw.c(85) : error C2275: 'PyObject' : illegal use of this type as an
expression
c:\users\marty.kuentzel\appdata\local\continuum\anaconda3\envs\py27
include\object.h(108) : see declaration of 'PyObject'
src/_ucrdtw.c(85) : error C2065: 'query_array' : undeclared identifier
src/_ucrdtw.c(86) : error C2065: 'query_array' : undeclared identifier
src/_ucrdtw.c(86) : warning C4047: '==' : 'int' differs in levels of indirec
tion from 'void *'
src/_ucrdtw.c(87) : error C2065: 'data_array' : undeclared identifier
src/_ucrdtw.c(87) : warning C4047: '==' : 'int' differs in levels of indirec
tion from 'void *'
src/_ucrdtw.c(87) : error C2065: 'data_array' : undeclared identifier
src/_ucrdtw.c(87) : error C2065: 'data_array' : undeclared identifier
src/_ucrdtw.c(87) : error C2065: 'data_array' : undeclared identifier
src/_ucrdtw.c(88) : error C2065: 'query_array' : undeclared identifier
src/_ucrdtw.c(88) : warning C4047: '==' : 'int' differs in levels of indirec
tion from 'void *'
src/_ucrdtw.c(88) : error C2065: 'query_array' : undeclared identifier
src/_ucrdtw.c(88) : error C2065: 'query_array' : undeclared identifier
src/_ucrdtw.c(88) : error C2065: 'query_array' : undeclared identifier
src/_ucrdtw.c(94) : error C2143: syntax error : missing ';' before 'type'
src/_ucrdtw.c(95) : error C2143: syntax error : missing ';' before 'type'
src/_ucrdtw.c(97) : error C2143: syntax error : missing ';' before 'type'
src/_ucrdtw.c(98) : error C2143: syntax error : missing ';' before 'type'
src/_ucrdtw.c(100) : error C2143: syntax error : missing ';' before 'type'
src/_ucrdtw.c(103) : error C2143: syntax error : missing ';' before 'type'
src/_ucrdtw.c(104) : error C2143: syntax error : missing ';' before 'type'
src/_ucrdtw.c(105) : error C2143: syntax error : missing ';' before 'type'
src/_ucrdtw.c(108) : error C2065: 'data_array' : undeclared identifier
src/_ucrdtw.c(108) : warning C4047: '==' : 'int' differs in levels of indire
ction from 'void *'
src/_ucrdtw.c(108) : error C2065: 'data_array' : undeclared identifier
src/_ucrdtw.c(108) : error C2065: 'data_array' : undeclared identifier
src/_ucrdtw.c(108) : error C2065: 'data_array' : undeclared identifier
src/_ucrdtw.c(109) : error C2065: 'query_array' : undeclared identifier
src/_ucrdtw.c(109) : warning C4047: '==' : 'int' differs in levels of indire
ction from 'void *'
src/_ucrdtw.c(109) : error C2065: 'query_array' : undeclared identifier
src/_ucrdtw.c(109) : error C2065: 'query_array' : undeclared identifier
src/_ucrdtw.c(109) : error C2065: 'query_array' : undeclared identifier
src/_ucrdtw.c(111) : error C2065: 'status' : undeclared identifier
src/_ucrdtw.c(117) : error C2275: 'PyObject' : illegal use of this type as a
n expression
c:\users\marty.kuentzel\appdata\local\continuum\anaconda3\envs\py27
include\object.h(108) : see declaration of 'PyObject'
src/_ucrdtw.c(117) : error C2065: 'ret' : undeclared identifier
src/_ucrdtw.c(117) : error C2065: 'location' : undeclared identifier
src/_ucrdtw.c(117) : error C2065: 'distance' : undeclared identifier
src/_ucrdtw.c(118) : error C2065: 'ret' : undeclared identifier
src/_ucrdtw.c(118) : warning C4047: 'return' : 'PyObject *' differs in level
s of indirection from 'int'
error: Command "C:\Users\Marty.kuentzel\AppData\Local\Programs\Common\Micros
oft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /D
NDEBUG -IC:\Users\Marty.kuentzel\AppData\Local\Continuum\Anaconda3\envs\py27\lib
\site-packages\numpy\core\include -IC:\Users\Marty.kuentzel\AppData\Local\Contin
uum\Anaconda3\envs\py27\include -IC:\Users\Marty.kuentzel\AppData\Local\Continuu
m\Anaconda3\envs\py27\PC /Tcsrc/_ucrdtw.c /Fobuild\temp.win-amd64-2.7\Release\sr
c/_ucrdtw.obj" failed with exit status 2

----------------------------------------

Command "C:\Users\Marty.kuentzel\AppData\Local\Continuum\Anaconda3\envs\py27\pyt
hon.exe -u -c "import setuptools, tokenize;file='c:\users\marty1.kue\app
data\local\temp\pip-6owkce-build\setup.py';f=getattr(tokenize, 'open', open)
(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, fi
le
, 'exec'))" install --record c:\users\marty
1.kue\appdata\local\temp\pip-nrb
rmb-record\install-record.txt --single-version-externally-managed --compile" fai
led with error code 1 in c:\users\marty~1.kue\appdata\local\temp\pip-6owkce-buil
d\

I am kind of desperate since this package plays a huge part in my Project, but I am unable to fix this C++ Code by myself. Can anyone help me with this issue ?

I am using Windows, Anaconda and I installed the Microsoft Visual C++ Compiler for Python 2.7 .

Best regards
Marty

Installing on Mac OS

I had problems installing the package on Mac OS,

what helped was

export CFLAGS="-I /usr/local/lib/python2.7/site-packages/numpy/core/include $CFLAGS"

Cannot import _ucrdtw

Thanks for the great code!
I built the package by running 'make' at the top level and it seems to of worked.
However, I now try

import _ucrdtw
and get the error
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named _ucrdtw

Any ideas?

Difference between ucrdtw and ucrdtwf

In the comments I see that ucrdtwf is for streaming data but do not see any examples for it.
Could you please let me know if this function is working and how it is different from ucrdtw.

Thanks!

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.