Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'DensityFeatures' object has no attribute 'desired_features' #864

Closed
pbenner opened this issue Aug 29, 2022 · 1 comment · Fixed by #896
Closed

AttributeError: 'DensityFeatures' object has no attribute 'desired_features' #864

pbenner opened this issue Aug 29, 2022 · 1 comment · Fixed by #896

Comments

@pbenner
Copy link

pbenner commented Aug 29, 2022

The following holds for DensityFeatures and GlobalSymmetryFeatures:

>>> import matminer
>>> matminer.__version__
'0.7.8'
>>> from matminer.featurizers.structure import DensityFeatures
>>> d = DensityFeatures()
>>> d
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/pbenner/.local/opt/anaconda3/lib/python3.8/site-packages/sklearn/base.py", line 279, in __repr__
    repr_ = pp.pformat(self)
  File "/home/pbenner/.local/opt/anaconda3/lib/python3.8/pprint.py", line 153, in pformat
    self._format(object, sio, 0, 0, {}, 0)
  File "/home/pbenner/.local/opt/anaconda3/lib/python3.8/pprint.py", line 170, in _format
    rep = self._repr(object, context, level)
  File "/home/pbenner/.local/opt/anaconda3/lib/python3.8/pprint.py", line 404, in _repr
    repr, readable, recursive = self.format(object, context.copy(),
  File "/home/pbenner/.local/opt/anaconda3/lib/python3.8/site-packages/sklearn/utils/_pprint.py", line 189, in format
    return _safe_repr(
  File "/home/pbenner/.local/opt/anaconda3/lib/python3.8/site-packages/sklearn/utils/_pprint.py", line 440, in _safe_repr
    params = _changed_params(object)
  File "/home/pbenner/.local/opt/anaconda3/lib/python3.8/site-packages/sklearn/utils/_pprint.py", line 93, in _changed_params
    params = estimator.get_params(deep=False)
  File "/home/pbenner/.local/opt/anaconda3/lib/python3.8/site-packages/sklearn/base.py", line 211, in get_params
    value = getattr(self, key)
AttributeError: 'DensityFeatures' object has no attribute 'desired_features'

Bugfix:

>>> d.desired_features=d.features
>>> d
DensityFeatures(desired_features=['density', 'vpa', 'packing fraction'])
@ml-evs
Copy link
Collaborator

ml-evs commented Oct 19, 2022

Also running into this and would appreciate a fix; this seems to be our only compat failure when upgrading from 0.6.5 -> 0.7.8.

Underlying issue is that the scikit-learn __repr__ now tries to introspect child classes when making pretty output, could just override this with a __repr__ on matminer's BaseFeaturizer to avoid having to exhaustively test all featurizers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants