Documentation

Sample

class outlierdenstream.Sample(value, timestamp: int)[source]

Each record of the stream has to be declared as a Sample class.

Parameters:
  • value – the values of the current sample.
  • timestamp – the timestamp of current sample.
getValue()[source]
Returns:value
setMicroClusterNumber(microClusterNumber: int)[source]

Assign to each sample the microClusterNumber in which was merged.

Set:microClusterNumber
setTimestamp(timestamp: int)[source]
Set:timestamp

Micro-Cluster

class outlierdenstream.MicroCluster(currenttimestamp, lamb, clusterNumber)[source]

Micro-Cluster class

Parameters:
  • currenttimestamp – the timestamp in which the cluster is created.
  • lamb – the lamb parameter used as decay factor.
  • clusterNumber – the number of the micro-cluster.
getCenter()[source]
Returns:the center of the micro-cluster.
getRadius()[source]
Returns:the radius of the micro-cluster.
insertSample(sample, timestamp=0)[source]

Adds a sample to a micro-cluster. Updates the variables of the micro-cluster with updateRealTimeWeight() and updateRealTimeLSandSS()

Parameters:
  • sample – the sample object
  • timestamp – deprecated, not needed anymore. Will be removed in the next versions.
noNewSamples()[source]

Updates the Weighted Linear Sum (WLS), the Weighted Squared Sum (WSS) and the weight of the micro-cluster when no new samples are merged.

updateRealTimeLSandSS(sample)[source]

Updates the Weighted Linear Sum (WLS), the Weighted Squared Sum (WSS), the center and the radius of the micro-cluster when a new sample is merged.

Parameters:sample – the sample to merge into the micro-cluster.
updateRealTimeWeight()[source]

Updates the Weight of the micro-cluster by the fading factor and increases it by 1.

Cluster

class outlierdenstream.Cluster[source]

Cluster class. Contains the list of the micro-cluster and the number of micro-clusters.

insert(mc)[source]

Inserts a micro-cluster into the cluster

Parameters:mc – the micro-cluster to be added to the list of the micro-clusters that make up the cluster.

Increases the counter of micro-clusters into the cluster by 1.

OutlierDenStream

class outlierdenstream.OutlierDenStream(lamb, epsilon=1, minPts=1, beta=1, mu=1, numberInitialSamples=None, startingBuffer=None, tp=60, radiusFactor=1)[source]

OutlierDenStream class.

Parameters:
  • lamb – the lambda parameter - fading factor
  • epsilon – the epsilon parameter
  • beta – the beta parameter
  • mu – the mu parameter
  • numberInitialSamples – samples to use as initial buffer
  • startgingBuffer – initial buffer on which apply DBScan or use it as unique class.
  • tp – frequency at which to apply the pruning strategy and remove old micro-clusters.
initDBScan()[source]

Init with DBSCAN

initWithoutDBScan()[source]

Produces a micro-cluster merging all the samples passed into the initial buffer

If epsilon is auto computes epsilon as the maxium radius obtained from these initial samples.

resetLearningImpl()[source]

Initializes two empty Cluster as a p-micro-cluter list and o-micro-cluster list.

If mu is auto computes the value

runDBSCanInitialization()[source]

Initializes the variables of the main algorithm with the methods resetLearningImpl() and initDBScan()

runInitialization()[source]

Initializes the variables of the main algorithm with the methods resetLearningImpl() and initWithoutDBScan()

runOnNewSample(sample)[source]

Performs the basic DenStream procedure for merging new samples.

  • Try to merge the sample to the closest core-micro-cluster (or)
  • Try to merge the sample to the closest outlier-micro-cluster (or)
  • Generate new outlier-micro-cluster by the sample
Parameters:sample – the new available sample in the stream
Returns:False if the sample is merged to an existing core-micro-cluster otherwise True meaning “anomalous” sample.