def test_desc(): fname = os.path.join( os.path.dirname(__file__), "..", "sklearn", "examples", "POSCAR" ) poscar = Structure.from_file(fname) desc = get_comp_descp(poscar) assert len(desc) == 1557
from monty.json import MontyEncoder, MontyDecoder from monty.serialization import loadfn, dumpfn from sklearn.ensemble import RandomForestRegressor, GradientBoostingRegressor from sklearn.feature_selection import VarianceThreshold from sklearn.pipeline import Pipeline import numpy as np import sys, os from jarvis.db.static.explore_db import get_3d_dataset, get_2d_dataset pos = os.path.join(os.path.dirname(__file__), "..", "..", "vasp", "examples", "SiOptb88", "POSCAR") # STEP-1: Check if the descriptor array length for POSCAR is 1557 as # mentioned in https://journals.aps.org/prmaterials/abstract/10.1103/PhysRevMaterials.2.083801 s = Structure.from_file(pos) X = get_comp_descp(s) print(X, len(X)) # 1557 # STEP-2: Download JARVIS-DFT database for bulk materials # from https://figshare.com/articles/jdft_3d-7-7-2018_json/6815699 # STEP-3: load data data = get_3d_dataset() # loadfn("jdft_3d-7-7-2018.json", cls=MontyDecoder) print("data length", len(data)) print("available keys", data[0].keys()) # Simple function to check if the data is available/float def isfloat(value): try:
# coding: utf-8 from jarvis.sklearn.get_desc import get_comp_descp from pymatgen.core.structure import Structure from monty.json import MontyEncoder, MontyDecoder from monty.serialization import loadfn, dumpfn from sklearn.ensemble import RandomForestRegressor,GradientBoostingRegressor from sklearn.feature_selection import VarianceThreshold from sklearn.pipeline import Pipeline import numpy as np import sys #STEP-1: Check if the descriptor array length for POSCAR is 1557 as # mentioned in https://journals.aps.org/prmaterials/abstract/10.1103/PhysRevMaterials.2.083801 s=Structure.from_file('POSCAR') X=get_comp_descp(s) print (X,len(X)) #1557 #STEP-2: Download JARVIS-DFT database for bulk materials #from https://figshare.com/articles/jdft_3d-7-7-2018_json/6815699 #STEP-3: load data data=loadfn('jdft_3d-7-7-2018.json',cls=MontyDecoder) print ('data length',len(data)) print ('available keys',data[0].keys()) def isfloat(value): #Simple function to check if the data is available/float try: float(value)
def test_desc(): fname = os.path.join(os.path.dirname(__file__), '..', 'sklearn', 'examples', 'POSCAR') poscar = Structure.from_file(fname) desc = get_comp_descp(poscar) assert len(desc) == 1557
def test_desc(self): poscar=Structure.from_file(str('../sklearn/examples/POSCAR')) desc=get_comp_descp(poscar) self.assertEqual(len(desc), 1557)