Oximachinerunner API reference¶
Implements methods to use oximachine as part of a Python package
-
class
oximachinerunner.
OximachineRunner
(modelname='all', automatic_download=True)[source]¶ Bases:
object
Loads a model and then runs the prediction
-
__init__
(modelname='all', automatic_download=True)[source]¶ - Parameters
modelname (str, optional) – [description]. Defaults to ‘all’. Use it to specifiy a model. You can view all available models with the .available_models property
automatic_download (bool, optional) – [description]. Defaults to True.
-
__weakref__
¶ list of weak references to the object (if defined)
-
property
available_models
¶ List all the available models.
- Return type
List
[str
]
-
property
default_mapping
¶ Return the default mapping between model name and filename
- Return type
Dict
[str
,str
]
-
property
feature_names
¶ Get a list of feature names
- Return type
List
[str
]
-
property
featureset
¶ Return the list of feature names
- Return type
List
[str
]
-
property
model
¶ Return the model object with .predict method
-
run_oximachine
(structure)[source]¶ Runs oximachine after attempting to guess what structure is
- Parameters
structure (Union[str, os.PathLike, Structure, Atoms]) –
be a pymatgen.Structure (can) –
or a filepath as str or (ase.Atoms) –
os.PathLike –
we then attempt to parse with pymatgen. (which) –
- Raises
ParsingError – In case the format of structure is not implemented or in case we cannot convert the input into a pymatgen Structure object.
FeaturizationError – In case the featurization fails.
PredictionError – In case the prediction fails.
- Returns
- with the keys metal_indices, metal_symbols,
prediction, max_probas, base_predictions
- Return type
OrderedDict
-
property
scaler
¶ Return the scaler object with .transform method
-
Some general utility functions for the oxidation state mining project
-
class
oximachinerunner.utils.
SymbolNameDict
[source]¶ Bases:
object
Parses the periodic table json and returns a dictionary with symbol: longname
-
__weakref__
¶ list of weak references to the object (if defined)
-
-
oximachinerunner.utils.
diff_to_18e
(nvalence)[source]¶ The number of electrons to donate to achieve 18 electrons might be an interesting descriptor, though there are more stable electron configurations
-
oximachinerunner.utils.
download_model
(url, destination, md5)[source]¶ - Downloads file from url to destination
and checks md5 hash
- Parameters
url (str) – URL
destination (Union[Path, str]) – Path to which the downloaded file will be saved
md5 (str) – Expected md5 hash
- Raises
Exception – [description]
Exception – [description]
-
oximachinerunner.utils.
has_metal_sites
(structure)[source]¶ Returns True if there is a metal in the structure.
-
oximachinerunner.utils.
model_exists
(path, md5)[source]¶ Checks whether a model if the expected md5 hash exists at the path
-
oximachinerunner.utils.
read_pickle
(filepath)[source]¶ Does what it says. Nothing more and nothing less. Takes a pickle file path and unpickles it
Defining custom exceptions for OximachineRunner
-
exception
oximachinerunner.errors.
FeaturizationError
[source]¶ Bases:
oximachinerunner.errors.OximachineRunnerException
Error that is thrown if the featurization fails
-
exception
oximachinerunner.errors.
ModelNotFoundError
[source]¶ Bases:
oximachinerunner.errors.OximachineRunnerException
Error that is thrown if the model could not be found
-
exception
oximachinerunner.errors.
NoMetalError
[source]¶ Bases:
oximachinerunner.errors.OximachineRunnerException
Error that is thrown if there is no metal in the structure
-
exception
oximachinerunner.errors.
OximachineRunnerException
[source]¶ Bases:
Exception
General class for oximachine errors
-
__weakref__
¶ list of weak references to the object (if defined)
-
-
exception
oximachinerunner.errors.
ParsingError
[source]¶ Bases:
oximachinerunner.errors.OximachineRunnerException
Error that is thrown if we cannot convert the structure into a pymatgen Structure object
-
exception
oximachinerunner.errors.
PredictionError
[source]¶ Bases:
oximachinerunner.errors.OximachineRunnerException
Error that is thrown if the prediction fails