route_distances package

Subpackages

Submodules

route_distances.clustering module

Module containing a class to help out with clustering

class route_distances.clustering.ClusteringHelper(distances)

Bases: object

A helper class to perform clustering of items based on a pre-computed distance matrix.

The clustering is the agglomerative clustering algorithm implemented in Scikit-learn.

Parameters

distances (np.ndarray) –

Return type

None

property labels: numpy.ndarray

Return the cluster labels

fixed_clustering(n_clusters, **kwargs)

Make a fixed number of clusters.

Additional arguments to the clustering algorithm can be passed in as key-word arguments

Parameters
  • n_clusters (int) – the desired number of clusters

  • kwargs (Any) –

Returns

the cluster index for each observation

Return type

numpy.ndarray

linkage_matrix(**kwargs)

Compute the linkage matrix.

Additional arguments to the clustering algorithm can be passed in as key-word arguments

Returns

the linkage matrix

Parameters

kwargs (Any) –

Return type

numpy.ndarray

optimize(max_clusters=5, **kwargs)

Optimize the number of cluster based Silhouette metric.

Additional arguments to the clustering algorithm can be passed in as key-word arguments

Parameters
  • max_clusters (int) – the maximum number of clusters to consider

  • kwargs (Any) –

Returns

the cluster index for each observation

Return type

numpy.ndarray

static cluster(distances, n_clusters, **kwargs)

Cluster items based on a pre-computed distance matrix using a hierarchical clustering.

Parameters
  • distances (numpy.ndarray) – the distance matrix

  • n_clusters (int) – the desired number of clusters

  • kwargs (Any) –

Returns

the cluster index for each observation

Return type

numpy.ndarray

route_distances.route_distances module

Module containing a factory function for making predictions of route distances

route_distances.route_distances.route_distances_calculator(model, **kwargs)

Return a callable that given a list routes as dictionaries calculate the squared distance matrix

Parameters
  • model (str) –

  • kwargs (Any) –

Returns

Return type

Callable[[List[Dict[str, Any]]], numpy.ndarray]

route_distances.validation module

Module containing routes to validate AiZynthFinder-like input dictionaries

class route_distances.validation.MoleculeNode(*, smiles, type, children)

Bases: pydantic.main.BaseModel

Node representing a molecule

Parameters
Return type

None

smiles: str
type: route_distances.validation.ConstrainedStrValue
children: Optional[types.ConstrainedListValue[route_distances.validation.ReactionNode]]
class route_distances.validation.ReactionNode(*, type, children)

Bases: pydantic.main.BaseModel

Node representing a reaction

Parameters
Return type

None

type: route_distances.validation.ConstrainedStrValue
children: List[route_distances.validation.MoleculeNode]
route_distances.validation.validate_dict(dict_)

Check that the route dictionary is a valid structure

Parameters
  • dict – the route as dictionary

  • dict_ (Dict[str, Any]) –

Return type

None

Module contents