subrela.plot.get_trace_data function¶
-
subrela.plot.get_trace_data(node_data, cut_data, wrs, tol=0.0)[source]¶ Calculate data for drawing trace lines.
- Parameters
node_data (pandas.DataFrame) – Data of nodes returned by
subrela.plot.get_dendrogram_datafunction.cut_data (pandas.DataFrame) – Data of cut lines returned by
subrela.plot.get_dendrogram_datafunction.wrs (pandas.DataFrame) – Weak relevance scores of subgroups, which is a concatenation of returns of
subrela.analysis.get_weak_relevance_scoresfunction.tol (float, optional) – Tolerance of difference in the relevance score.
- Returns
trace_data (pandas.DataFrame) – Data of trace lines.
Notes
An index and columns of
trace_dataare as follows:trace_data.indexNo meaning.
trace_data['breadths']list[float]Positions of start, corner, and end points along the breadth direction.
trace_data['heights']list[float]Positions of start, corner, and end points along the heights direction.
trace_data['group']intCluster index of a group to which a trace line belongs
Examples
>>> import numpy >>> from subrela.records import from_arrays >>> from subrela.clustering import get_clusters >>> from subrela.analysis import get_weak_relevance_scores >>> subset_scores = from_arrays([[False, False, False, True, True], ... [True, False, False, True, True], ... [False, True, False, True, True], ... [True, True, False, True, True], ... [False, False, True, True, True], ... [True, False, True, True, True], ... [False, True, True, True, True], ... [True, True, True, True, True]], ... [0.7, 0.7, 0.8, 0.8, 0.9, 0.9, 1., 1.]) >>> X = numpy.array([[0, -5, -5, 6, 6], [0, -1, 1, -2, 2]]) >>> Z = get_clusters(X) >>> _, node_data, _, cut_data = get_dendrogram_data(Z, groups=[5]) >>> wrs = get_weak_relevance_scores(subset_scores, Z, 5)
>>> get_trace_data(node_data, cut_data, wrs) breadths heights group 0 [3.5, 3.5] [3.5495097567963922, 2.0] 5 1 [3.5, 3.0, 3.0] [2.0, 2.0, 0.0] 5 2 [3.5, 4.0, 4.0] [2.0, 2.0, 0.0] 5
>>> get_trace_data(node_data, cut_data, wrs, tol=0.1) breadths heights group 0 [3.5, 3.5] [3.5495097567963922, 2.0] 5 1 [3.5, 4.0, 4.0] [2.0, 2.0, 0.0] 5