Some Composition features not working

79 views
Skip to first unread message

debasis.se...@gmail.com

unread,
Apr 16, 2019, 10:06:45 AM4/16/19
to matminer
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:


>>> 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 "<stdin>", line 1, in <module>
  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
>>>

qwa...@lbl.gov

unread,
Apr 16, 2019, 1:26:42 PM4/16/19
to matminer
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

ard...@lbl.gov

unread,
Apr 16, 2019, 7:59:39 PM4/16/19
to matminer
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

Reply all
Reply to author
Forward
0 new messages