COBRAS

The COBRAS class contains most of the clustering procedure that is shared between specific COBRAS variants: COBRAS_dtw, COBRAS_kmeans and COBRAS_kshape (see below)

The following methods are specific to each variant:

  • create_superinstance: this method simply creates a super-instance of the appropriate type

  • split_superinstance: this method splits a super-instance

class cobras_ts.cobras.COBRAS(data, querier, max_questions, train_indices=None, store_intermediate_results=True)
cluster()

Perform clustering

Returns

if cobras.store_intermediate_results is set to False, this method returns a single Clustering object if cobras.store_intermediate_results is set to True, this method returns a tuple containing the following items:

  • a Clustering object representing the resulting clustering

  • a list of intermediate clustering labellings for each query (each item is a list of clustering labels)

  • a list of timestamps for each query

  • the list of must-link constraints that was queried

  • the list of cannot-link constraints that was queried

abstract create_superinstance(indices, parent=None)

Creates a new super-instance containing the given instances and with the given parent

Parameters
  • indices (List[int]) – the indices of the instances that should be in the new super-instance

  • parent (SuperInstance) – the parent of this super-instance

Returns

the new super-instance

abstract split_superinstance(si, k)

Splits the super-instance si into k new super-instances

Parameters
  • si (SuperInstance) – the super-instance to split

  • k (int) – the desired number of new super-instances

Returns

a list of the new super-instances

Return type

List[SuperInstance]

COBRAS_DTW

Important when using COBRAS_DTW the data argument given to the COBRAS constructor should NOT be the raw data. In the case of COBRAS_DTW, COBRAS expects an affinity matrix as input. This affinity matrix should be generated by the dtaidistance package as in the run_cobras_dtw example (under examples).

class cobras_ts.cobras_dtw.COBRAS_DTW(data, querier, max_questions, train_indices=None, store_intermediate_results=True)
create_superinstance(indices, parent=None)

Creates a super-instance of type SuperInstance_DTW

split_superinstance(si, k)

Splits the given super-instance using spectral clustering

COBRAS_kmeans

class cobras_ts.cobras_kmeans.COBRAS_kmeans(data, querier, max_questions, train_indices=None, store_intermediate_results=True)
create_superinstance(indices, parent=None)

Creates a super-instance of type SuperInstance_kmeans

split_superinstance(si, k)

Splits the given super-instance using k-means

COBRAS_kshape

class cobras_ts.cobras_kshape.COBRAS_kShape(data, querier, max_questions, train_indices=None, store_intermediate_results=True)
create_superinstance(indices, parent=None)

Creates a super-instance of type SuperInstance_kShape

split_superinstance(si, k)

Splits the given super-instance using kshape clustering