gnrs.cluster¶
gnrs.cluster.cluster_task¶
This module provides the ClusterSelectionTask class for performing cluster selection tasks.
This source code is licensed under the BSD-3-Clause license found in the LICENSE file in the root directory of this source tree.
- class gnrs.cluster.cluster_task.ClusterSelectionTask[source]¶
Bases:
TaskABCTask for performing cluster selection.
Initialize the cluster selection task.
- Parameters:
comm – MPI communicator
config – Config dictionary
gnrs_info – Genarris info dictionary
cluster – Clustering class name
selection – Selection class name
- __init__(comm, config, gnrs_info, cluster, selection)[source]¶
Initialize the cluster selection task.
- pack_settings()[source]¶
Pack settings needed for cluster selection.
- Returns:
Task settings dictionary
- Return type:
- print_settings(task_set)[source]¶
Print task settings in a formatted table.
- Parameters:
task_set (dict) – Task settings dictionary
- Return type:
None
gnrs.cluster.ap¶
This module provides the AP clustering algorithm.
This source code is licensed under the BSD-3-Clause license found in the LICENSE file in the root directory of this source tree.
- class gnrs.cluster.ap.APCluster[source]¶
Bases:
ClusterABCAffinity Propagation clustering implementation.
This class implements the Affinity Propagation clustering algorithm with support for distributed computation using MPI.
Initialize the APCluster object.
- Parameters:
comm – MPI communicator
task_settings – Task settings for AP clustering
- __init__(comm, task_settings)[source]¶
Initialize the APCluster object.
- Parameters:
comm (mpi4py.MPI.Comm) – MPI communicator
task_settings (dict) – Task settings for AP clustering
- Return type:
None
- initialize()[source]¶
Initialize the clustering by gathering crystal structures and computing similarity matrix.
This method: 1. Gathers structures from all processes 2. Computes or loads feature vectors 3. Computes or loads similarity matrix 4. Sets up preference range for AP clustering 5. Initializes the AP model
- Return type:
None
- fit()[source]¶
Fit the clustering model to the data.
Only AP-worker ranks run AP clustering.
- Return type:
None
- predict()[source]¶
Assign cluster labels to structures.
- Returns:
Final number of clusters
- Return type:
- check_convergence(n_clusters_pref, pref_range, n_attempts)[source]¶
Check if the clustering has converged.
- Parameters:
- Returns:
converged: Whether a suitable clustering was found
rank: Rank with suitable clustering
pref: preference used for clustering
n_cluster: Number of clusters found
new_pref_range: New preference range to try
- Return type:
Dictionary containing
gnrs.cluster.kmeans¶
This module provides k-means clustering.
This source code is licensed under the BSD-3-Clause license found in the LICENSE file in the root directory of this source tree.
- class gnrs.cluster.kmeans.KMEANSCluster[source]¶
Bases:
ClusterABCK-means clustering.
Initialize the k-means clustering.
- Parameters:
comm – MPI communicator
task_settings – Task settings
gnrs.cluster.selection.center¶
This module provides the CenterSelection class for selecting the center of a cluster.
This source code is licensed under the BSD-3-Clause license found in the LICENSE file in the root directory of this source tree.
- class gnrs.cluster.selection.center.CENTERSelection[source]¶
Bases:
SelectionABCSelection class that identifies and keeps only the center crystals from clusters.
This class can select centers based on either: 1. Crystals marked as centers during clustering 2. Crystals with minimum value of a specified property within each cluster
Initialize the selection algorithm.
- Parameters:
comm – MPI communicator for parallel computation
settings – Selection settings
gnrs.cluster.selection.window¶
This module provides the WindowSelection class for selecting structures within a energy window.
This source code is licensed under the BSD-3-Clause license found in the LICENSE file in the root directory of this source tree.
- class gnrs.cluster.selection.window.WINDOWSelection[source]¶
Bases:
SelectionABCSelection class that selects structures within a energy window from clusters.
Initialize the selection algorithm.
- Parameters:
comm – MPI communicator for parallel computation
settings – Selection settings
- select(struct_dict)[source]¶
Select structures within energy window from each cluster.
- Parameters:
struct_dict (dict) – Crystals dictionary
- Return type:
None