I have a DataFrame with a column called ‘composition’ that has pymatgen composition objects and I used the CompositionToStructureFromMP.featurize.dataframe() method to add a column of pymatgen structure objects for each entry.
print(df)
material_id formula_pretty composition \
0 mp-1226226 CrRe5B2 Cr1 Re5 B2
1 mp-569875 ScBRh3 Sc1 B1 Rh3
2 mp-1215920 YB2Mo Y1 B2 Mo1
3 mp-8631 LuAlB4 Lu1 Al1 B4
4 mp-1198294 Dy2B6Os Dy2 B6 Os1
5 mp-1191106 ScFeB4 Sc1 Fe1 B4
6 mp-1226242 CrB2W Cr1 B2 W1
7 mp-640067 Ni4B3 Ni4 B3
8 mp-1220630 Pr16Re25B24 Pr16 Re25 B24
structure
0 Full Formula (Cr1 Re5 B2)\nReduced Formula: Cr...
1 Full Formula (Sc1 B1 Rh3)\nReduced Formula: Sc...
2 Full Formula (Y1 B2 Mo1)\nReduced Formula: YB2...
3 Full Formula (Lu4 Al4 B16)\nReduced Formula: L...
4 Full Formula (Dy8 B24 Os4)\nReduced Formula: D...
5 NaN
6 Full Formula (Cr1 B2 W1)\nReduced Formula: CrB...
7 Full Formula (Ni16 B12)\nReduced Formula: Ni4B...
8 NaN
Now I am trying to use the OrbitalFieldMatrix structure featurizer on the ‘structure’ column, but I am getting the error below.
from matminer.featurizers.structure.matrix import OrbitalFieldMatrix
ofm = OrbitalFieldMatrix()
df = ofm.featurize_dataframe(df, 'structure')
RemoteTraceback Traceback (most recent call last)
RemoteTraceback:
"""
Traceback (most recent call last):
File "C:\Users\joeya\anaconda3\lib\site-packages\matminer\featurizers\base.py", line 497, in featurize_wrapper
return self.featurize(*x)
File "C:\Users\joeya\anaconda3\lib\site-packages\matminer\featurizers\structure\matrix.py", line 437, in featurize
s *= [3, 3, 3]
TypeError: can't multiply sequence by non-int of type 'list'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\joeya\anaconda3\lib\multiprocessing\pool.py", line 125, in worker
result = (True, func(*args, **kwds))
File "C:\Users\joeya\anaconda3\lib\multiprocessing\pool.py", line 48, in mapstar
return list(map(*args))
File "C:\Users\joeya\anaconda3\lib\site-packages\matminer\featurizers\base.py", line 514, in featurize_wrapper
reraise(type(e), type(e)(msg), sys.exc_info()[2])
File "C:\Users\joeya\anaconda3\lib\site-packages\six.py", line 718, in reraise
raise value.with_traceback(tb)
File "C:\Users\joeya\anaconda3\lib\site-packages\matminer\featurizers\base.py", line 497, in featurize_wrapper
return self.featurize(*x)
File "C:\Users\joeya\anaconda3\lib\site-packages\matminer\featurizers\structure\matrix.py", line 437, in featurize
s *= [3, 3, 3]
TypeError: can't multiply sequence by non-int of type 'list'
TO SKIP THESE ERRORS when featurizing specific compounds, set 'ignore_errors=True' when running the batch featurize() operation (e.g., featurize_many(), featurize_dataframe(), etc.).
"""
The above exception was the direct cause of the following exception:
TypeError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_14912\2267195686.py in <module>
3 ofm = OrbitalFieldMatrix()
4
----> 5 df = ofm.featurize_dataframe(df, 'structure')
6 display(df)
~\anaconda3\lib\site-packages\matminer\featurizers\base.py in featurize_dataframe(self, df, col_id, ignore_errors, return_errors, inplace, multiindex, pbar)
337
338 # Compute the features
--> 339 features = self.featurize_many(
340 df[col_id].values,
341 ignore_errors=ignore_errors,
~\anaconda3\lib\site-packages\matminer\featurizers\base.py in featurize_many(self, entries, ignore_errors, return_errors, pbar)
469 ignore_errors=ignore_errors,
470 )
--> 471 return p.map(func, entries, chunksize=self.chunksize)
472
473 def featurize_wrapper(self, x, return_errors=False, ignore_errors=False):
~\anaconda3\lib\multiprocessing\pool.py in map(self, func, iterable, chunksize)
362 in a list that is returned.
363 '''
--> 364 return self._map_async(func, iterable, mapstar, chunksize).get()
365
366 def starmap(self, func, iterable, chunksize=None):
~\anaconda3\lib\multiprocessing\pool.py in get(self, timeout)
769 return self._value
770 else:
--> 771 raise self._value
772
773 def _set(self, i, obj):
TypeError: can't multiply sequence by non-int of type 'list'
TO SKIP THESE ERRORS when featurizing specific compounds, set 'ignore_errors=True' when running the batch featurize() operation (e.g., featurize_many(), featurize_dataframe(), etc.).