Hi all,
I want to know if can use mat-miner to featurize vdw radius for each element using the composition. I looked through the documentation, but could not find any information related to this.
Thanks
Alex
Hi all,
I want to know if can use mat-miner to featurize vdw radius for each element using the composition. I looked through the documentation, but could not find any information related to this.
Thanks
Alex
Have you already looked at ElementProperty? It lets you map compositions to features based on the property of the elements, and Iâd be surprised if we donât have vdw as an available feature
Hi Logan,
Thanks for the prompt reply. While looking at the features summary I could not find any info related to vdw radius.
https://hackingmaterials.lbl.gov/matminer/featurizer_summary.html
May be I am not looking at the right place. If you could provide any pointers that will be very helpful.
Thanks,
Alex
Hey Alex,
What youâll need to do is create an ElementProperty featurizer then define the vdw Radius as a elemental property it should use.
For vdw, you can use the one from the Magpie element property set (https://github.com/hackingmaterials/matminer/tree/main/matminer/utils/data_files/magpie_elementdata) that looks like:
feat = ElementProperty("magpie", ["vdwRadius"], ["mean"]) # Compute the mean vdw radius of the compositions using the Magpie feature set.
See here for more details on ElementProperty: https://github.com/hackingmaterials/matminer/blob/e2843d4de7f1806afb79498b32a7dabe73ee49de/matminer/featurizers/composition/composite.py#L18
Thanks Logan. This certainty helped me to improve my understanding of matminer.
The issue related to adding âvdwRadiusâ as a feature however, still remains. I tested your suggestion with the following:
from matminer.featurizers.composition import ElementProperty
import pandas as pd
from pymatgen.core import Composition
# Initialize the ElementProperty featurizer
ep_featurizer = ElementProperty("magpie", ["vdwRadius"], ["mean"])
# List of chemical formulas
chemical_formulas = ['H', 'He', 'Li', 'Be', 'B', 'C']
# Create Composition objects from formulas
compositions = [Composition(formula) for formula in chemical_formulas]
df = pd.DataFrame({'composition': compositions})
# Initialize the ElementProperty featurizer
# Compute elemental properties
features = ep_featurizer.featurize_dataframe(df, col_id="composition")
# Print the computed features
print(features.head())
This give me following error.
Traceback (most recent call last):
File "/usr/lib/python3.8/multiprocessing/pool.py", line 125, in worker
result = (True, func(*args, **kwds))
File "/usr/lib/python3.8/multiprocessing/pool.py", line 48, in mapstar
return list(map(*args))
File "/home/alex/.local/lib/python3.8/site-packages/matminer/featurizers/base.py", line 514, in featurize_wrapper
raise type(e)(msg).with_traceback(sys.exc_info()[2])
File "/home/alex/.local/lib/python3.8/site-packages/matminer/featurizers/base.py", line 497, in featurize_wrapper
return self.featurize(*x)
File "/home/alex/.local/lib/python3.8/site-packages/matminer/featurizers/composition/composite.py", line 180, in featurize
elem_data = [self.data_source.get_elemental_property(e, attr) for e in elements]
File "/home/alex/.local/lib/python3.8/site-packages/matminer/featurizers/composition/composite.py", line 180, in <listcomp>
elem_data = [self.data_source.get_elemental_property(e, attr) for e in elements]
File "/home/alex/.local/lib/python3.8/site-packages/matminer/utils/data.py", line 223, in get_elemental_property
return self.all_elemental_props[property_name][elem.symbol]
KeyError: "'vdwRadius'\nTO SKIP THESE ERRORS when featurizing specific compounds, set 'ignore_errors=True' when running the batch featurize() operation (e.g., featurize_many(), featurize_dataframe(), etc.)."
Note that the I also tested the code above with âignore_errors=Trueâ, but it gives vdwRadius as NaN. However vdwRadius data is available in the VdWRadius.table for some of the elements in my dataframe.
If I change âvdwRadiusâ with other features listed at
tt works fine. Strangely vdwRadius is not there in the list of magpie features.
Thanks for you time.
Alex