Skip to content

Clustering and pipelines

PdmContext.ContextClustering.DBscanContextStream

DBscanContextStream(cluster_similarity_limit=0.7, min_points=2, distancefunc=None)

A simple clustering method for context (inspired from streaming DBSCAN)

Parameters:

cluster_similarity_limit: The similarity upon two clusters are merged

min_points:

distancefunc: The function to use in order to calculate two Contexts' similarity. None value results in the usage of default distance function implemented in the class. In case of user's distance function, this has to take the two contexts as parameter and

return a real number in [0,1] indicating their similarity (1 is maximum similarity)

PdmContext.Pipelines

ContextAndClustering

ContextAndClustering(Clustring_object, context_generator_object)

This class build a pipeline of Cntext generator and Clustering technique running immediately in the results of Context Generator

Parameters:

Clustring_object: The clustering technique to use to cluster the created context from Context generator The class of the clustering technique must implement the method add_sample_to_cluster(context: Context)

context_generator_object: A PdmContext.ContextGeneration import ContextGenerator object

collect_data

collect_data(timestamp, source, name, value=None, type='Univariate', replace=None)

Call the PdmContext.ContextGeneration.ContextGenerator and pass the result to clustering technique

Parameters:

timestamp: The timestamp of the arrived value

source: The source of the arrived value

name: The name (or identifier) of the arrived value

value: The value (float), in case this is None the arrived data is considered as event

type: the type of the data can be one of "isolated","configuration" when no value is passed

replace: replacement policy passed to ContextGenerator.collect_data

return: PdmContext.utils.structure.Context object when the data name match to the target name or None.

ContextAndClusteringAndDatabase

ContextAndClusteringAndDatabase(context_generator_object, Clustring_object, databaseStore_object)

This class build a pipeline of Cntext generator and Clustering technique running immediately in the results of Context Generator, and storing context results to database

Parameters:

context_generator_object: A PdmContext.ContextGeneration import ContextGenerator object

Clustring_object: The clustering technique to use to cluster the created context from Context generator The class of the clustering technique must implement the method add_sample_to_cluster(context: Context) databaseStore_object: Class which implement insert_record(date : pd.datetime,target: str,context : Context, metadata: str)

databaseStore_object: An object of database connection from PdmContext.utils.dbconnector

collect_data

collect_data(timestamp, source, name, value=None, type='Univariate', replace=None)

Call the PdmContext.ContextGeneration.ContextGenerator and pass the result to clustering technique

Parameters:

timestamp: The timestamp of the arrived value

source: The source of the arrived value

name: The name (or identifier) of the arrived value

value: The value (float), in case this is None the arrived data is considered as event

type: the type of the data can be one of "isolated","configuration" when no value is passed

replace: replacement policy passed to ContextGenerator.collect_data

return: PdmContext.utils.structure.Context object when the data name match to the target name or None.

ContextAndDatabase

ContextAndDatabase(context_generator_object, databaseStore_object)

This class build a pipeline of Cntext generator and storing results to database

Parameters:

context_generator_object: A PdmContext.ContextGeneration import ContextGenerator object

databaseStore_object: Class which implement insert_record(date : pd.datetime,target: str,context : Context, metadata: str)

collect_data

collect_data(timestamp, source, name, value=None, type='Univariate', replace=None)

Call the PdmContext.ContextGeneration.ContextGenerator and pass the result to clustering technique

Parameters:

timestamp: The timestamp of the arrived value

source: The source of the arrived value

name: The name (or identifier) of the arrived value

value: The value (float), in case this is None the arrived data is considered as event

type: the type of the data can be one of "isolated","configuration" when no value is passed

replace: replacement policy passed to ContextGenerator.collect_data

return: PdmContext.utils.structure.Context object when the data name match to the target name or None.