I have a pandas dataframe of structures from the QMOF database on the materials project. When I try to fit the bag of bonds featurizer:
featurizer = BagofBonds()
featurizer.fit(df['structure'][0:5])
I get the following:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[111], line 2
1 featurizer = BagofBonds()
----> 2 featurizer.fit(dfftr['structure'][0:5])
File ~/anaconda3/envs/py38/lib/python3.8/site-packages/matminer/featurizers/structure/bonding.py:537, in BagofBonds.fit(self, X, y)
535 unpadded_bobs = [self.bag(s, return_baglens=True) for s in X]
536 bonds = [list(bob.keys()) for bob in unpadded_bobs]
--> 537 bonds = np.unique(sum(bonds, []))
538 baglens = [0] * len(bonds)
540 for i, bond in enumerate(bonds):
File <__array_function__ internals>:200, in unique(*args, **kwargs)
File ~/anaconda3/envs/py38/lib/python3.8/site-packages/numpy/lib/arraysetops.py:272, in unique(ar, return_index, return_inverse, return_counts, axis, equal_nan)
138 @array_function_dispatch(_unique_dispatcher)
139 def unique(ar, return_index=False, return_inverse=False,
140 return_counts=False, axis=None, *, equal_nan=True):
141 """
142 Find the unique elements of an array.
143
(...)
270
271 """
--> 272 ar = np.asanyarray(ar)
273 if axis is None:
274 ret = _unique1d(ar, return_index, return_inverse, return_counts,
275 equal_nan=equal_nan)
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (101,) + inhomogeneous part.
featurizer.bag(structure)
works fine on the other hand. Can anyone help?