active-learning-step 2026.10.14__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- active_learning_step/__init__.py +34 -0
- active_learning_step/_version.py +21 -0
- active_learning_step/active_learning.py +209 -0
- active_learning_step/active_learning_parameters.py +120 -0
- active_learning_step/active_learning_step.py +95 -0
- active_learning_step/check.py +928 -0
- active_learning_step/cli.py +468 -0
- active_learning_step/committee.py +774 -0
- active_learning_step/covalent_radii.py +131 -0
- active_learning_step/data/properties.csv +1 -0
- active_learning_step/data/references.bib +40 -0
- active_learning_step/engine.py +585 -0
- active_learning_step/lammps_data.py +147 -0
- active_learning_step/metadata.py +145 -0
- active_learning_step/molecules.py +279 -0
- active_learning_step/pool.py +252 -0
- active_learning_step/samplers.py +171 -0
- active_learning_step/score.py +284 -0
- active_learning_step/selection.py +550 -0
- active_learning_step/substep.py +99 -0
- active_learning_step/threads.py +74 -0
- active_learning_step/thresholds.py +168 -0
- active_learning_step/tk_active_learning.py +209 -0
- active_learning_step/train.py +588 -0
- active_learning_step-2026.10.14.dist-info/METADATA +140 -0
- active_learning_step-2026.10.14.dist-info/RECORD +32 -0
- active_learning_step-2026.10.14.dist-info/WHEEL +6 -0
- active_learning_step-2026.10.14.dist-info/entry_points.txt +8 -0
- active_learning_step-2026.10.14.dist-info/licenses/AUTHORS.rst +5 -0
- active_learning_step-2026.10.14.dist-info/licenses/LICENSE +31 -0
- active_learning_step-2026.10.14.dist-info/top_level.txt +1 -0
- active_learning_step-2026.10.14.dist-info/zip-safe +1 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
active_learning_step
|
|
5
|
+
A SEAMM plug-in for Active Learning
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
# Bring up the classes so that they appear to be directly in
|
|
9
|
+
# the active_learning_step package.
|
|
10
|
+
#
|
|
11
|
+
# The library (committee, molecules, pool, selection) and the seamm-al command also
|
|
12
|
+
# run in MLFF environments that have torch and xnn but not SEAMM, so the step's
|
|
13
|
+
# classes are only imported when SEAMM is there.
|
|
14
|
+
try:
|
|
15
|
+
import seamm # noqa: F401
|
|
16
|
+
except ImportError:
|
|
17
|
+
pass
|
|
18
|
+
else:
|
|
19
|
+
from .active_learning import ActiveLearning # noqa: F401, E501
|
|
20
|
+
from .active_learning_parameters import ActiveLearningParameters # noqa: F401, E501
|
|
21
|
+
from .active_learning_step import ActiveLearningStep # noqa: F401, E501
|
|
22
|
+
from .tk_active_learning import TkActiveLearning # noqa: F401, E501
|
|
23
|
+
|
|
24
|
+
from .metadata import metadata # noqa: F401
|
|
25
|
+
|
|
26
|
+
# Handle versioneer
|
|
27
|
+
from ._version import get_versions
|
|
28
|
+
|
|
29
|
+
__author__ = "Paul Saxe"
|
|
30
|
+
__email__ = "psaxe@molssi.org"
|
|
31
|
+
versions = get_versions()
|
|
32
|
+
__version__ = versions["version"]
|
|
33
|
+
__git_revision__ = versions["full-revisionid"]
|
|
34
|
+
del get_versions, versions
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
# This file was generated by 'versioneer.py' (0.18) from
|
|
3
|
+
# revision-control system data, or from the parent directory name of an
|
|
4
|
+
# unpacked source archive. Distribution tarballs contain a pre-generated copy
|
|
5
|
+
# of this file.
|
|
6
|
+
|
|
7
|
+
import json
|
|
8
|
+
|
|
9
|
+
version_json = '''
|
|
10
|
+
{
|
|
11
|
+
"date": "2026-10-14T06:21:42-0400",
|
|
12
|
+
"dirty": false,
|
|
13
|
+
"error": null,
|
|
14
|
+
"full-revisionid": "1644bd1a7793ed3ca65d488119b41a5d0a7d1180",
|
|
15
|
+
"version": "2026.10.14"
|
|
16
|
+
}
|
|
17
|
+
''' # END VERSION_JSON
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def get_versions():
|
|
21
|
+
return json.loads(version_json)
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
"""Non-graphical part of the Active Learning step in a SEAMM flowchart"""
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
import importlib.resources
|
|
8
|
+
import pprint # noqa: F401
|
|
9
|
+
|
|
10
|
+
import active_learning_step
|
|
11
|
+
import molsystem
|
|
12
|
+
import seamm
|
|
13
|
+
from seamm_util import ureg, Q_ # noqa: F401
|
|
14
|
+
import seamm_util.printing as printing
|
|
15
|
+
from seamm_util.printing import FormattedText as __
|
|
16
|
+
|
|
17
|
+
# In addition to the normal logger, two logger-like printing facilities are
|
|
18
|
+
# defined: "job" and "printer". "job" send output to the main job.out file for
|
|
19
|
+
# the job, and should be used very sparingly, typically to echo what this step
|
|
20
|
+
# will do in the initial summary of the job.
|
|
21
|
+
#
|
|
22
|
+
# "printer" sends output to the file "step.out" in this steps working
|
|
23
|
+
# directory, and is used for all normal output from this step.
|
|
24
|
+
|
|
25
|
+
logger = logging.getLogger(__name__)
|
|
26
|
+
job = printing.getPrinter()
|
|
27
|
+
printer = printing.getPrinter("Active Learning")
|
|
28
|
+
|
|
29
|
+
# Add this module's properties to the standard properties
|
|
30
|
+
path = importlib.resources.files("active_learning_step") / "data"
|
|
31
|
+
csv_file = path / "properties.csv"
|
|
32
|
+
if path.exists():
|
|
33
|
+
molsystem.add_properties_from_file(csv_file)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class ActiveLearning(seamm.Node):
|
|
37
|
+
"""
|
|
38
|
+
The non-graphical part of a Active Learning step in a flowchart.
|
|
39
|
+
|
|
40
|
+
Attributes
|
|
41
|
+
----------
|
|
42
|
+
parser : configargparse.ArgParser
|
|
43
|
+
The parser object.
|
|
44
|
+
|
|
45
|
+
options : tuple
|
|
46
|
+
It contains a two item tuple containing the populated namespace and the
|
|
47
|
+
list of remaining argument strings.
|
|
48
|
+
|
|
49
|
+
subflowchart : seamm.Flowchart
|
|
50
|
+
A SEAMM Flowchart object that represents a subflowchart, if needed.
|
|
51
|
+
|
|
52
|
+
parameters : ActiveLearningParameters
|
|
53
|
+
The control parameters for Active Learning.
|
|
54
|
+
|
|
55
|
+
See Also
|
|
56
|
+
--------
|
|
57
|
+
TkActiveLearning,
|
|
58
|
+
ActiveLearning, ActiveLearningParameters
|
|
59
|
+
"""
|
|
60
|
+
|
|
61
|
+
def __init__(
|
|
62
|
+
self, flowchart=None, title="Active Learning", extension=None, logger=logger
|
|
63
|
+
):
|
|
64
|
+
"""A step for Active Learning in a SEAMM flowchart.
|
|
65
|
+
|
|
66
|
+
You may wish to change the title above, which is the string displayed
|
|
67
|
+
in the box representing the step in the flowchart.
|
|
68
|
+
|
|
69
|
+
Parameters
|
|
70
|
+
----------
|
|
71
|
+
flowchart: seamm.Flowchart
|
|
72
|
+
The non-graphical flowchart that contains this step.
|
|
73
|
+
|
|
74
|
+
title: str
|
|
75
|
+
The name displayed in the flowchart.
|
|
76
|
+
extension: None
|
|
77
|
+
Not yet implemented
|
|
78
|
+
logger : Logger = logger
|
|
79
|
+
The logger to use and pass to parent classes
|
|
80
|
+
|
|
81
|
+
Returns
|
|
82
|
+
-------
|
|
83
|
+
None
|
|
84
|
+
"""
|
|
85
|
+
logger.debug(f"Creating Active Learning {self}")
|
|
86
|
+
|
|
87
|
+
super().__init__(
|
|
88
|
+
flowchart=flowchart,
|
|
89
|
+
title="Active Learning",
|
|
90
|
+
extension=extension,
|
|
91
|
+
module=__name__,
|
|
92
|
+
logger=logger,
|
|
93
|
+
) # yapf: disable
|
|
94
|
+
|
|
95
|
+
self._metadata = active_learning_step.metadata
|
|
96
|
+
self.parameters = active_learning_step.ActiveLearningParameters()
|
|
97
|
+
|
|
98
|
+
@property
|
|
99
|
+
def version(self):
|
|
100
|
+
"""The semantic version of this module."""
|
|
101
|
+
return active_learning_step.__version__
|
|
102
|
+
|
|
103
|
+
@property
|
|
104
|
+
def git_revision(self):
|
|
105
|
+
"""The git version of this module."""
|
|
106
|
+
return active_learning_step.__git_revision__
|
|
107
|
+
|
|
108
|
+
def description_text(self, P=None):
|
|
109
|
+
"""Create the text description of what this step will do.
|
|
110
|
+
The dictionary of control values is passed in as P so that
|
|
111
|
+
the code can test values, etc.
|
|
112
|
+
|
|
113
|
+
Parameters
|
|
114
|
+
----------
|
|
115
|
+
P: dict
|
|
116
|
+
An optional dictionary of the current values of the control
|
|
117
|
+
parameters.
|
|
118
|
+
Returns
|
|
119
|
+
-------
|
|
120
|
+
str
|
|
121
|
+
A description of the current step.
|
|
122
|
+
"""
|
|
123
|
+
if not P:
|
|
124
|
+
P = self.parameters.values_to_dict()
|
|
125
|
+
|
|
126
|
+
text = (
|
|
127
|
+
"Please replace this with a short summary of the "
|
|
128
|
+
"Active Learning step, including key parameters."
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
return self.header + "\n" + __(text, **P, indent=4 * " ").__str__()
|
|
132
|
+
|
|
133
|
+
def run(self):
|
|
134
|
+
"""Run a Active Learning step.
|
|
135
|
+
|
|
136
|
+
Parameters
|
|
137
|
+
----------
|
|
138
|
+
None
|
|
139
|
+
|
|
140
|
+
Returns
|
|
141
|
+
-------
|
|
142
|
+
seamm.Node
|
|
143
|
+
The next node object in the flowchart.
|
|
144
|
+
"""
|
|
145
|
+
next_node = super().run(printer)
|
|
146
|
+
# Get the values of the parameters, dereferencing any variables
|
|
147
|
+
P = self.parameters.current_values_to_dict(
|
|
148
|
+
context=seamm.flowchart_variables._data
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
# Print what we are doing
|
|
152
|
+
printer.important(__(self.description_text(P), indent=self.indent))
|
|
153
|
+
|
|
154
|
+
directory = Path(self.directory)
|
|
155
|
+
directory.mkdir(parents=True, exist_ok=True)
|
|
156
|
+
|
|
157
|
+
# Get the current system and configuration (ignoring the system...)
|
|
158
|
+
_, configuration = self.get_system_configuration(None)
|
|
159
|
+
|
|
160
|
+
# Results data
|
|
161
|
+
data = {}
|
|
162
|
+
|
|
163
|
+
# Temporary code just to print the parameters. You will need to change
|
|
164
|
+
# this!
|
|
165
|
+
for key in P:
|
|
166
|
+
print("{:>15s} = {}".format(key, P[key]))
|
|
167
|
+
printer.normal(
|
|
168
|
+
__(
|
|
169
|
+
"{key:>15s} = {value}",
|
|
170
|
+
key=key,
|
|
171
|
+
value=P[key],
|
|
172
|
+
indent=4 * " ",
|
|
173
|
+
wrap=False,
|
|
174
|
+
dedent=False,
|
|
175
|
+
)
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
# Analyze the results
|
|
179
|
+
self.analyze()
|
|
180
|
+
# Put any requested results into variables or tables
|
|
181
|
+
self.store_results(
|
|
182
|
+
configuration=configuration,
|
|
183
|
+
data=data,
|
|
184
|
+
)
|
|
185
|
+
# Add other citations here or in the appropriate place in the code.
|
|
186
|
+
# Add the bibtex to data/references.bib, and add a self.reference.cite
|
|
187
|
+
# similar to the above to actually add the citation to the references.
|
|
188
|
+
|
|
189
|
+
return next_node
|
|
190
|
+
|
|
191
|
+
def analyze(self, indent="", **kwargs):
|
|
192
|
+
"""Do any analysis of the output from this step.
|
|
193
|
+
|
|
194
|
+
Also print important results to the local step.out file using
|
|
195
|
+
"printer".
|
|
196
|
+
|
|
197
|
+
Parameters
|
|
198
|
+
----------
|
|
199
|
+
indent: str
|
|
200
|
+
An extra indentation for the output
|
|
201
|
+
"""
|
|
202
|
+
printer.normal(
|
|
203
|
+
__(
|
|
204
|
+
"This is a placeholder for the results from the Active Learning step",
|
|
205
|
+
indent=4 * " ",
|
|
206
|
+
wrap=True,
|
|
207
|
+
dedent=False,
|
|
208
|
+
)
|
|
209
|
+
)
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Control parameters for the Active Learning step in a SEAMM flowchart
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import logging
|
|
7
|
+
import seamm
|
|
8
|
+
import pprint # noqa: F401
|
|
9
|
+
|
|
10
|
+
logger = logging.getLogger(__name__)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ActiveLearningParameters(seamm.Parameters):
|
|
14
|
+
"""
|
|
15
|
+
The control parameters for Active Learning.
|
|
16
|
+
|
|
17
|
+
You need to replace the "time" entry in dictionary below these comments with the
|
|
18
|
+
definitions of parameters to control this step. The keys are parameters for the
|
|
19
|
+
current plugin,the values are dictionaries as outlined below.
|
|
20
|
+
|
|
21
|
+
Examples
|
|
22
|
+
--------
|
|
23
|
+
::
|
|
24
|
+
|
|
25
|
+
parameters = {
|
|
26
|
+
"time": {
|
|
27
|
+
"default": 100.0,
|
|
28
|
+
"kind": "float",
|
|
29
|
+
"default_units": "ps",
|
|
30
|
+
"enumeration": tuple(),
|
|
31
|
+
"format_string": ".1f",
|
|
32
|
+
"description": "Simulation time:",
|
|
33
|
+
"help_text": ("The time to simulate in the dynamics run.")
|
|
34
|
+
},
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
parameters : {str: {str: str}}
|
|
38
|
+
A dictionary containing the parameters for the current step.
|
|
39
|
+
Each key of the dictionary is a dictionary that contains the
|
|
40
|
+
the following keys:
|
|
41
|
+
|
|
42
|
+
parameters["default"] :
|
|
43
|
+
The default value of the parameter, used to reset it.
|
|
44
|
+
|
|
45
|
+
parameters["kind"] : enum()
|
|
46
|
+
Specifies the kind of a variable. One of "integer", "float", "string",
|
|
47
|
+
"boolean", or "enum"
|
|
48
|
+
|
|
49
|
+
While the "kind" of a variable might be a numeric value, it may still have
|
|
50
|
+
enumerated custom values meaningful to the user. For instance, if the parameter
|
|
51
|
+
is a convergence criterion for an optimizer, custom values like "normal",
|
|
52
|
+
"precise", etc, might be adequate. In addition, any parameter can be set to a
|
|
53
|
+
variable of expression, indicated by having "$" as the first character in the
|
|
54
|
+
field. For example, $OPTIMIZER_CONV.
|
|
55
|
+
|
|
56
|
+
parameters["default_units"] : str
|
|
57
|
+
The default units, used for resetting the value.
|
|
58
|
+
|
|
59
|
+
parameters["enumeration"] : tuple
|
|
60
|
+
A tuple of enumerated values.
|
|
61
|
+
|
|
62
|
+
parameters["format_string"] : str
|
|
63
|
+
A format string for "pretty" output.
|
|
64
|
+
|
|
65
|
+
parameters["description"] : str
|
|
66
|
+
A short string used as a prompt in the GUI.
|
|
67
|
+
|
|
68
|
+
parameters["help_text"] : str
|
|
69
|
+
A longer string to display as help for the user.
|
|
70
|
+
|
|
71
|
+
See Also
|
|
72
|
+
--------
|
|
73
|
+
ActiveLearning, TkActiveLearning, ActiveLearningParameters, ActiveLearningStep
|
|
74
|
+
"""
|
|
75
|
+
|
|
76
|
+
parameters = {
|
|
77
|
+
"time": {
|
|
78
|
+
"default": 100.0,
|
|
79
|
+
"kind": "float",
|
|
80
|
+
"default_units": "ps",
|
|
81
|
+
"enumeration": tuple(),
|
|
82
|
+
"format_string": ".1f",
|
|
83
|
+
"description": "Simulation time:",
|
|
84
|
+
"help_text": ("The time to simulate in the dynamics run."),
|
|
85
|
+
},
|
|
86
|
+
# # Results handling ... uncomment if needed
|
|
87
|
+
# "results": {
|
|
88
|
+
# "default": {},
|
|
89
|
+
# "kind": "dictionary",
|
|
90
|
+
# "default_units": "",
|
|
91
|
+
# "enumeration": tuple(),
|
|
92
|
+
# "format_string": "",
|
|
93
|
+
# "description": "results",
|
|
94
|
+
# "help_text": "The results to save to variables or in tables.",
|
|
95
|
+
# },
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
def __init__(self, defaults={}, data=None):
|
|
99
|
+
"""
|
|
100
|
+
Initialize the parameters, by default with the parameters defined above
|
|
101
|
+
|
|
102
|
+
Parameters
|
|
103
|
+
----------
|
|
104
|
+
defaults: dict
|
|
105
|
+
A dictionary of parameters to initialize. The parameters
|
|
106
|
+
above are used first and any given will override/add to them.
|
|
107
|
+
data: dict
|
|
108
|
+
A dictionary of keys and a subdictionary with value and units
|
|
109
|
+
for updating the current, default values.
|
|
110
|
+
|
|
111
|
+
Returns
|
|
112
|
+
-------
|
|
113
|
+
None
|
|
114
|
+
"""
|
|
115
|
+
|
|
116
|
+
logger.debug("ActiveLearningParameters.__init__")
|
|
117
|
+
|
|
118
|
+
super().__init__(
|
|
119
|
+
defaults={**ActiveLearningParameters.parameters, **defaults}, data=data
|
|
120
|
+
)
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
import active_learning_step
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ActiveLearningStep(object):
|
|
7
|
+
"""Helper class needed for the stevedore integration.
|
|
8
|
+
|
|
9
|
+
This must provide a `description()` method that returns a dict containing a
|
|
10
|
+
description of this node, and `create_node()` and `create_tk_node()` methods
|
|
11
|
+
for creating the graphical and non-graphical nodes.
|
|
12
|
+
|
|
13
|
+
The dictionary for the description is the class variable just below these
|
|
14
|
+
comments. The felds are as follows:
|
|
15
|
+
|
|
16
|
+
my_description : {str, str}
|
|
17
|
+
A human-readable description of this step. It can be
|
|
18
|
+
several lines long, and needs to be clear to non-expert users.
|
|
19
|
+
It contains the following keys: description, group, name.
|
|
20
|
+
|
|
21
|
+
my_description["description"] : tuple
|
|
22
|
+
A description of the Active Learning step. It must be
|
|
23
|
+
clear to non-experts.
|
|
24
|
+
|
|
25
|
+
my_description["group"] : str
|
|
26
|
+
Which group in the menus to put this step. If the group does
|
|
27
|
+
not exist it will be created. Common groups are "Building",
|
|
28
|
+
"Control", "Custom", "Data", and "Simulations".
|
|
29
|
+
|
|
30
|
+
my_description["name"] : str
|
|
31
|
+
The name of this step, to be displayed in the menus.
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
my_description = {
|
|
35
|
+
"description": "An interface for Active Learning",
|
|
36
|
+
"group": "Simulations",
|
|
37
|
+
"name": "Active Learning",
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
def __init__(self, flowchart=None, gui=None):
|
|
41
|
+
"""Initialize this helper class, which is used by
|
|
42
|
+
the application via stevedore to get information about
|
|
43
|
+
and create node objects for the flowchart
|
|
44
|
+
"""
|
|
45
|
+
pass
|
|
46
|
+
|
|
47
|
+
def create_node(self, flowchart=None, **kwargs):
|
|
48
|
+
"""Create and return the new node object.
|
|
49
|
+
|
|
50
|
+
Parameters
|
|
51
|
+
----------
|
|
52
|
+
flowchart: seamm.Node
|
|
53
|
+
A non-graphical SEAMM node
|
|
54
|
+
|
|
55
|
+
**kwargs : keyword arguments
|
|
56
|
+
Various keyword arguments such as title, namespace or
|
|
57
|
+
extension representing the title displayed in the flowchart,
|
|
58
|
+
the namespace for the plugins of a subflowchart and
|
|
59
|
+
the extension, respectively.
|
|
60
|
+
|
|
61
|
+
Returns
|
|
62
|
+
-------
|
|
63
|
+
ActiveLearning
|
|
64
|
+
"""
|
|
65
|
+
|
|
66
|
+
return active_learning_step.ActiveLearning(flowchart=flowchart, **kwargs)
|
|
67
|
+
|
|
68
|
+
def create_tk_node(self, canvas=None, **kwargs):
|
|
69
|
+
"""Create and return the graphical Tk node object.
|
|
70
|
+
|
|
71
|
+
Parameters
|
|
72
|
+
----------
|
|
73
|
+
canvas : tk.Canvas
|
|
74
|
+
The Tk Canvas widget
|
|
75
|
+
|
|
76
|
+
**kwargs : keyword arguments
|
|
77
|
+
Various keyword arguments such as tk_flowchart, node, x, y, w, h
|
|
78
|
+
representing a graphical flowchart object, a non-graphical node for
|
|
79
|
+
a step, and dimensions of the graphical node.
|
|
80
|
+
|
|
81
|
+
Returns
|
|
82
|
+
-------
|
|
83
|
+
TkActiveLearning
|
|
84
|
+
"""
|
|
85
|
+
|
|
86
|
+
return active_learning_step.TkActiveLearning(canvas=canvas, **kwargs)
|
|
87
|
+
|
|
88
|
+
def description(self):
|
|
89
|
+
"""Return a description of what this step does.
|
|
90
|
+
|
|
91
|
+
Returns
|
|
92
|
+
-------
|
|
93
|
+
description : dict(str, str)
|
|
94
|
+
"""
|
|
95
|
+
return ActiveLearningStep.my_description
|