-
Notifications
You must be signed in to change notification settings - Fork 0
API Reference
Kaleb edited this page Jul 31, 2024
·
7 revisions
- temporal_mapper.TemporalMapper(time, data, clusterer)
-
The TemporalMapper object stores all the data and preprocessing associated to the temporal mapper graph, with semantic data
data
and timestampstime
. Clustering is performed using an sklearn clustererclusterer
, which can optionally support weighted points.Attributes:
- G: networkx.classes.Digraph(Graph)
- The temporal graph itself.
- density: ndarray
- The f-density rho for each data point.
Parameters:
- time: ndarray
- time array (1 dim)
- data: ndarray
- data array (n dim)
- clusterer: sklearn clusterer
- the clusterer to use for the slice-wise clustering, optionally accepts sample_weights
- N_checkpoints: int
- number of time-points at which to cluster
- checkpoints: arraylike
- array of time-points at which to cluster
- overlap: float
- A float in (0,1) which specifies the
g
parameter (see README) - neighbours: float
- The number of nearest neighbours to use in the density computation.
- show_outliers: bool
- If true, include unclustered points in the graph
- slice_method: str
- One of 'time' or 'data'. If time, generates N_checkpoints evenly spaced in time. If data, generates N_checkpoints such that there are equal amounts of data between the points.
- rate_sensitivity: float
- A positive float, or -1. The rate parameter is raised to this parameter, so higher numbers
means that the algorithm is more sensitive to changes in rate. If
rate_sensivity == -1
, then the rate parameter is taken log2. - kernel: function
- A function with signature
f(t0, t, density, binwidth, epsilon=0.01, params=None)
. Two options are included in weighted_clustering.py,weighted_clustering.square
andweighted_clustering.gaussian
. - kernel_parameters: tuple or None,
- Passed to kernel as params kwarg.
- verbose: bool
- Does what you expect.
Methods:
- build():
- Run the fuzzy mapper algorithm to construct the temporal graph.
- get_vertex_data(str node):
- Returns the index of elements of
data
which are in vertexnode
.
- temporal_mapper.utilities.time_semantic_plot(TemporalGraph, semantic_axis)
-
Create a time-semantic plot of the graph
TemporalGraph.G
.Parameters:
- TemporalMapper: temporal_mapper.TemporalMapper
- The temporal graph object to plot.
- semantic_axis: ndarray
- Array of shape
(n_samples,)
with the 1D semantic data to use in the plot. - ax: matplotlib.axes (optional, default=None)
- Matplotlib axis to draw on
- vertices: list (optional, default=None)
- List of nodes in TG.G to include in the plot.
- label_edges: bool (optional, default=False)
- If true, include text labels of the edge weight on top of edges.
- edge_scaling: float (optional, default = 1)
- Scales the thickness of edges, larger is thicker.
- bundle: bool (optional, default=True)
- If true, bundle the edges of the graph using datashader's hammer_bundle function.
- print_params: bool (optional, default=False)
- If true, print extra information about the parameters of TemporalMapper on the plot.
Returns: matplotlib.axes
- temporal_mapper.utilities.centroid_datamap(TemporalGraph)
-
Plot the temporal graph in 2d with vertices at their cluster centroids.
Parameters:
- TemporalMapper: temporal_mapper.TemporalMapper
- The temporal graph object to plot.
- ax: matplotlib.axes (optional, default=None)
- Matplotlib axis to draw on
- node_colouring:
'desaturate'
or'override'
(optional, default='desaturate') - Determines how to incorporate temporal information in the color. The desaturate option will take the semantic colouring from datamapplot and desaturate points that are further back in time. The override option will throw away the semantic colouring and colour points only based on their time value.
- vertices: list (optional, default=None)
- List of nodes in TG.G to include in the plot.
- label_edges: bool (optional, default=False)
- If true, include text labels of the edge weight on top of edges.
- edge_scaling: float (optional, default = 1)
- Scales the thickness of edges, larger is thicker.
- bundle: bool (optional, default=True)
- If true, bundle the edges of the graph using datashader's hammer_bundle function.
- print_params: bool (optional, default=False)
- If true, print extra information about the parameters of TemporalMapper on the plot.
Returns: matplotlib.axes