Error for ElementProperty Source:Magpie

Dear Matminer developers,

thank you for your great work in developing Matminer.
I have encountered an issue retrieving element properties using the magpie database running

pymatgen 2024.1.27
matminer 0.8.0

trying to execute

ep_feat3 = ElementProperty(data_source="magpie", features=["Number",
                "MendeleevNumber",
                "AtomicWeight",
                "MeltingT",
                "Column",
                "Row",
                "CovalentRadius",
                "Electronegativity",
                "NsValence",
                "NpValence",
                "NdValence",
                "NfValence",
                "NValence",
                "NsUnfilled",
                "NpUnfilled",
                "NdUnfilled",
                "NfUnfilled",
                "NUnfilled",
                "GSvolume_pa",
                "GSbandgap",
                "GSmagmom",
                "SpaceGroupNumber",], stats = ["mean"])

gives the error:

File "C:\Users\xxxxx\anaconda3\envs\thesis\Lib\site-packages\matminer\featurizers\composition\composite.py", line 52, in __init__
    self.data_source = MagpieData()
                       ^^^^^^^^^^^^
  File "C:\Users\xxxxx\anaconda3\envs\thesis\Lib\site-packages\matminer\utils\data.py", line 220, in __init__
    self.all_elemental_props[descriptor_name][Element.from_Z(atomic_no).symbol] = prop_value
                                              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xxxxx\anaconda3\envs\thesis\Lib\site-packages\pymatgen\core\periodic_table.py", line 526, in from_Z
    raise ValueError(f"Unexpected atomic number {Z=}")
ValueError: Unexpected atomic number Z=119

It is important to note that this error only appears when using the magpie source, not for any other valid source.

I would be grateful if you could let me know why I encounter this issue.

Best wishes
Frank

I also have the same question. matminer version is 0.9.0.

install pymatgen 2023.3.10

Same issue here, in matminer 0.9.0.

trying to run:

from matminer.featurizers.composition import ElementProperty

leads to the error:

{
	"name": "ValueError",
	"message": "Unexpected atomic number Z=119",
	"stack": "---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[20], line 1
----> 1 from matminer.featurizers.composition import ElementProperty
      3 ep_feat = ElementProperty.from_preset(preset_name=\"magpie\")
      4 df = ep_feat.featurize_dataframe(df, col_id=\"composition\")

File ~/anaconda3/lib/python3.11/site-packages/matminer/featurizers/composition/__init__.py:1
----> 1 from matminer.featurizers.composition.alloy import Miedema, WenAlloys, YangSolidSolution
      2 from matminer.featurizers.composition.composite import ElementProperty, Meredig
      3 from matminer.featurizers.composition.element import (
      4     BandCenter,
      5     ElementFraction,
      6     Stoichiometry,
      7     TMetalFraction,
      8 )

File ~/anaconda3/lib/python3.11/site-packages/matminer/featurizers/composition/alloy.py:16
     13 from pymatgen.core.periodic_table import get_el_sp
     15 from matminer.featurizers.base import BaseFeaturizer
---> 16 from matminer.featurizers.composition.packing import AtomicPackingEfficiency
     17 from matminer.featurizers.utils.stats import PropertyStats
     18 from matminer.utils.data import CohesiveEnergyData, MagpieData, MixingEnthalpy

File ~/anaconda3/lib/python3.11/site-packages/matminer/featurizers/composition/packing.py:13
     10 from sklearn.neighbors import NearestNeighbors
     12 from matminer.featurizers.base import BaseFeaturizer
---> 13 from matminer.featurizers.composition.element import ElementFraction
     14 from matminer.featurizers.utils.stats import PropertyStats
     15 from matminer.utils.data import MagpieData

File ~/anaconda3/lib/python3.11/site-packages/matminer/featurizers/composition/element.py:202
    198     def implementors(self):
    199         return [\"Jiming Chen\", \"Logan Ward\"]
--> 202 class BandCenter(BaseFeaturizer):
    203     \"\"\"
    204     Estimation of absolute position of band center using electronegativity.
    205 
    206     Features
    207         - Band center
    208     \"\"\"
    210     magpie_data = MagpieData()

File ~/anaconda3/lib/python3.11/site-packages/matminer/featurizers/composition/element.py:210, in BandCenter()
    202 class BandCenter(BaseFeaturizer):
    203     \"\"\"
    204     Estimation of absolute position of band center using electronegativity.
    205 
    206     Features
    207         - Band center
    208     \"\"\"
--> 210     magpie_data = MagpieData()
    211     deml_data = DemlData()
    213     def featurize(self, comp):

File ~/anaconda3/lib/python3.11/site-packages/matminer/utils/data.py:217, in MagpieData.__init__(self)
    215 except (ValueError, IndexError):
    216     prop_value = float(\"NaN\")
--> 217 self.all_elemental_props[descriptor_name][Element.from_Z(atomic_no).symbol] = prop_value

File ~/anaconda3/lib/python3.11/site-packages/pymatgen/core/periodic_table.py:526, in ElementBase.from_Z(Z, A)
    524     if data[\"Atomic no\"] == Z and atomic_mass_num == A:
    525         return Element(sym)
--> 526 raise ValueError(f\"Unexpected atomic number {Z=}\")

ValueError: Unexpected atomic number Z=119"
}

Also attempted to try pymatgen in 2023.3.10, but got installation error:

ERROR: Could not build wheels for pymatgen, which is required to install pyproject.toml-based projects

The suggested fix by Whitney worked for me.

Thanks for the reply, may I ask what system you are in and what is the python version?

Windows 11
Python 3.11.5
pymatgen 2023.3.10
matminer 0.9.0

See when I import matminer,mistake as following:ValueError: Unexpected atomic number Z=119。 · Issue #924 · hackingmaterials/matminer · GitHub Error in import composition · Issue #919 · hackingmaterials/matminer · GitHub and Simple composition-based featurization fails due to an upgrade in pymatgen · Issue #920 · hackingmaterials/matminer · GitHub for info on this issue. The problem is essentially that matminer can no longer stay up to date with its dependencies (an impossible task, unless we get a lot of help), but you should always be able to installed the last tested dependencies from the requirements files on GitHub.

Thanks for all the information and the hard work!
I still cannot run it on my mac and have given up trying, but it somehow works in Kaggle environment (python 3.10) with pymatgen in 2023.3.10, and I am satisfied so far.

I am wondering if I would like to contribute, where will be the best place to start?

Hi,

Thanks for your interest in matminer. If you’d like to contribute, probably the best place to start would be to help in resolving some of the dependency issues everyone is experiencing.That said, there is no expectation that this will be fixed by the user community. If you do end up making a beneficial change, please submit a PR and tag @computron. I’ll assign someone to review and merge.