graph2mat.core.data.metrics

Functions to assess performance.

When answering “How similar are these two matrices?”, there is no perfectly right answer. Depending on what you are most interested in, you might use any of the functions implemented here.

Functions are wrapped into an OrbitalMatrixMetric class to make sure they share the same interface and that they are all registered.

Functions

get_predictions_error(nodes_pred, nodes_ref, ...)

Returns errors for both nodes and edges, removing NaN values.

Classes

Meta

OrbitalMatrixMetric(*args, **kwds)

block_type_mae(*args, **kwds)

block_type_mae_sigmoid_thresh(*args, **kwds)

block_type_mape(*args, **kwds)

block_type_mapemaemix(*args, **kwds)

block_type_mapemsemix(*args, **kwds)

block_type_mapestdmix(*args, **kwds)

block_type_mse(*args, **kwds)

block_type_mse_sigmoid_thresh(*args, **kwds)

block_type_mse_threshold(*args, **kwds)

edge_mse(*args, **kwds)

elementwise_mse(*args, **kwds)

node_mse(*args, **kwds)

normalized_density_error(*args, **kwds)

class graph2mat.core.data.metrics.OrbitalMatrixMetric(*args: Any, **kwds: Any)[source]

Bases: object

__call__(*args, **kwargs)[source]

Call self as a function.

static compute_metric(nodes_pred, nodes_ref, edges_pred, edges_ref, **kwargs) Tuple[float, Dict[str, float]][source]

Function that actually computes the metric. This function should return the metric and a dictionary of other intermediate metrics that have been computed as intermediate steps (or are easy to compute from intermediate steps), if applicable. This other metrics might be, for example, logged during training.

classmethod from_metric_func(fn: Callable) Type[OrbitalMatrixMetric][source]

Creates an OrbitalMatrixMetric class from a function that computes the loss.

get_metric(config_resolved=False, **kwargs) Tuple[float, Dict[str, float]] | ndarray[source]

Get the value for the metric.

Parameters:

config_resolved (bool, optional) –

Whether the metric should be computed individually for each configuration in the batch, by default False.

If False, a single float is returned, which is the metric for the whole batch. If True, a numpy array is returned, which contains the metric for each configuration in the batch.

Returns:

The metric value(s), as specified by config_resolved.

If config_resolved is False, a dictionary is also returned containing additional stats related to the metric.

Return type:

Union[Tuple[float, Dict[str, float]], np.ndarray]

class graph2mat.core.data.metrics.block_type_mae(*args: Any, **kwds: Any)[source]

Bases: OrbitalMatrixMetric

static compute_metric(nodes_pred, nodes_ref, edges_pred, edges_ref, log_verbose=False, **kwargs) Tuple[float, Dict[str, float]]

Function that actually computes the metric. This function should return the metric and a dictionary of other intermediate metrics that have been computed as intermediate steps (or are easy to compute from intermediate steps), if applicable. This other metrics might be, for example, logged during training.

class graph2mat.core.data.metrics.block_type_mae_sigmoid_thresh(*args: Any, **kwds: Any)[source]

Bases: OrbitalMatrixMetric

static compute_metric(nodes_pred, nodes_ref, edges_pred, edges_ref, threshold=0.0001, sigmoid_factor=1e-05, log_verbose=False, **kwargs) Tuple[float, Dict[str, float]]

Function that actually computes the metric. This function should return the metric and a dictionary of other intermediate metrics that have been computed as intermediate steps (or are easy to compute from intermediate steps), if applicable. This other metrics might be, for example, logged during training.

class graph2mat.core.data.metrics.block_type_mape(*args: Any, **kwds: Any)[source]

Bases: OrbitalMatrixMetric

static compute_metric(nodes_pred, nodes_ref, edges_pred, edges_ref, log_verbose=False, **kwargs) Tuple[float, Dict[str, float]]

Function that actually computes the metric. This function should return the metric and a dictionary of other intermediate metrics that have been computed as intermediate steps (or are easy to compute from intermediate steps), if applicable. This other metrics might be, for example, logged during training.

class graph2mat.core.data.metrics.block_type_mapemaemix(*args: Any, **kwds: Any)[source]

Bases: OrbitalMatrixMetric

static compute_metric(nodes_pred, nodes_ref, edges_pred, edges_ref, log_verbose=False, **kwargs) Tuple[float, Dict[str, float]]

Function that actually computes the metric. This function should return the metric and a dictionary of other intermediate metrics that have been computed as intermediate steps (or are easy to compute from intermediate steps), if applicable. This other metrics might be, for example, logged during training.

class graph2mat.core.data.metrics.block_type_mapemsemix(*args: Any, **kwds: Any)[source]

Bases: OrbitalMatrixMetric

static compute_metric(nodes_pred, nodes_ref, edges_pred, edges_ref, log_verbose=False, **kwargs) Tuple[float, Dict[str, float]]

Function that actually computes the metric. This function should return the metric and a dictionary of other intermediate metrics that have been computed as intermediate steps (or are easy to compute from intermediate steps), if applicable. This other metrics might be, for example, logged during training.

class graph2mat.core.data.metrics.block_type_mapestdmix(*args: Any, **kwds: Any)[source]

Bases: OrbitalMatrixMetric

static compute_metric(nodes_pred, nodes_ref, edges_pred, edges_ref, log_verbose=False, **kwargs) Tuple[float, Dict[str, float]]

Function that actually computes the metric. This function should return the metric and a dictionary of other intermediate metrics that have been computed as intermediate steps (or are easy to compute from intermediate steps), if applicable. This other metrics might be, for example, logged during training.

class graph2mat.core.data.metrics.block_type_mse(*args: Any, **kwds: Any)[source]

Bases: OrbitalMatrixMetric

static compute_metric(nodes_pred, nodes_ref, edges_pred, edges_ref, log_verbose=False, **kwargs) Tuple[float, Dict[str, float]]

Function that actually computes the metric. This function should return the metric and a dictionary of other intermediate metrics that have been computed as intermediate steps (or are easy to compute from intermediate steps), if applicable. This other metrics might be, for example, logged during training.

class graph2mat.core.data.metrics.block_type_mse_sigmoid_thresh(*args: Any, **kwds: Any)[source]

Bases: OrbitalMatrixMetric

static compute_metric(nodes_pred, nodes_ref, edges_pred, edges_ref, threshold=0.0001, sigmoid_factor=1e-05, log_verbose=False, **kwargs) Tuple[float, Dict[str, float]]

Function that actually computes the metric. This function should return the metric and a dictionary of other intermediate metrics that have been computed as intermediate steps (or are easy to compute from intermediate steps), if applicable. This other metrics might be, for example, logged during training.

class graph2mat.core.data.metrics.block_type_mse_threshold(*args: Any, **kwds: Any)[source]

Bases: OrbitalMatrixMetric

static compute_metric(nodes_pred, nodes_ref, edges_pred, edges_ref, threshold=0.0001, log_verbose=False, **kwargs) Tuple[float, Dict[str, float]]

Function that actually computes the metric. This function should return the metric and a dictionary of other intermediate metrics that have been computed as intermediate steps (or are easy to compute from intermediate steps), if applicable. This other metrics might be, for example, logged during training.

class graph2mat.core.data.metrics.edge_mse(*args: Any, **kwds: Any)[source]

Bases: OrbitalMatrixMetric

static compute_metric(nodes_pred, nodes_ref, edges_pred, edges_ref, log_verbose=False, **kwargs) Tuple[float, Dict[str, float]]

Function that actually computes the metric. This function should return the metric and a dictionary of other intermediate metrics that have been computed as intermediate steps (or are easy to compute from intermediate steps), if applicable. This other metrics might be, for example, logged during training.

class graph2mat.core.data.metrics.elementwise_mse(*args: Any, **kwds: Any)[source]

Bases: OrbitalMatrixMetric

static compute_metric(nodes_pred, nodes_ref, edges_pred, edges_ref, log_verbose=False, **kwargs) Tuple[float, Dict[str, float]]

Function that actually computes the metric. This function should return the metric and a dictionary of other intermediate metrics that have been computed as intermediate steps (or are easy to compute from intermediate steps), if applicable. This other metrics might be, for example, logged during training.

class graph2mat.core.data.metrics.node_mse(*args: Any, **kwds: Any)[source]

Bases: OrbitalMatrixMetric

static compute_metric(nodes_pred, nodes_ref, edges_pred, edges_ref, log_verbose=False, **kwargs) Tuple[float, Dict[str, float]]

Function that actually computes the metric. This function should return the metric and a dictionary of other intermediate metrics that have been computed as intermediate steps (or are easy to compute from intermediate steps), if applicable. This other metrics might be, for example, logged during training.

class graph2mat.core.data.metrics.normalized_density_error(*args: Any, **kwds: Any)[source]

Bases: OrbitalMatrixMetric

static compute_metric(nodes_pred, nodes_ref, edges_pred, edges_ref, batch, basis_table, grid_spacing: float = 0.1, log_verbose=False, **kwargs) Tuple[float, Dict[str, float]]

Computes the normalized density error.

This is the error of the density in real space divided by the number of electrons.