ericgossett
1/21/2019 - 7:05 PM

ml_example.py

import json
from pprint import pprint
from aflowml.client import AFLOWmlAPI

with open('entries_data.json', 'r') as json_file:
    entries_data = json.load(json_file)
    predictions = []
    ml = AFLOWmlAPI()
    count = 1
    print("Fetching predictions:")
    for entry in entries_data:
        print('%s of %s               %s' % (
            count,
            len(entries_data),
            entry['auid']
        ))
        count += 1
        prediction = ml.get_prediction(entry['poscar'], 'plmf')
        # merge entry and prediction dict
        predictions.append(prediction)
    print('Output')
    pprint(predictions)