from data.load import load import matplotlib.pyplot as plt import numpy as np data = load().ekg()[0:1000] windowSize = 100 leftOffset = 50 rightOffset = 50 start = leftOffset end = data.shape[0] - rightOffset windows = np.zeros(shape=(end - start, windowSize)) #stft = np.zeros(shape=(end - start, windowSize)) for n in range(start, end): windows[n-start, :] = data[n - leftOffset:n + rightOffset] #stft[n - start, :] = np.fft.fft(np.hamming(windowSize) * windowVals) print('') corrThreshold = 0.9
from data.load import load data = load().ekg() from external.luminol.src import luminol
# clusterer.fit(stfts) # # # plt.plot(data) # # labelsX = np.array(range(start,end)) # plt.plot(labelsX, 100*(clusterer.labels_-5)) # plt.show() if __name__ == '__main__': from data.load import load import matplotlib.pyplot as plt data = load().TICC()[:, 0] # just do univariate for now data = load().ekg() # already univariate model = STFT_Cluster(n_clusters=10, windowSize=100) model.fit_predict(data[0:5000]) plt.figure() plt.plot(data[0:5000]) plt.plot(100*(model.labels_-5)) # plt.figure() # results = model.predict(data[5000:6000]) # plt.plot(data[5000:6000]) # # plt.plot((results-25))
from distance.traj_dist.frechet import frechet from distance.traj_dist.sspd import e_sspd from distance.traj_dist.hausdorff import e_hausdorff from distance.eros import eros plotSamples = False runLCSS = False runDiscretFretchet = False runFretchet = False runSSPD = False runHausdorff = False runEros = True allSamples = load().auslan() wantedLabels = ['how-1', 'how-2', 'how-3', 'answer-3'] samples = [] sampleLabels = [] for label in list(allSamples.keys()): data = allSamples[label] #x1, y1, z1 = data['x1'].values, data['y1'].values, data['z1'].values sample = data[['x1','y1','z1']].values sampleLabels.append(label)
if segmentType == 'interpolate': segmenting = fit.interpolate elif segmentType == 'regression': segmenting = fit.regression else: raise ValueError('Unknown segmenting type') return window(data, segmenting, error, maxError) if __name__ == '__main__': from data.load import load data = load().s_and_p500() data = load().TICC() segments = PLA(data[:,0], windowScale=1000, windowingType='bottom up', segmentType='interpolate') print(segments) import matplotlib.pyplot as plt plt.plot(data[:,0]) for seg in segments: plt.plot( [seg[0], seg[2]], [seg[1], seg[3]], c='r') plt.show()