BaseDataset
The BaseDataset defining shared functionality between all datasets.
BaseDataset
¶
Bases: DatasetPropertyMixIn
Base class for datasets in the openQDC package.
Source code in openqdc/datasets/base.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 |
|
__force_methods__
property
¶
For backward compatibility. To be removed in the future.
e0s_dispatcher: AtomEnergies
property
¶
Property to get the object that dispatched the isolated atom energies of the QM methods.
Returns:
Type | Description |
---|---|
AtomEnergies
|
Object wrapping the isolated atom energies of the QM methods. |
energy_methods: List[str]
property
¶
Return the string version of the energy methods
__init__(energy_unit=None, distance_unit=None, array_format='numpy', energy_type='formation', overwrite_local_cache=False, cache_dir=None, recompute_statistics=False, transform=None, skip_statistics=False, read_as_zarr=False, regressor_kwargs={'solver_type': 'linear', 'sub_sample': None, 'stride': 1})
¶
Parameters:
Name | Type | Description | Default |
---|---|---|---|
energy_unit |
Optional[str]
|
Energy unit to convert dataset to. Supported units: ["kcal/mol", "kj/mol", "hartree", "ev"] |
None
|
distance_unit |
Optional[str]
|
Distance unit to convert dataset to. Supported units: ["ang", "nm", "bohr"] |
None
|
array_format |
str
|
Format to return arrays in. Supported formats: ["numpy", "torch", "jax"] |
'numpy'
|
energy_type |
Optional[str]
|
Type of isolated atom energy to use for the dataset. Default: "formation" Supported types: ["formation", "regression", "null", None] |
'formation'
|
overwrite_local_cache |
bool
|
Whether to overwrite the locally cached dataset. |
False
|
cache_dir |
Optional[str]
|
Cache directory location. Defaults to "~/.cache/openqdc" |
None
|
recompute_statistics |
bool
|
Whether to recompute the statistics of the dataset. |
False
|
transform |
Optional[Callable]
|
transformation to apply to the getitem calls |
None
|
regressor_kwargs |
Dict
|
Dictionary of keyword arguments to pass to the regressor. Default: {"solver_type": "linear", "sub_sample": None, "stride": 1} solver_type can be one of ["linear", "ridge"] |
{'solver_type': 'linear', 'sub_sample': None, 'stride': 1}
|
Source code in openqdc/datasets/base.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
__smiles_converter__(x)
¶
util function to convert string to smiles: useful if the smiles is encoded in a different format than its display format
Source code in openqdc/datasets/base.py
719 720 721 722 723 |
|
as_iter(atoms=False, energy_method=0)
¶
Return the dataset as an iterator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
atoms |
bool
|
Whether to return the items as ASE atoms object, by default False |
False
|
energy_method |
int
|
Index of the energy method to use |
0
|
Returns:
Type | Description |
---|---|
Iterable
|
Iterator of the dataset |
Source code in openqdc/datasets/base.py
651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 |
|
calculate_descriptors(descriptor_name='soap', chemical_species=None, n_samples=None, progress=True, **descriptor_kwargs)
¶
Compute the descriptors for the dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
descriptor_name |
str
|
Name of the descriptor to use. Supported descriptors are ["soap"] |
'soap'
|
chemical_species |
Optional[List[str]]
|
List of chemical species to use for the descriptor computation, by default None. If None, the chemical species of the dataset are used. |
None
|
n_samples |
Optional[Union[List[int], int, float]]
|
Number of samples to use for the computation, by default None. If None, all the dataset is used. If a list of integers is provided, the descriptors are computed for each of the specified idx of samples. |
None
|
progress |
bool
|
Whether to show a progress bar, by default True. |
True
|
**descriptor_kwargs |
dict Keyword arguments to pass to the descriptor instantiation of the model. |
{}
|
Returns:
Type | Description |
---|---|
Dict[str, ndarray]
|
Dictionary containing the following keys: - values : np.ndarray of shape (N, M) containing the descriptors for the dataset - idxs : np.ndarray of shape (N,) containing the indices of the samples used |
Source code in openqdc/datasets/base.py
600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 |
|
collate_list(list_entries)
¶
Collate a list of entries into a single dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
list_entries |
List[Dict]
|
List of dictionaries containing the entries to collate. |
required |
Returns:
Type | Description |
---|---|
Dict
|
Dictionary containing the collated entries. |
Source code in openqdc/datasets/base.py
389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 |
|
get_ase_atoms(idx, energy_method=0, ext=True)
¶
Get the ASE atoms object for the entry at index idx.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
idx |
int
|
Index of the entry. |
required |
energy_method |
int
|
Index of the energy method to use |
0
|
ext |
bool
|
Whether to include additional informations |
True
|
Returns:
Type | Description |
---|---|
Atoms
|
ASE atoms object |
Source code in openqdc/datasets/base.py
566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 |
|
get_statistics(return_none=True)
¶
Get the converted statistics of the dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
return_none |
Whether to return None if the statistics for the forces are not available, by default True Otherwise, the statistics for the forces are set to 0.0 |
True
|
Returns:
Type | Description |
---|---|
Dict
|
Dictionary containing the statistics of the dataset |
Source code in openqdc/datasets/base.py
674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 |
|
is_cached()
¶
Check if the dataset is cached locally.
Returns:
Type | Description |
---|---|
bool
|
True if the dataset is cached locally, False otherwise. |
Source code in openqdc/datasets/base.py
480 481 482 483 484 485 486 487 488 489 490 491 492 |
|
is_preprocessed()
¶
Check if the dataset is preprocessed and available online or locally.
Returns:
Type | Description |
---|---|
bool
|
True if the dataset is available remotely or locally, False otherwise. |
Source code in openqdc/datasets/base.py
466 467 468 469 470 471 472 473 474 475 476 477 478 |
|
no_init()
classmethod
¶
Class method to avoid the init method to be called when the class is instanciated. Useful for debugging purposes or preprocessing data.
Source code in openqdc/datasets/base.py
209 210 211 212 213 214 215 |
|
preprocess(upload=False, overwrite=True, as_zarr=True)
¶
Preprocess the dataset and save it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
upload |
bool
|
Whether to upload the preprocessed data to the remote storage or only saving it locally. |
False
|
overwrite |
bool
|
hether to overwrite the preprocessed data if it already exists. Only used if upload is True. Cache is always overwritten locally. |
True
|
as_zarr |
bool
|
Whether to save the data as zarr files |
True
|
Source code in openqdc/datasets/base.py
494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 |
|
read_raw_entries()
¶
Preprocess the raw (aka from the fetched source) into a list of dictionaries.
Source code in openqdc/datasets/base.py
383 384 385 386 387 |
|
save_preprocess(data_dict, upload=False, overwrite=True, as_zarr=False)
¶
Save the preprocessed data to the cache directory and optionally upload it to the remote storage.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_dict |
Dict[str, ndarray]
|
Dictionary containing the preprocessed data. |
required |
upload |
bool
|
Whether to upload the preprocessed data to the remote storage or only saving it locally. |
False
|
overwrite |
bool
|
Whether to overwrite the preprocessed data if it already exists. Only used if upload is True. Cache is always overwritten locally. |
True
|
Source code in openqdc/datasets/base.py
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 |
|
save_xyz(idx, energy_method=0, path=None, ext=True)
¶
Save a single entry at index idx as an extxyz file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
idx |
int
|
Index of the entry |
required |
energy_method |
int
|
Index of the energy method to use |
0
|
path |
Optional[str]
|
Path to save the xyz file. If None, the current working directory is used. |
None
|
ext |
bool
|
Whether to include additional informations like forces and other metadatas (extxyz format) |
True
|
Source code in openqdc/datasets/base.py
529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 |
|
set_distance_unit(value)
¶
Set a new distance unit for the dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
str
|
New distance unit to set. |
required |
Source code in openqdc/datasets/base.py
366 367 368 369 370 371 372 373 374 375 376 377 |
|
set_energy_unit(value)
¶
Set a new energy unit for the dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
str
|
New energy unit to set. |
required |
Source code in openqdc/datasets/base.py
353 354 355 356 357 358 359 360 361 362 363 364 |
|
to_xyz(energy_method=0, path=None)
¶
Save dataset as single xyz file (extended xyz format).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
energy_method |
int
|
Index of the energy method to use |
0
|
path |
Optional[str]
|
Path to save the xyz file |
None
|
Source code in openqdc/datasets/base.py
548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 |
|
upload(overwrite=False, as_zarr=False)
¶
Upload the preprocessed data to the remote storage. Must be called after preprocess and need to have write privileges.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
overwrite |
bool
|
Whether to overwrite the remote data if it already exists |
False
|
as_zarr |
bool
|
Whether to upload the data as zarr files |
False
|
Source code in openqdc/datasets/base.py
512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 |
|