Semi-supervised time series clustering with COBRAS
Project description
Library for semi-supervised time series clustering using pairwise constraints.
Installation
This package is available on PyPi:
$ pip install cobras_ts
Usage
Examples can also be found in the examples subdirectory.
Running COBRAS_kShape:
import os import numpy as np from cobras_ts import cobras_kshape ucr_path = '/path/to/UCR/archive' dataset = 'ECG200' budget = 100 data = np.loadtxt(os.path.join(ucr_path,dataset,dataset + '_TEST'), delimiter=',') series = data[:,1:] labels = data[:,0] clusterer = cobras_kshape.COBRAS_kShape(series, labels, budget) clusterings, runtimes, ml, cl = clusterer.cluster()
Running COBRAS_DTW:
This uses the dtaidistance package to compute the DTW distance matrix. Note that constructing this matrix is typically the most time consuming step, and significant speedups can be achieved by using the C implementation in the dtaidistance package.
import os import numpy as np from cobras_ts import cobras_dtw from dtaidistance import dtw ucr_path = '/path/to/UCR/archive' dataset = 'ECG200' budget = 100 alpha = 0.5 window = 10 data = np.loadtxt(os.path.join(ucr_path,dataset,dataset + '_TEST'), delimiter=',') series = data[:,1:] labels = data[:,0] dists = dtw.distance_matrix(series, window=int(0.01 * window * series.shape[1])) dists[dists == np.inf] = 0 dists = dists + dists.T - np.diag(np.diag(dists)) affinities = np.exp(-dists * alpha) clusterer = cobras_dtw.COBRAS_DTW(affinities, labels, budget) clusterings, runtimes, ml, cl = clusterer.cluster()
Dependencies
This package uses Python3, numpy, scikit-learn, kshape and dtaidistance.
Contact
Toon Van Craenendonck at toon.vancraenendonck@cs.kuleuven.be
License
COBRAS code for semi-supervised time series clustering.
Copyright 2018 KU Leuven, DTAI Research Group
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for cobras_ts-0.0.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b8bb808316e35ce27ba087e0ede1af6e55a473f5062a2597a9fea0fce5282dc |
|
MD5 | d4ba579906cc59c354068a392ec4df30 |
|
BLAKE2b-256 | ad0e7202edfd32a1b64c8995882e9e9cb5d6a7371d428e63a3808315f628c354 |