In [5]:
import os
files = [f for f in os.listdir('.') if os.path.isfile(f)]
for f in files:
print(f)
In [24]:
from numpy import genfromtxt
dd = genfromtxt("/home/psenin/git/saxpy/data/insect.txt", delimiter=',')
In [15]:
len(dd)
Out[15]:
In [16]:
type(dd[1])
Out[16]:
In [13]:
import matplotlib.pyplot as plt
plt.plot(dd)
Out[13]:
In [14]:
plt.show()
In [25]:
import numpy as np
def znorm(series, znorm_threshold=0.01):
"""Fallback Python implementation."""
sd = np.std(series)
if (sd < znorm_threshold):
return series
mean = np.mean(series)
res = (series - mean)/sd
return res
In [26]:
dd_norm = znorm(dd, 0.001)
In [29]:
type(dd_norm)
Out[29]:
In [27]:
plt.plot(dd_norm)
plt.show()
In [28]:
%timeit -r 10 a = znorm(dd, 0.001)
In [ ]:
setup = '''
from numpy import genfromtxt
dd = genfromtxt("/home/psenin/git/saxpy/data/insect.txt", delimiter=',')
from saxpy import znorm
'''
import timeit
timeit.Timer('a=znorm.znorm(dd, 0.001)', setup=setup).repeat(7, 1000)
In [ ]:
setup = '''
from numpy import genfromtxt
dd = genfromtxt("/home/psenin/git/saxpy/data/insect.txt", delimiter=',')
from saxpy import znorm
'''
import timeit
timeit.Timer('a=znorm.znorm(dd, 0.001)', setup=setup).repeat(7, 1000)
In [ ]:
In [ ]:
from numpy import std
from saxpy import znorm as zn
In [ ]:
"""Test the znorm implementation."""
ts = [-1., -2., -1., 0., 2., 1., 1., 0.]
z_thrsh = 0.001
x_scaled = [x / 100.0 for x in ts]
In [ ]:
zn.znorm(x_scaled, z_thrsh)
In [1]:
import inspect
from saxpy import znorm as zn
lines = inspect.getsourcelines(zn.znorm)
print("".join(lines[0]))
In [ ]:
import numpy as np
def znorm(series, znorm_threshold=0.01):
"""Fallback Python implementation."""
sd = np.std(series)
if (sd < znorm_threshold):
return series
mean = np.mean(series)
res = np.zeros(len(series))
for i in range(0, len(series)):
res[i] = (series[i] - mean) / sd
return res.ravel()
In [ ]:
mean = np.mean(zz)
mean
In [ ]:
std = np.std(zz, axis=0, ddof=1)
std
In [ ]:
In [ ]:
In [ ]: