Some Composition features not working

Hi,

I have not tested all composition features.

Three of the features, AtomicOribitals, ElectronAffinity and ElectronegativityDiff do not work. I believe all these features require X.featurize_dataframe(df,’‘composition_oxid’) unlike the other composition features which require composition, i.e. X.featurize_dataframe(df,’‘composition’)

Below is one example error that I got from running and extending the tutorial in the link:

https://nbviewer.jupyter.org/github/hackingmaterials/matminer_examples/blob/master/matminer_examples/machine_learning-nb/bulk_modulus.ipynb

from matminer.featurizers.composition import ElectronegativityDiff
ED_feat = ElectronegativityDiff()
df = ED_feat.featurize_dataframe(df, ‘composition_oxid’)
ElectronegativityDiff: 100%|█████████████████████████████████████████████████████████| 1181/1181 [00:00<00:00, 6325.20it/s]
multiprocessing.pool.RemoteTraceback:
“”"
Traceback (most recent call last):
File “/home/dxs/.local/lib/python3.6/site-packages/matminer/featurizers/base.py”, line 493, in featurize_wrapper
return self.featurize(x)
File “/home/dxs/.local/lib/python3.6/site-packages/matminer/featurizers/composition.py”, line 512, in featurize
anions, anion_fractions = zip(
[(s, x) for s, x in comp.items() if s.oxi_state < 0])
ValueError: not enough values to unpack (expected 2, got 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/lib64/python3.6/multiprocessing/pool.py”, line 119, in worker
result = (True, func(*args, **kwds))
File “/usr/lib64/python3.6/multiprocessing/pool.py”, line 44, in mapstar
return list(map(*args))
File “/home/dxs/.local/lib/python3.6/site-packages/matminer/featurizers/base.py”, line 508, in featurize_wrapper
reraise(type(e), type(e)(msg), sys.exc_info()[2])
File “/usr/local/lib/python3.6/site-packages/six.py”, line 692, in reraise
raise value.with_traceback(tb)
File “/home/dxs/.local/lib/python3.6/site-packages/matminer/featurizers/base.py”, line 493, in featurize_wrapper
return self.featurize(x)
File “/home/dxs/.local/lib/python3.6/site-packages/matminer/featurizers/composition.py”, line 512, in featurize
anions, anion_fractions = zip(
[(s, x) for s, x in comp.items() if s.oxi_state < 0])
ValueError: not enough values to unpack (expected 2, got 0)
To skip errors when featurizing specific compounds, consider running the batch featurize() operation (e.g., featurize_many(), featurize_dataframe(), etc.) with ignore_errors=True
“”"

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “”, line 1, in
File “/home/dxs/.local/lib/python3.6/site-packages/matminer/featurizers/base.py”, line 340, in featurize_dataframe
pbar=pbar)
File “/home/dxs/.local/lib/python3.6/site-packages/matminer/featurizers/base.py”, line 467, in featurize_many
return p.map(func, entries, chunksize=self.chunksize)
File “/usr/lib64/python3.6/multiprocessing/pool.py”, line 266, in map
return self._map_async(func, iterable, mapstar, chunksize).get()
File “/usr/lib64/python3.6/multiprocessing/pool.py”, line 644, in get
raise self._value
ValueError: not enough values to unpack (expected 2, got 0)
To skip errors when featurizing specific compounds, consider running the batch featurize() operation (e.g., featurize_many(), featurize_dataframe(), etc.) with ignore_errors=True

···

Hi Debasis,

A quick suggestion is that you can try featurizer.featurize_dataframe(df, ‘composition_oxid’, ignore_errors=True). This would avoid breaking the featurization process due to some featurizers do not work for certain compositions (which is the case here) and the features of those compositions will be NaN. You can later do feature reduction to remove those non-functioning features.

The problem-maker here is that not all featurizers are suitable for certain compositions. For example, in the case of ElectronegativityDiff and ElectronAffinity you got problems with, I guess they are due to that oxidation states are ill-defined for some compositions, for example, compositions with all metals. According to the description, you are trying to featurize the elastic tensor dataset, and I guess there could be many compositions that these featurizers do not work well. You can try ignore_errors=True and look at the featurized dataframe for more details.

Best,

Qi

···

On Tuesday, April 16, 2019 at 7:06:45 AM UTC-7, [email protected] wrote:

Hi,

I have not tested all composition features.

Three of the features, AtomicOribitals, ElectronAffinity and ElectronegativityDiff do not work. I believe all these features require X.featurize_dataframe(df,’‘composition_oxid’) unlike the other composition features which require composition, i.e. X.featurize_dataframe(df,’‘composition’)

Below is one example error that I got from running and extending the tutorial in the link:

https://nbviewer.jupyter.org/github/hackingmaterials/matminer_examples/blob/master/matminer_examples/machine_learning-nb/bulk_modulus.ipynb

from matminer.featurizers.composition import ElectronegativityDiff
ED_feat = ElectronegativityDiff()
df = ED_feat.featurize_dataframe(df, ‘composition_oxid’)
ElectronegativityDiff: 100%|█████████████████████████████████████████████████████████| 1181/1181 [00:00<00:00, 6325.20it/s]
multiprocessing.pool.RemoteTraceback:
“”"
Traceback (most recent call last):
File “/home/dxs/.local/lib/python3.6/site-packages/matminer/featurizers/base.py”, line 493, in featurize_wrapper
return self.featurize(x)
File “/home/dxs/.local/lib/python3.6/site-packages/matminer/featurizers/composition.py”, line 512, in featurize
anions, anion_fractions = zip(
[(s, x) for s, x in comp.items() if s.oxi_state < 0])
ValueError: not enough values to unpack (expected 2, got 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/lib64/python3.6/multiprocessing/pool.py”, line 119, in worker
result = (True, func(*args, **kwds))
File “/usr/lib64/python3.6/multiprocessing/pool.py”, line 44, in mapstar
return list(map(*args))
File “/home/dxs/.local/lib/python3.6/site-packages/matminer/featurizers/base.py”, line 508, in featurize_wrapper
reraise(type(e), type(e)(msg), sys.exc_info()[2])
File “/usr/local/lib/python3.6/site-packages/six.py”, line 692, in reraise
raise value.with_traceback(tb)
File “/home/dxs/.local/lib/python3.6/site-packages/matminer/featurizers/base.py”, line 493, in featurize_wrapper
return self.featurize(x)
File “/home/dxs/.local/lib/python3.6/site-packages/matminer/featurizers/composition.py”, line 512, in featurize
anions, anion_fractions = zip(
[(s, x) for s, x in comp.items() if s.oxi_state < 0])
ValueError: not enough values to unpack (expected 2, got 0)
To skip errors when featurizing specific compounds, consider running the batch featurize() operation (e.g., featurize_many(), featurize_dataframe(), etc.) with ignore_errors=True
“”"

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “”, line 1, in
File “/home/dxs/.local/lib/python3.6/site-packages/matminer/featurizers/base.py”, line 340, in featurize_dataframe
pbar=pbar)
File “/home/dxs/.local/lib/python3.6/site-packages/matminer/featurizers/base.py”, line 467, in featurize_many
return p.map(func, entries, chunksize=self.chunksize)
File “/usr/lib64/python3.6/multiprocessing/pool.py”, line 266, in map
return self._map_async(func, iterable, mapstar, chunksize).get()
File “/usr/lib64/python3.6/multiprocessing/pool.py”, line 644, in get
raise self._value
ValueError: not enough values to unpack (expected 2, got 0)
To skip errors when featurizing specific compounds, consider running the batch featurize() operation (e.g., featurize_many(), featurize_dataframe(), etc.) with ignore_errors=True

Hey Debasis,

An addition to what Qi said:

You can also add return_errors=True argument to the featurize_dataframe method when ignore_errors=True is also passed. This will add a column of the exceptions raised for each material to the dataframe (materials which were featurized successfully will have “nan” for errors); this is useful for inspecting what is going wrong with the featurization.

Thanks,

Alex