temporalmapper.TemporalMapper

class temporalmapper.TemporalMapper(time: ~numpy.ndarray[~typing.Any, ~numpy.dtype[~numpy._typing._array_like._ScalarType_co]] | None = None, data: ~numpy.ndarray[~typing.Any, ~numpy.dtype[~numpy._typing._array_like._ScalarType_co]] | None = None, clusterer: ~sklearn.base.ClusterMixin = None, n_slices: int = 5, n_neighbors: int = 5, overlap: float = 0.5, inclusion_threshold: float = 0.01, slice_method: str = 'time', density_based: bool = True, kernel: ~collections.abc.Callable[[float, float, float, float], float] = <function square>, kernel_params: dict = None, verbose: bool = False)

Wrapper over density-based Mapper for Temporal Topic Modelling

graph

The temporal graph itself.

Type:

networkx.classes.Digraph(Graph)

fit():

Run the density-based mapper algorithm to construct the temporal graph.

get_vertex_data(str node):

Returns the index of elements of data which are in vertex node.

get_dir_subvertices(str node, float threshold = 0.0, bool backwards=False):

Returns the vertices that descend from node with outedge weight at least threshold. If backwards = True, returns the ancestors instead of descendants.

temporal_plot():

Returns a matplotlib axis containing a temporal plot

interactive_temporal_plot():

Returns a Plotly figure containing an interactive temporal plot

__init__(time: ~numpy.ndarray[~typing.Any, ~numpy.dtype[~numpy._typing._array_like._ScalarType_co]] | None = None, data: ~numpy.ndarray[~typing.Any, ~numpy.dtype[~numpy._typing._array_like._ScalarType_co]] | None = None, clusterer: ~sklearn.base.ClusterMixin = None, n_slices: int = 5, n_neighbors: int = 5, overlap: float = 0.5, inclusion_threshold: float = 0.01, slice_method: str = 'time', density_based: bool = True, kernel: ~collections.abc.Callable[[float, float, float, float], float] = <function square>, kernel_params: dict = None, verbose: bool = False)
Parameters:
  • clusterer (sklearn clusterer) – the clusterer to use for the slice-wise clustering, must accept sample_weights

  • n_slices (int) – number of time-points at which to cluster

  • n_neighbors (int (optional, default=5)) – The number of nearest neighbors used in the density computation.

  • overlap (float (optional, default=0.5)) – A float in (0,1) which specifies the g parameter (see README)

  • inclusion_threshold (float (optional, default=0.1)) – A float in [0,1) which specifies the minimum kernel weight for a point to be included in a slice.

  • slice_method (str (optional, default='time')) – 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.

  • density_based (bool (optional, default=True)) – Whether to use density-based Mapper. If False, skips the density computation and uses a standard pullback Mapper cover.

  • kernel (function (optional, default=temporalmapper.kernels.square)) – A function with signature f(t0, t, density, binwidth, epsilon=0.01, params=None). Options are included in temporalmapper.kernels.

  • kernel_params (tuple or None,) – Passed to kernel as params kwarg.

  • verbose (bool) – Does what you expect.

Methods

__init__(time, ...)

assign_topics()

Assign each vertex to a 'topic' based on its change over time.

build()

Construct the density-based Mapper graph

edge_thresholded_subgraph(threshold)

Return a subgraph

fit(X[, y, time_index, drop_time])

Fit the TemporalMapper :param X: Should have shape (n_samples, n_features) :type X: ndarray :param time_index: Which feature of X to use as time.

get_dir_subvertices(v[, threshold, backwards])

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

get_subgraph_data(vertices)

get_vertex_data(node)

initial_y_position()

Compute initial positions for the y-axis of temporal plot

interactive_temporal_plot([cluster_labels, ...])

Generate an interactive (plotly) temporal plot of the Mapper graph on a specified matplotlib axis using sensible defaults.

populate_edge_attrs()

Add src_weight and dst_weight properties to every edge.

populate_node_attrs([labels])

Add node attributes (dictionaries) to the vertices of the graph.

set_fit_request(*[, drop_time, time_index])

Configure whether metadata should be requested to be passed to the fit method.

set_params(**params)

Set the parameters of this estimator.

temporal_plot([ax, title, cluster_labels, ...])

vertex_subgraph(v[, threshold])

Attributes

SERIAL_VERSION

clusters

density

gomic_

graph

midpoints

slices

weights