simple example for BandFeaturizer and DOSFeaturizer

Hi,

I have a one column table of 16k superconductor names i.e.

name
Ba0.4K0.6Fe2As2
Ca0.4Ba1.25La1.25Cu3O6.98

As a python nooby, how do I fill up the data frame with things like BandFeaturizer and DOSFeaturizer

I tried to run the example code (from https://groups.google.com/forum/#!topic/matminer/9OKuvxXhjwM). Please see below and I just got a lot of errors… A dead simple example would be very helpful!!! Thank you!!!

Sincerely,

tom

from matminer.data_retrieval.retrieve_MP import MPDataRetrieval
from matminer.featurizers.bandstructure import BandFeaturizer
from pymatgen import MPRester

df_mp1 = MPDataRetrieval().get_dataframe(criteria=‘Li2O’,
properties=[‘formula’])
mpr = MPRester()
df_mp1[“band_structure”] = df_mp1.index.map(
lambda x: mpr.get_bandstructure_by_material_id(x))
df_mp1 = BandFeaturizer().featurize_dataframe(df_mp1, col_id=‘band_structure’)
print(df_mp1)

The errors that I got from:

df_mp1 = MPDataRetrieval().get_dataframe(criteria=‘Li2O’,
properties=[‘formula’])

are below… I gave up after that… Any suggestions on how to get this to work would be appreciated!!

Sincerely,

tom

···

MPRestError Traceback (most recent call last)
~\Anaconda3\lib\site-packages\pymatgen\ext\matproj.py in _make_request(self, sub_url, payload, method, mp_decode)
151 raise MPRestError(“REST query returned with error status code {}”
→ 152 .format(response.status_code))
153

MPRestError: REST query returned with error status code 403

During handling of the above exception, another exception occurred:

MPRestError Traceback (most recent call last)
in ()
1 df_mp1 = MPDataRetrieval().get_dataframe(criteria=‘Li2O’,
----> 2 properties=[‘formula’])

~\Anaconda3\lib\site-packages\matminer\data_retrieval\retrieve_MP.py in get_dataframe(self, criteria, properties, index_mpid, **kwargs)
44 “”"
45 data = self.get_data(criteria=criteria, properties=properties,
—> 46 index_mpid=index_mpid, **kwargs)
47 df = pd.DataFrame(data, columns=properties)
48 for prop in [“dos”, “phonon_dos”,

~\Anaconda3\lib\site-packages\matminer\data_retrieval\retrieve_MP.py in get_data(self, criteria, properties, mp_decode, index_mpid)
87 if index_mpid and “material_id” not in properties:
88 properties.append(“material_id”)
—> 89 data = self.mprester.query(criteria, properties, mp_decode)
90 return data
91

~\Anaconda3\lib\site-packages\pymatgen\ext\matproj.py in query(self, criteria, properties, mp_decode)
735 “properties”: json.dumps(properties)}
736 return self._make_request(“/query”, payload=payload, method=“POST”,
→ 737 mp_decode=mp_decode)
738
739 def submit_structures(self, structures, authors, projects=None,

~\Anaconda3\lib\site-packages\pymatgen\ext\matproj.py in _make_request(self, sub_url, payload, method, mp_decode)
155 msg = “{}. Content: {}”.format(str(ex), response.content)
156 if hasattr(response, “content”) else str(ex)
→ 157 raise MPRestError(msg)
158
159 def get_materials_id_from_task_id(self, task_id):

MPRestError: REST query returned with error status code 403. Content: b’{“valid_response”: false, “error”: “API_KEY is not supplied.”, “version”: {“db”: “2018.11”, “pymatgen”: “2018.11.6”, “rest”: “2.0”}, “created_at”: “2018-11-16T07:10:42.034008”}’

On Thursday, November 15, 2018 at 10:49:36 AM UTC-5, thomas heiman wrote:

Hi,

I have a one column table of 16k superconductor names i.e.

name
Ba0.4K0.6Fe2As2
Ca0.4Ba1.25La1.25Cu3O6.98

As a python nooby, how do I fill up the data frame with things like BandFeaturizer and DOSFeaturizer

I tried to run the example code (from https://groups.google.com/forum/#!topic/matminer/9OKuvxXhjwM). Please see below and I just got a lot of errors… A dead simple example would be very helpful!!! Thank you!!!

Sincerely,

tom

from matminer.data_retrieval.retrieve_MP import MPDataRetrieval
from matminer.featurizers.bandstructure import BandFeaturizer
from pymatgen import MPRester

df_mp1 = MPDataRetrieval().get_dataframe(criteria=‘Li2O’,
properties=[‘formula’])
mpr = MPRester()
df_mp1[“band_structure”] = df_mp1.index.map(
lambda x: mpr.get_bandstructure_by_material_id(x))
df_mp1 = BandFeaturizer().featurize_dataframe(df_mp1, col_id=‘band_structure’)
print(df_mp1)

Hi Thomas,

when retrieving data from the materialsproject.org or any other website through their API (application program interface), you need to provide the API_KEY (like a password) when you instantiate the class (here MPDataRetrieval) OR just define it as an environment variable on your computer. You can get yours here https://materialsproject.org/dashboard (you would need an account).

Best,

Alireza

···

On Nov 16, 2018, at 7:13 AM, thomas heiman [email protected] wrote:

The errors that I got from:

df_mp1 = MPDataRetrieval().get_dataframe(criteria=‘Li2O’,
properties=[‘formula’])

are below… I gave up after that… Any suggestions on how to get this to work would be appreciated!!

Sincerely,

tom


MPRestError Traceback (most recent call last)
~\Anaconda3\lib\site-packages\pymatgen\ext\matproj.py in _make_request(self, sub_url, payload, method, mp_decode)
151 raise MPRestError(“REST query returned with error status code {}”
→ 152 .format(response.status_code))
153

MPRestError: REST query returned with error status code 403

During handling of the above exception, another exception occurred:

MPRestError Traceback (most recent call last)
in ()
1 df_mp1 = MPDataRetrieval().get_dataframe(criteria=‘Li2O’,
----> 2 properties=[‘formula’])

~\Anaconda3\lib\site-packages\matminer\data_retrieval\retrieve_MP.py in get_dataframe(self, criteria, properties, index_mpid, **kwargs)
44 “”"
45 data = self.get_data(criteria=criteria, properties=properties,
—> 46 index_mpid=index_mpid, **kwargs)
47 df = pd.DataFrame(data, columns=properties)
48 for prop in [“dos”, “phonon_dos”,

~\Anaconda3\lib\site-packages\matminer\data_retrieval\retrieve_MP.py in get_data(self, criteria, properties, mp_decode, index_mpid)
87 if index_mpid and “material_id” not in properties:
88 properties.append(“material_id”)
—> 89 data = self.mprester.query(criteria, properties, mp_decode)
90 return data
91

~\Anaconda3\lib\site-packages\pymatgen\ext\matproj.py in query(self, criteria, properties, mp_decode)
735 “properties”: json.dumps(properties)}
736 return self._make_request(“/query”, payload=payload, method=“POST”,
→ 737 mp_decode=mp_decode)
738
739 def submit_structures(self, structures, authors, projects=None,

~\Anaconda3\lib\site-packages\pymatgen\ext\matproj.py in _make_request(self, sub_url, payload, method, mp_decode)
155 msg = “{}. Content: {}”.format(str(ex), response.content)
156 if hasattr(response, “content”) else str(ex)
→ 157 raise MPRestError(msg)
158
159 def get_materials_id_from_task_id(self, task_id):

MPRestError: REST query returned with error status code 403. Content: b’{“valid_response”: false, “error”: “API_KEY is not supplied.”, “version”: {“db”: “2018.11”, “pymatgen”: “2018.11.6”, “rest”: “2.0”}, “created_at”: “2018-11-16T07:10:42.034008”}’

On Thursday, November 15, 2018 at 10:49:36 AM UTC-5, thomas heiman wrote:

Hi,

I have a one column table of 16k superconductor names i.e.

name
Ba0.4K0.6Fe2As2
Ca0.4Ba1.25La1.25Cu3O6.98

As a python nooby, how do I fill up the data frame with things like BandFeaturizer and DOSFeaturizer

I tried to run the example code (from https://groups.google.com/forum/#!topic/matminer/9OKuvxXhjwM). Please see below and I just got a lot of errors… A dead simple example would be very helpful!!! Thank you!!!

Sincerely,

tom

from matminer.data_retrieval.retrieve_MP import MPDataRetrieval
from matminer.featurizers.bandstructure import BandFeaturizer
from pymatgen import MPRester

df_mp1 = MPDataRetrieval().get_dataframe(criteria=‘Li2O’,
properties=[‘formula’])
mpr = MPRester()
df_mp1[“band_structure”] = df_mp1.index.map(
lambda x: mpr.get_bandstructure_by_material_id(x))
df_mp1 = BandFeaturizer().featurize_dataframe(df_mp1, col_id=‘band_structure’)
print(df_mp1)

You received this message because you are subscribed to the Google Groups “matminer” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

For more options, visit https://groups.google.com/d/optout.

Hi Alireza,

Thank you!

Sincerely,

tom

···

On Friday, November 16, 2018 at 10:27:06 AM UTC-5, Alireza Faghaninia wrote:

Hi Thomas,

when retrieving data from the materialsproject.org or any other website through their API (application program interface), you need to provide the API_KEY (like a password) when you instantiate the class (here MPDataRetrieval) OR just define it as an environment variable on your computer. You can get yours here https://materialsproject.org/dashboard (you would need an account).

Best,

Alireza

On Nov 16, 2018, at 7:13 AM, thomas heiman [email protected] wrote:

The errors that I got from:

df_mp1 = MPDataRetrieval().get_dataframe(criteria=‘Li2O’,
properties=[‘formula’])

are below… I gave up after that… Any suggestions on how to get this to work would be appreciated!!

Sincerely,

tom


MPRestError Traceback (most recent call last)
~\Anaconda3\lib\site-packages\pymatgen\ext\matproj.py in _make_request(self, sub_url, payload, method, mp_decode)
151 raise MPRestError(“REST query returned with error status code {}”
→ 152 .format(response.status_code))
153

MPRestError: REST query returned with error status code 403

During handling of the above exception, another exception occurred:

MPRestError Traceback (most recent call last)
in ()
1 df_mp1 = MPDataRetrieval().get_dataframe(criteria=‘Li2O’,
----> 2 properties=[‘formula’])

~\Anaconda3\lib\site-packages\matminer\data_retrieval\retrieve_MP.py in get_dataframe(self, criteria, properties, index_mpid, **kwargs)
44 “”"
45 data = self.get_data(criteria=criteria, properties=properties,
—> 46 index_mpid=index_mpid, **kwargs)
47 df = pd.DataFrame(data, columns=properties)
48 for prop in [“dos”, “phonon_dos”,

~\Anaconda3\lib\site-packages\matminer\data_retrieval\retrieve_MP.py in get_data(self, criteria, properties, mp_decode, index_mpid)
87 if index_mpid and “material_id” not in properties:
88 properties.append(“material_id”)
—> 89 data = self.mprester.query(criteria, properties, mp_decode)
90 return data
91

~\Anaconda3\lib\site-packages\pymatgen\ext\matproj.py in query(self, criteria, properties, mp_decode)
735 “properties”: json.dumps(properties)}
736 return self._make_request(“/query”, payload=payload, method=“POST”,
→ 737 mp_decode=mp_decode)
738
739 def submit_structures(self, structures, authors, projects=None,

~\Anaconda3\lib\site-packages\pymatgen\ext\matproj.py in _make_request(self, sub_url, payload, method, mp_decode)
155 msg = “{}. Content: {}”.format(str(ex), response.content)
156 if hasattr(response, “content”) else str(ex)
→ 157 raise MPRestError(msg)
158
159 def get_materials_id_from_task_id(self, task_id):

MPRestError: REST query returned with error status code 403. Content: b’{“valid_response”: false, “error”: “API_KEY is not supplied.”, “version”: {“db”: “2018.11”, “pymatgen”: “2018.11.6”, “rest”: “2.0”}, “created_at”: “2018-11-16T07:10:42.034008”}’

On Thursday, November 15, 2018 at 10:49:36 AM UTC-5, thomas heiman wrote:

Hi,

I have a one column table of 16k superconductor names i.e.

name
Ba0.4K0.6Fe2As2
Ca0.4Ba1.25La1.25Cu3O6.98

As a python nooby, how do I fill up the data frame with things like BandFeaturizer and DOSFeaturizer

I tried to run the example code (from https://groups.google.com/forum/#!topic/matminer/9OKuvxXhjwM). Please see below and I just got a lot of errors… A dead simple example would be very helpful!!! Thank you!!!

Sincerely,

tom

from matminer.data_retrieval.retrieve_MP import MPDataRetrieval
from matminer.featurizers.bandstructure import BandFeaturizer
from pymatgen import MPRester

df_mp1 = MPDataRetrieval().get_dataframe(criteria=‘Li2O’,
properties=[‘formula’])
mpr = MPRester()
df_mp1[“band_structure”] = df_mp1.index.map(
lambda x: mpr.get_bandstructure_by_material_id(x))
df_mp1 = BandFeaturizer().featurize_dataframe(df_mp1, col_id=‘band_structure’)
print(df_mp1)

You received this message because you are subscribed to the Google Groups “matminer” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

For more options, visit https://groups.google.com/d/optout.