matminer.featurizers.tests package¶
Submodules¶
matminer.featurizers.tests.test_bandstructure module¶
matminer.featurizers.tests.test_base module¶
- class matminer.featurizers.tests.test_base.FittableFeaturizer¶
Bases:
BaseFeaturizer
This test featurizer tests fitting qualities of BaseFeaturizer, including refittability and different results based on different fits.
- citations()¶
Citation(s) and reference(s) for this feature.
- Returns:
- (list) each element should be a string citation,
ideally in BibTeX format.
- feature_labels()¶
Generate attribute names.
- Returns:
([str]) attribute labels.
- featurize(x)¶
Main featurizer function, which has to be implemented in any derived featurizer subclass.
- Args:
x: input data to featurize (type depends on featurizer).
- Returns:
(list) one or more features.
- fit(X, y=None, **fit_kwargs)¶
Update the parameters of this featurizer based on available data
- Args:
X - [list of tuples], training data
- Returns:
self
- implementors()¶
List of implementors of the feature.
- Returns:
- (list) each element should either be a string with author name (e.g.,
“Anubhav Jain”) or a dictionary with required key “name” and other keys like “email” or “institution” (e.g., {“name”: “Anubhav Jain”, “email”: “ajain@lbl.gov”, “institution”: “LBNL”}).
- class matminer.featurizers.tests.test_base.MatrixFeaturizer¶
Bases:
BaseFeaturizer
- citations()¶
Citation(s) and reference(s) for this feature.
- Returns:
- (list) each element should be a string citation,
ideally in BibTeX format.
- feature_labels()¶
Generate attribute names.
- Returns:
([str]) attribute labels.
- featurize(*x)¶
Main featurizer function, which has to be implemented in any derived featurizer subclass.
- Args:
x: input data to featurize (type depends on featurizer).
- Returns:
(list) one or more features.
- implementors()¶
List of implementors of the feature.
- Returns:
- (list) each element should either be a string with author name (e.g.,
“Anubhav Jain”) or a dictionary with required key “name” and other keys like “email” or “institution” (e.g., {“name”: “Anubhav Jain”, “email”: “ajain@lbl.gov”, “institution”: “LBNL”}).
- class matminer.featurizers.tests.test_base.MultiArgs2¶
Bases:
BaseFeaturizer
- __init__()¶
- citations()¶
Citation(s) and reference(s) for this feature.
- Returns:
- (list) each element should be a string citation,
ideally in BibTeX format.
- feature_labels()¶
Generate attribute names.
- Returns:
([str]) attribute labels.
- featurize(*x)¶
Main featurizer function, which has to be implemented in any derived featurizer subclass.
- Args:
x: input data to featurize (type depends on featurizer).
- Returns:
(list) one or more features.
- implementors()¶
List of implementors of the feature.
- Returns:
- (list) each element should either be a string with author name (e.g.,
“Anubhav Jain”) or a dictionary with required key “name” and other keys like “email” or “institution” (e.g., {“name”: “Anubhav Jain”, “email”: “ajain@lbl.gov”, “institution”: “LBNL”}).
- class matminer.featurizers.tests.test_base.MultiTypeFeaturizer¶
Bases:
BaseFeaturizer
A featurizer that returns multiple dtypes
- citations()¶
Citation(s) and reference(s) for this feature.
- Returns:
- (list) each element should be a string citation,
ideally in BibTeX format.
- feature_labels()¶
Generate attribute names.
- Returns:
([str]) attribute labels.
- featurize(*x)¶
Main featurizer function, which has to be implemented in any derived featurizer subclass.
- Args:
x: input data to featurize (type depends on featurizer).
- Returns:
(list) one or more features.
- implementors()¶
List of implementors of the feature.
- Returns:
- (list) each element should either be a string with author name (e.g.,
“Anubhav Jain”) or a dictionary with required key “name” and other keys like “email” or “institution” (e.g., {“name”: “Anubhav Jain”, “email”: “ajain@lbl.gov”, “institution”: “LBNL”}).
- class matminer.featurizers.tests.test_base.MultipleFeatureFeaturizer¶
Bases:
BaseFeaturizer
- citations()¶
Citation(s) and reference(s) for this feature.
- Returns:
- (list) each element should be a string citation,
ideally in BibTeX format.
- feature_labels()¶
Generate attribute names.
- Returns:
([str]) attribute labels.
- featurize(x)¶
Main featurizer function, which has to be implemented in any derived featurizer subclass.
- Args:
x: input data to featurize (type depends on featurizer).
- Returns:
(list) one or more features.
- implementors()¶
List of implementors of the feature.
- Returns:
- (list) each element should either be a string with author name (e.g.,
“Anubhav Jain”) or a dictionary with required key “name” and other keys like “email” or “institution” (e.g., {“name”: “Anubhav Jain”, “email”: “ajain@lbl.gov”, “institution”: “LBNL”}).
- class matminer.featurizers.tests.test_base.SingleFeaturizer¶
Bases:
BaseFeaturizer
- citations()¶
Citation(s) and reference(s) for this feature.
- Returns:
- (list) each element should be a string citation,
ideally in BibTeX format.
- feature_labels()¶
Generate attribute names.
- Returns:
([str]) attribute labels.
- featurize(x)¶
Main featurizer function, which has to be implemented in any derived featurizer subclass.
- Args:
x: input data to featurize (type depends on featurizer).
- Returns:
(list) one or more features.
- implementors()¶
List of implementors of the feature.
- Returns:
- (list) each element should either be a string with author name (e.g.,
“Anubhav Jain”) or a dictionary with required key “name” and other keys like “email” or “institution” (e.g., {“name”: “Anubhav Jain”, “email”: “ajain@lbl.gov”, “institution”: “LBNL”}).
- class matminer.featurizers.tests.test_base.SingleFeaturizerMultiArgs¶
Bases:
SingleFeaturizer
- featurize(*x)¶
Main featurizer function, which has to be implemented in any derived featurizer subclass.
- Args:
x: input data to featurize (type depends on featurizer).
- Returns:
(list) one or more features.
- class matminer.featurizers.tests.test_base.SingleFeaturizerMultiArgsWithPrecheck¶
Bases:
SingleFeaturizerMultiArgs
- precheck(*x)¶
Precheck (provide an estimate of whether a featurizer will work or not) for a single entry (e.g., a single composition). If the entry fails the precheck, it will most likely fail featurization; if it passes, it is likely (but not guaranteed) to featurize correctly.
- Prechecks should be:
accurate (but can be good estimates rather than ground truth)
fast to evaluate
- unlikely to be obsolete via changes in the featurizer in the near
future
This method should be overridden by any featurizer requiring its use, as by default all entries will pass prechecking. Also, precheck is a good opportunity to throw warnings about long runtimes (e.g., doing nearest neighbors computations on a structure with many thousand sites).
See the documentation for precheck_dataframe for more information.
- Args:
- *x (Composition, Structure, etc.): Input to-be-featurized. Can be
a single input or multiple inputs.
- Returns:
(bool): True, if passes the precheck. False, if fails.
- class matminer.featurizers.tests.test_base.SingleFeaturizerWithPrecheck¶
Bases:
SingleFeaturizer
- precheck(x)¶
Precheck (provide an estimate of whether a featurizer will work or not) for a single entry (e.g., a single composition). If the entry fails the precheck, it will most likely fail featurization; if it passes, it is likely (but not guaranteed) to featurize correctly.
- Prechecks should be:
accurate (but can be good estimates rather than ground truth)
fast to evaluate
- unlikely to be obsolete via changes in the featurizer in the near
future
This method should be overridden by any featurizer requiring its use, as by default all entries will pass prechecking. Also, precheck is a good opportunity to throw warnings about long runtimes (e.g., doing nearest neighbors computations on a structure with many thousand sites).
See the documentation for precheck_dataframe for more information.
- Args:
- *x (Composition, Structure, etc.): Input to-be-featurized. Can be
a single input or multiple inputs.
- Returns:
(bool): True, if passes the precheck. False, if fails.
- class matminer.featurizers.tests.test_base.TestBaseClass(methodName='runTest')¶
Bases:
PymatgenTest
- static make_test_data()¶
- setUp()¶
Hook method for setting up the test fixture before exercising it.
- test_caching()¶
Test whether MultiFeaturizer properly caches
- test_dataframe()¶
- test_featurize_many()¶
- test_fittable()¶
- test_ignore_errors()¶
- test_indices()¶
- test_inplace()¶
- test_matrix()¶
Test the ability to add features that are matrices to a dataframe
- test_multifeature_no_zero_index()¶
Test whether multifeaturizer can handle series that lack a entry with index==0
- test_multifeatures_multiargs()¶
- test_multiindex_in_multifeaturizer()¶
- test_multiindex_inplace()¶
- test_multiindex_return()¶
- test_multiple()¶
- test_multiprocessing_df()¶
- test_multitype_multifeat()¶
Test Multifeaturizer when a featurizer returns a non-numeric type
- test_precheck()¶
- test_stacked_featurizer()¶
matminer.featurizers.tests.test_conversions module¶
- class matminer.featurizers.tests.test_conversions.TestConversions(methodName='runTest')¶
Bases:
PymatgenTest
- test_ase_conversion()¶
- test_composition_to_oxidcomposition()¶
- test_composition_to_structurefromMP()¶
- test_conversion_multiindex()¶
- test_conversion_multiindex_dynamic()¶
- test_conversion_overwrite()¶
- test_dict_to_object()¶
- test_json_to_object()¶
- test_pymatgen_general_converter()¶
- test_str_to_composition()¶
- test_structure_to_composition()¶
- test_structure_to_oxidstructure()¶
- test_to_istructure()¶