예제 #1
0
파일: uq.py 프로젝트: globus-labs/proxima
    def is_supported(self, model: BaseInferenceEngine,
                     training_data: ASEDataStore, X: Tuple[Atoms]):
        # Check total count
        if training_data.count() < self.min_entries:
            return False

        # Get the training points
        train_X, _ = training_data.get_all_data()
        if not training_data.convert_to_pmg:
            train_X = [AseAtomsAdaptor.get_molecule(x) for x in train_X]
        train_X = self.cm.fit_transform(train_X)

        # Make a distance computer
        # TODO (wardlt): Here is where we could benefit from checking if training set is updated
        nn = NearestNeighbors(n_neighbors=self.k,
                              n_jobs=self.n_jobs,
                              metric=self.metric).fit(train_X)

        # Get the distance
        strc = AseAtomsAdaptor.get_molecule(X[0])
        features = self.cm.transform([strc])
        dists, _ = nn.kneighbors(features)
        return np.mean(dists, axis=1)[0] < self.threshold
예제 #2
0
def molToMolecule(filename):
    """

    :code:`molToMolecule` can help us read the .mol file and return a pymatgen Molecule object.

    :param filename: The filename (relative path) that we want.
    :type filename: python string object

    :returns: A pymatgen Molecule object

    """

    from pymatgen.io.ase import AseAtomsAdaptor
    from ase.io import read

    mol = read(filename, format='mol')

    return AseAtomsAdaptor.get_molecule(mol)
예제 #3
0
 def infer(self, X: Atoms) -> float:
     # Convert to pymatgen format needed by matminer
     strc = AseAtomsAdaptor.get_molecule(X[0])
     return self.model.predict([strc])[0]