Skip to contents

Combines an online clustering component (DSC_Micro) and an offline reclustering component (DSC_Macro) into a single process.

Usage

DSC_TwoStage(micro, macro)

Arguments

micro

Clustering algorithm used in the online stage (DSC_Micro)

macro

Clustering algorithm used for reclustering in the offline stage (DSC_Macro)

Value

An object of class DSC_TwoStage (subclass of DSC, DSC_Macro) which is a named list with elements:

  • description: a description of the clustering algorithms.

  • micro: The DSD used for creating micro clusters in the online component.

  • macro: The DSD for offline reclustering.

  • state: an environment storing state information needed for reclustering.

with the two clusterers. The names are “

Details

update() runs the online micro-clustering stage and only when macro cluster centers/weights are requested using get_centers() or get_weights(), then the offline stage reclustering is automatically performed.

Available clustering methods can be found in the See Also section below.

Author

Michael Hahsler

Examples

stream <- DSD_Gaussians(k = 3, d = 2)

# Create a clustering process that uses a window for the online stage and
# k-means for the offline stage (reclustering)
win_km <- DSC_TwoStage(
  micro = DSC_Window(horizon = 100),
  macro = DSC_Kmeans(k = 3)
  )
win_km
#> Sliding window + k-Means (weighted) 
#> Class: DSC_TwoStage, DSC_Macro, DSC 
#> Number of micro-clusters: 0 
#> Number of macro-clusters: 0 

update(win_km, stream, 200)
win_km
#> Sliding window + k-Means (weighted) 
#> Class: DSC_TwoStage, DSC_Macro, DSC 
#> Number of micro-clusters: 100 
#> Number of macro-clusters: 3 
win_km$micro
#> Sliding window 
#> Class: DSC_Window, DSC_Micro, DSC_R, DSC 
#> Number of micro-clusters: 100 
win_km$macro
#> k-Means (weighted) 
#> Class: DSC_Kmeans, DSC_Macro, DSC_R, DSC 
#> Number of micro-clusters: 100 
#> Number of macro-clusters: 3 

plot(win_km, stream)

evaluate_static(win_km, stream, assign = "macro")
#> Evaluation results for macro-clusters.
#> Points were assigned to macro-clusters.
#> 
#>             numPoints      numMicroClusters      numMacroClusters 
#>          1.000000e+02          1.000000e+02          3.000000e+00 
#>        noisePredicted                   SSQ            silhouette 
#>          0.000000e+00          3.376204e-01          7.938251e-01 
#>       average.between        average.within          max.diameter 
#>          6.548251e-01          6.886761e-02          2.493522e-01 
#>        min.separation ave.within.cluster.ss                    g2 
#>          9.837076e-02          3.222057e-03          9.963625e-01 
#>          pearsongamma                  dunn                 dunn2 
#>          7.669822e-01          3.945053e-01          3.424728e+00 
#>               entropy              wb.ratio            numClasses 
#>          1.095559e+00          1.051695e-01          3.000000e+00 
#>           noiseActual        noisePrecision        outlierJaccard 
#>          0.000000e+00                   NaN                   NaN 
#>             precision                recall                    F1 
#>          1.000000e+00          1.000000e+00          1.000000e+00 
#>                purity             Euclidean             Manhattan 
#>          1.000000e+00          1.000000e+00          1.000000e+00 
#>                  Rand                 cRand                   NMI 
#>          1.000000e+00          1.000000e+00          1.000000e+00 
#>                    KP                 angle                  diag 
#>          1.000000e+00          1.000000e+00          1.000000e+00 
#>                    FM               Jaccard                    PS 
#>          1.000000e+00          1.000000e+00          1.000000e+00 
#>                    vi 
#>          0.000000e+00 
#> attr(,"type")
#> [1] "macro"
#> attr(,"assign")
#> [1] "macro"