xnn.common.data.hub.qm9.QM9Builder#

class xnn.common.data.hub.qm9.QM9Builder[source]#

Bases: DatasetBuilder

Builder for QM9 (133,885 molecules, 15 properties, random benchmark splits).

load(*, split=None, cache_dir, label='U0', units='eV', n_train=110000, n_val=10000, n_test=None, seed=0, exclude_uncharacterized=True, return_info=False, quiet=False)[source]#

Download, parse and split QM9.

Parameters:
  • split (str or None) – None returns {"train": ..., "val": ..., "test": ...}; "train" / "val" / "test" returns that split; "all" returns every molecule in gdb order.

  • cache_dir (pathlib.Path) – Base cache directory; the files are stored under cache_dir/"qm9".

  • label (str, optional) – The property stored as the structure energy, by default "U0" (see PROPERTIES).

  • units (str, optional) – "eV" (default; Hartree properties converted) or "hartree" (as published).

  • n_train (int, optional) – Sizes of the random training and validation splits, by default 110,000 and 10,000; the rest is the test split.

  • n_val (int, optional) – Sizes of the random training and validation splits, by default 110,000 and 10,000; the rest is the test split.

  • n_test (int, optional) – Truncate the test split to its first n_test molecules.

  • seed (int, optional) – Seed of the random split, by default 0.

  • exclude_uncharacterized (bool, optional) – Drop the 3054 molecules of uncharacterized.txt (default).

  • return_info (bool, optional) – Add an info dict with the gdb index and all 15 properties (in the chosen units) to every structure.

  • quiet (bool, optional) – Suppress download progress output.

Returns:

dict of {str – Structure dicts with pos (N, 3) (Angstrom), atomic_numbers (N,) and energy (the label).

Return type:

list of dict} or list of dict

Raises:

ValueError – For an unknown units, label or split.