MolecularDiffusion.utils.plot_function

Functions

plot_correlation_with_histograms(→ None)

Plot a scatter plot comparing predicted vs. true values, with marginal histograms.

plot_correlation_with_kde(→ None)

Plot a correlation scatter plot between predicted and true values,

plot_embedding(→ None)

Plot a 2D embedding with optional labels (for classification or regression).

plot_histogram_distribution(→ None)

Plot a histogram of the distribution for a single target.

plot_kde_distribution(→ None)

Plot the Kernel Density Estimate (KDE) of a single target distribution.

plot_kde_distribution_multiple(→ None)

Plot KDEs of multiple target distributions on the same axes.

Module Contents

MolecularDiffusion.utils.plot_function.plot_correlation_with_histograms(true_values: numpy.ndarray, predicted_values: numpy.ndarray, property_name: str = 'E', unit: str = 'eV', output_path: str | None = None) None

Plot a scatter plot comparing predicted vs. true values, with marginal histograms.

Parameters:
  • true_values (np.ndarray) – True target values.

  • predicted_values (np.ndarray) – Predicted target values.

  • property_name (str) – Name of the property (for axis labels). Default is “E”.

  • unit (str) – Unit of the property. Default is “eV”.

  • output_path (Optional[str]) – If provided, path to save the figure.

MolecularDiffusion.utils.plot_function.plot_correlation_with_kde(true_values: numpy.ndarray, predicted_values: numpy.ndarray, property_name: str = 'E', output_path: str | None = None) None

Plot a correlation scatter plot between predicted and true values, with probability density coloring, R² and MAE.

Parameters:
  • true_values (np.ndarray) – Array of true values.

  • predicted_values (np.ndarray) – Array of predicted values.

  • property_name (str) – Name of the property being compared (for axis labels). Defaults to ‘E’.

  • output_path (Optional[str]) – Path to save the figure. If None, the plot is not saved.

MolecularDiffusion.utils.plot_function.plot_embedding(embedding: numpy.ndarray, labels: numpy.ndarray | None = None, label_names: str | List[str] | None = None, label_type: str = 'reg', output_path: str = 'tSNE.png') None

Plot a 2D embedding with optional labels (for classification or regression).

Parameters:
  • embedding (np.ndarray) – 2D array of shape (n_samples, 2) representing t-SNE embedding.

  • labels (Optional[np.ndarray]) – 1D array of target labels (regression values or class indices).

  • label_names (Optional[Union[str, List[str]]]) – Name of the regression label or list of class names.

  • label_type (str) – Type of label (“reg” for regression, “class” for classification).

  • output_path (str) – Path to save the output image. Defaults to ‘tSNE.png’.

MolecularDiffusion.utils.plot_function.plot_histogram_distribution(predictions: numpy.ndarray, task_name: str, output_path: str | None = None, num_bins: int = 50) None

Plot a histogram of the distribution for a single target.

Parameters:
  • predictions (np.ndarray) – Array of prediction values (1D).

  • task_name (str) – Name of the task/property for labeling.

  • output_path (Optional[str]) – Path to save the plot. Defaults to ‘hist_targets.png’.

  • num_bins (int) – Number of histogram bins. Defaults to 50.

MolecularDiffusion.utils.plot_function.plot_kde_distribution(predictions: numpy.ndarray, task_name: str, output_path: str | None = None) None

Plot the Kernel Density Estimate (KDE) of a single target distribution.

Parameters:
  • predictions (np.ndarray) – Array of prediction values (1D).

  • task_name (str) – Name of the task/property for labeling.

  • output_path (Optional[str]) – Path to save the plot. Defaults to ‘kde_targets.png’.

MolecularDiffusion.utils.plot_function.plot_kde_distribution_multiple(predictions: numpy.ndarray, task_names: List[str], output_path: str | None = None) None

Plot KDEs of multiple target distributions on the same axes.

Parameters:
  • predictions (np.ndarray) – 2D array of shape (n_samples, n_tasks).

  • task_names (List[str]) – List of task/property names.

  • output_path (Optional[str]) – Path to save the plot. Defaults to ‘kde_targets.png’.