Dendrogram¤
The dendrogram module performs hierarchical aggolomerative clustering.
The Dendrogram Class¤
Dendrogram
pydantic-model
¤
Bases: BaseModel
Dendrogram.
Typical usage:
The dtm parameter can be a a DTM instance or a pandas DataFrame with terms
as columns and docs as rows (the output of DTM.to_df(transpose=True)).
It can also be an equivalent numpy array or list of lists. But in most cases,
it will be most convenient to use a DTM instance.
Config:
arbitrary_types_allowed:True
Fields:
-
dtm(Optional[ArrayLike | DTM | DataFrame]) -
labels(Optional[list[str]]) -
metric(Optional[str]) -
method(Optional[str]) -
truncate_mode(Optional[str]) -
color_threshold(Optional[float]) -
get_leaves(Optional[bool]) -
orientation(Optional[str]) -
count_sort(Optional[bool | str]) -
distance_sort(Optional[bool | str]) -
show_leaf_counts(Optional[bool]) -
no_plot(Optional[bool]) -
no_labels(Optional[bool]) -
leaf_rotation(Optional[int]) -
leaf_font_size(Optional[int]) -
leaf_label_func(Optional[Callable]) -
show_contracted(Optional[bool]) -
link_color_func(Optional[Callable]) -
ax(Optional[Axes]) -
above_threshold_color(Optional[str]) -
title(Optional[str]) -
figsize(Optional[tuple]) -
fig(Optional[Figure])
Source code in lexos/cluster/dendrogram.py
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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | |
above_threshold_color: Optional[str] = 'C0'
pydantic-field
¤
The above threshold color for the dendrogram.
ax: Optional[Axes] = None
pydantic-field
¤
The ax for the dendrogram.
color_threshold: Optional[float] = None
pydantic-field
¤
The color threshold for the dendrogram.
count_sort: Optional[bool | str] = None
pydantic-field
¤
The count sort for the dendrogram.
distance_sort: Optional[bool | str] = None
pydantic-field
¤
The distance sort for the dendrogram.
dtm: Optional[ArrayLike | DTM | pd.DataFrame] = None
pydantic-field
¤
The document-term matrix.
figsize: Optional[tuple] = (10, 10)
pydantic-field
¤
The figsize for the dendrogram.
get_leaves: Optional[bool] = True
pydantic-field
¤
The get leaves for the dendrogram.
labels: Optional[list[str]] = None
pydantic-field
¤
The labels for the dendrogram.
leaf_font_size: Optional[int] = None
pydantic-field
¤
The leaf font size for the dendrogram.
leaf_label_func: Optional[Callable] = None
pydantic-field
¤
The leaf label function for the dendrogram.
leaf_rotation: Optional[int] = 90
pydantic-field
¤
The leaf rotation for the dendrogram.
link_color_func: Optional[Callable] = None
pydantic-field
¤
The link color function for the dendrogram.
method: Optional[str] = 'average'
pydantic-field
¤
The method to use for the dendrogram.
metric: Optional[str] = 'euclidean'
pydantic-field
¤
The metric to use for the dendrogram.
no_labels: Optional[bool] = False
pydantic-field
¤
The no labels for the dendrogram.
no_plot: Optional[bool] = False
pydantic-field
¤
The no plot for the dendrogram.
orientation: Optional[str] = 'top'
pydantic-field
¤
The orientation for the dendrogram.
show_contracted: Optional[bool] = False
pydantic-field
¤
The show contracted for the dendrogram.
show_leaf_counts: Optional[bool] = False
pydantic-field
¤
The show leaf counts for the dendrogram.
title: Optional[str] = None
pydantic-field
¤
The title for the dendrogram.
truncate_mode: Optional[str] = None
pydantic-field
¤
The truncate mode for the dendrogram.
__init__(**data) -> None
¤
Initialize the Dendrogram instance.
Source code in lexos/cluster/dendrogram.py
save(path: Path | str)
¤
Save the figure as a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path | str
|
The path to the file to save. |
required |
Source code in lexos/cluster/dendrogram.py
show()
¤
Show the figure if it is hidden.
This is a helper method. You can also reference the figure
using Dendrogram.fig. This will generally display in a
Jupyter notebook.
rendering:
show_root_heading: true
heading_level: 3
__init__(**data) -> None
¤
Initialize the Dendrogram instance.
Source code in lexos/cluster/dendrogram.py
rendering:
show_root_heading: true
heading_level: 3
_get_valid_matrix()
¤
Get a valid matrix based on the data type of the dtm.
Source code in lexos/cluster/dendrogram.py
rendering:
show_root_heading: true
heading_level: 3
save(path: Path | str)
¤
Save the figure as a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path | str
|
The path to the file to save. |
required |
Source code in lexos/cluster/dendrogram.py
rendering:
show_root_heading: true
heading_level: 3
show()
¤
Show the figure if it is hidden.
This is a helper method. You can also reference the figure
using Dendrogram.fig. This will generally display in a
Jupyter notebook.
rendering:
show_root_heading: true
heading_level: 3