Skip to content

Persistent Generators Household Analysis

Pipeline description

This example shows the detection of a circular pattern in high-dimensional data. The data contains seven mesurements of electric power consumption for a single household over two years, for a daily sampling. This can be interpreted as 700 points (on per day) in R^7.

The distance matrix between these points is computed using TableDistanceMatrix. Using the distance matrix, a clustering of the input data is performed using ParaView's K-means algorithm (with k=8). The points are then embedded in 3D using MDS, with DimensionReduction.

At this point, the 2-dimensional Rips complex is computed with RipsComplex from the high-dimensional point cloud, and shown in 3D via MDS projection.

Finally an infinitely persistent 1-cycle is extracted from the Rips complex with PersistentGenerators, on the diameter function. This cycle captures a circular pattern present in the data, implying that in practice, continuous displacements from one cluster to another are likely to imply transformations through other clusters present along the cycle.

The python script saves the resulting point cloud, Rips complex and output cycle as vtk files.

ParaView

To reproduce the above screenshot, go to your ttk-data directory and enter the following command:

paraview states/persistentGenerators_householdAnalysis.pvsm

Python code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env python

from paraview.simple import *

# create a new 'CSV Reader'
household_part1_ID_dailycsv = CSVReader(FileName=["household_part1_ID_daily.csv"])
household_part1_ID_dailycsv.HaveHeaders = 0

# create a new 'TTK DimensionReduction'
tTKDimensionReduction1 = TTKDimensionReduction(
    Input=household_part1_ID_dailycsv, ModulePath="default"
)
tTKDimensionReduction1.InputColumns = [
    "Field 2",
    "Field 3",
    "Field 4",
    "Field 5",
    "Field 6",
    "Field 7",
    "Field 8",
]
tTKDimensionReduction1.Method = "Principal Component Analysis"
tTKDimensionReduction1.Components = 3

# create a new 'TTK TableDistanceMatrix'
tTKTableDistanceMatrix1 = TTKTableDistanceMatrix(Input=tTKDimensionReduction1)
tTKTableDistanceMatrix1.InputColumns = [
    "Field 2",
    "Field 3",
    "Field 4",
    "Field 5",
    "Field 6",
    "Field 7",
    "Field 8",
]

# create a new 'Table To Points'
tableToPoints1 = TableToPoints(Input=tTKDimensionReduction1)
tableToPoints1.XColumn = "Component_0"
tableToPoints1.YColumn = "Component_1"
tableToPoints1.ZColumn = "Component_2"
tableToPoints1.KeepAllDataArrays = 1

# create a new 'K Means'
kMeans1 = KMeans(Input=tableToPoints1, ModelInput=None)
kMeans1.VariablesofInterest = ["Component_0", "Component_1", "Component_2"]
kMeans1.k = 8

# create a new 'TTK RipsComplex'
tTKRipsComplex1 = TTKRipsComplex(Input=tTKTableDistanceMatrix1)
tTKRipsComplex1.SelectFieldswithaRegexp = 1
tTKRipsComplex1.Regexp = "Dist.*"
tTKRipsComplex1.Diameterepsilon = 18.0

# create a new 'Cell Data to Point Data'
cellDatatoPointData1 = CellDatatoPointData(Input=tTKRipsComplex1)
cellDatatoPointData1.CellDataArraytoprocess = ["Diameter"]

# create a new 'Threshold'
threshold1 = Threshold(Input=cellDatatoPointData1)
threshold1.Scalars = ["POINTS", "Diameter"]
threshold1.LowerThreshold = 9.0
threshold1.UpperThreshold = 17.38239404772305

# create a new 'TTK PersistentGenerators'
tTKPersistentGenerators1 = TTKPersistentGenerators(Input=threshold1)
tTKPersistentGenerators1.ScalarField = ["POINTS", "Diameter"]
tTKPersistentGenerators1.PruneHandlesGenerators = 1

SaveData("PersistentGeneratorsHouseholdAnalysis_cycle.vtp", tTKPersistentGenerators1)
SaveData("PersistentGeneratorsHouseholdAnalysis_points.vtp", OutputPort(kMeans1, 1))
SaveData("PersistentGeneratorsHouseholdAnalysis_ripsComplex.vtu", tTKRipsComplex1)

To run the above Python script, go to your ttk-data directory and enter the following command:

pvpython python/persistentGenerators_householdAnalysis.py

Inputs

Outputs

  • PersistentGeneratorsHouseholdAnalysis_points.vtp: the high-dimensionnal point cloud embedded in 3D.
  • PersistentGeneratorsHouseholdAnalysis_ripsComplex: the 2-dimensional Rips complex of the point cloud.
  • PersistentGeneratorsHouseholdAnalysis_cycle: the infinitely persistent 1-cycle of the Rips complex.

C++/Python API

DimensionReduction

PersistentGenerators

RipsComplex

TableDistanceMatrix