magnet.mesh.AggMeshDataset#

class magnet.mesh.AggMeshDataset(mesh_list: list[AggMesh], name: str | None = None)#

Bases: MeshDataset

Dataset of agglomerable meshes.

Parameters:
  • list_of_meshes (list of AggMesh) – Meshes that form the dataset.

  • name (str, optional) – Name of the dataset (default is None).

Variables:
  • meshes (list of AggMesh) – The meshes that form the dataset.

  • name (str, optional) – Name of the dataset.

Notes

The implementation assumes that the dataset is always homogeneous (i.e. all meshes are either 2D or 3D, they are all homogeneous or heterogeneous), but there are no checks on this.

Constructor

__init__(mesh_list: list[AggMesh], name: str | None = None)#

Methods

__init__(mesh_list[, name])

compare_quality(models[, boxplot])

Compare agglomeration models on the dataset.

compute_quality_metrics([boxplot])

Compute average quality metrics for all meshes in the dataset.

__init__(mesh_list: list[AggMesh], name: str | None = None)#
compare_quality(models: list, boxplot=False, **kwargs)#

Compare agglomeration models on the dataset.

Agglomerates the mesh dataset with each of the given agglomeration models, and then compares them by computing quality metrics on the agglomerated meshes.

Parameters: models : list of AgglomerationModel

Models to be compared.

**kwargsdict[str, Any], optional

Additional keyword arguments to pass to AggMesh.agglomerate.

Returns: list of np.ndarray of float

The computed quality metrics for each agglomeration model.

Notes

It does no make sense to use Kmeans and Metis on heterogeneous domains, since they have no way to process this information.

See also

AggMesh.agglomerate

agglomerate the mesh.

Examples

>>> from magnet import aggmodels
>>> from magnet.generate import dataset_2D
>>> from magnet.io import load_dataset
>>> dataset_2D({'random_delaunay': 200}, 'datasets', 'Testdataset')
>>> dataset = load_dataset('datasets/Testdataset')
>>> mt = aggmodels.METIS()
>>> km = aggmodels.KMEANS()
>>> dataset.compare_quality([mt, km], 'mult_factor', mult_factor=.3)
compute_quality_metrics(boxplot: bool = True) ndarray#

Compute average quality metrics for all meshes in the dataset.

Parameters:

boxplot (bool, optional) – If True, create a boxplot to of the quality metrics (default is True).

Returns:

Array of shape (dataset_size, 3): each column corresponds to a mean quality metric (CR, UF, VD).

Return type:

np.ndarray of float

Inherited Methods

add_mesh(mesh)

Add a mesh to the dataset.

count(value)

index(value, [start, [stop]])

Raises ValueError if the value is not present.

merge(other_dataset)

Merge two datasets.