Recover a composition from ElementFraction

Hello everybody,

I was wondering if there is a straightforward way to recover a composition from a compositional vector obtained with ElementFraction() featurizer from matminer.

Not sure this is the most straight forward way, but you should be able to achieve what you want with:

from pymatgen.core import Composition

featurized_composition = ElementFraction().featurize(Composition('SiO2'))
composition_dict = {el:x for el, x in zip(ElementFraction().feature_labels(), featurized_composition)}
composition = Composition(composition_dict).get_integer_formula_and_factor()[0]


1 Like