How to use the matminer.featurizers.structure function in matminer

To help you get started, we’ve selected a few matminer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hackingmaterials / automatminer / automatminer / featurization / sets.py View on Github external
def heavy(self):
        fs = [
            self.ssf.from_preset("CrystalNNFingerprint_ops"),
            sf.ChemicalOrdering(),
            sf.StructuralHeterogeneity(),
            sf.MaximumPackingEfficiency(),
            sf.XRDPowderPattern(),
            sf.Dimensionality(),
            sf.OrbitalFieldMatrix(flatten=True),
            sf.JarvisCFID(),
        ]
        fs += self.express
        fs = self._add_external(fs)
        return self._get_featurizers(fs)
github uw-cmg / MAST-ML / mastml / legos / feature_generators.py View on Github external
def transform(self, df, y=None):
        # iterate through dataframe rows
        for i, rows in df.iterrows():
            f = Poscar.from_file(df.at[i, self.structure_col])
            structure = f.structure # create pymatgen structure object
            df.at[i, self.structure_col] = structure # replace path with structure object

        # iterate through structural_features list
        for struc_feat in range(len(self.structural_features)):
            # nested loop to check structural_features list item against matminer structures list
            for feature_name in inspect.getmembers(struc, inspect.isclass):
                # if structural feature item is a match
                if feature_name[0] == self.structural_features[struc_feat]:
                    sf = getattr(struc, self.structural_features[struc_feat])()  # instantiates the structure featurizer
                    df = sf.fit_featurize_dataframe(df, self.structure_col)  # fit_featurize_dataframe() works for all
                    # updates dataframe if the structural feature happens to be the GlobalSymmetryFeatures
                    if self.structural_features[struc_feat] == "GlobalSymmetryFeatures":
                        df = df.drop('crystal_system', axis=1)
                        for i, rows in df.iterrows():
                            if df.at[i, "is_centrosymmetric"] == True:
                                df.at[i, "is_centrosymmetric"] = 1
                            elif df.at[i, "is_centrosymmetric"] == False:
                                df.at[i, "is_centrosymmetric"] = 0
                    break # structure feature was found for this iteration, repeat

        # drop unused dataframe columns for rest of application
        df = df.drop(self.structure_col, axis=1)
        df = df.drop('Material', axis=1)
        return df  # return generated dataframe
github hackingmaterials / automatminer / automatminer / featurization / sets.py View on Github external
def __init__(self, exclude=None):
        super(StructureFeaturizers, self).__init__(exclude=exclude)
        self.ssf = sf.SiteStatsFingerprint
github uw-cmg / MAST-ML / mastml / legos / feature_generators.py View on Github external
def transform(self, df, y=None):
        # iterate through dataframe rows
        for i, rows in df.iterrows():
            f = Poscar.from_file(df.at[i, self.structure_col])
            structure = f.structure # create pymatgen structure object
            df.at[i, self.structure_col] = structure # replace path with structure object

        # iterate through structural_features list
        for struc_feat in range(len(self.structural_features)):
            # nested loop to check structural_features list item against matminer structures list
            for feature_name in inspect.getmembers(struc, inspect.isclass):
                # if structural feature item is a match
                if feature_name[0] == self.structural_features[struc_feat]:
                    sf = getattr(struc, self.structural_features[struc_feat])()  # instantiates the structure featurizer
                    df = sf.fit_featurize_dataframe(df, self.structure_col)  # fit_featurize_dataframe() works for all
                    # updates dataframe if the structural feature happens to be the GlobalSymmetryFeatures
                    if self.structural_features[struc_feat] == "GlobalSymmetryFeatures":
                        df = df.drop('crystal_system', axis=1)
                        for i, rows in df.iterrows():
                            if df.at[i, "is_centrosymmetric"] == True:
                                df.at[i, "is_centrosymmetric"] = 1
                            elif df.at[i, "is_centrosymmetric"] == False:
                                df.at[i, "is_centrosymmetric"] = 0
                    break # structure feature was found for this iteration, repeat

        # drop unused dataframe columns for rest of application
        df = df.drop(self.structure_col, axis=1)
github hackingmaterials / automatminer / automatminer / featurization / sets.py View on Github external
def _add_external(self, fset):
        # Prevent import errors
        require_external = []
        if torch and cgcnn:
            require_external.append(sf.CGCNNFeaturizer())
        if dscribe:
            require_external.append(sf.SOAP())
        return fset + require_external