usnistgov / jarvis

JARVIS-Tools: an open-source software package for data-driven atomistic materials design. Publications: https://scholar.google.com/citations?user=3w6ej94AAAAJ https://www.youtube.com/watch?v=2-XHeC8gbeY
https://pages.nist.gov/jarvis/
Other
313 stars 124 forks source link

Update tutorials.md for get_chem_only_descriptors #309

Closed bobleesj closed 9 months ago

bobleesj commented 9 months ago

I was following the "How to train chemical formula only datasets" tutorial from the document. I noticed that the tutorial had an incorrect function name of get_chem_only_descriptor instead of get_chem_only_descriptors. The following code block worked for me.

import numpy as np
from jarvis.ai.descriptors.cfid import get_chem_only_descriptors

# Load a dataset, you can use pandas read_csv also to generte my_data
# Here is a sample dataset
my_data = [
    ["CoAl", 1],
    ["CoNi", 2],
    ["CoNb2Ni5", 3],
    ["Co1.2Al2.3NiRe2", 4],
    ["Co", 5],
    ["CoAlTi", 1],
    ["CoNiTi", 2],
    ["CoNb2Ni5Ti", 3],
    ["Co1.2Al2.3NiRe2Ti", 4],
    ["CoTi", 5],
    ["CoAlFe", 1],
    ["CoNiFe", 2],
    ["CoNb2Ni5Fe", 3],
    ["Co1.2Al2.3NiRe2Fe", 4],
    ["CoFe", 5],
]

# Convert my_data to numpy array
X = []
Y = []
IDs = []
for ii, i in enumerate(my_data):
    X.append(get_chem_only_descriptors(i[0]))
    Y.append(i[1])
    IDs.append(ii)

X = np.array(X)
Y = np.array(Y).reshape(-1, 1)
IDs = np.array(IDs)

print(X, Y)
knc6 commented 9 months ago

Thanks @bobleesj for pointing out this issue.

bobleesj commented 9 months ago

Thanks!