Matbench Perovskite Dataset

Exploratory Data Analysis (EDA). MPContribs link

Matbench v0.1 dataset for predicting formation energy from crystal structure with 18,928 entries, adapted from an original dataset by Castelli et al.

The target is the heat of formation of the entire 5-atom perovskite cell in eV as calculated by RPBE GGA-DFT. The oxygen reference state was computed from oxygen's chemical potential in water vapor, not as oxygen molecules, to reflect the application these perovskites were studied for.

# make-assets supplies matminer
%pip install "pymatviz[make-assets]"
/Users/janosh/.cache/uv/builds-v0/.tmppPpFhX/bin/python: No module named pip
Note: you may need to restart the kernel to use updated packages.
import kemio
import pandas as pd
from matminer.datasets import load_dataset
from tqdm import tqdm

import pymatviz as pmv


__author__ = "Janosh Riebesell"
__date__ = "2022-03-19"
df_perov = load_dataset("matbench_perovskites")

moyo_spg_num_key = "moyopy_spg_num"
df_perov[moyo_spg_num_key] = [
    struct.get_symmetry_dataset(backend="moyopy", return_raw_dataset=True).number
    for struct in tqdm(df_perov["structure"])
]
df_perov["volume"] = df_perov["structure"].map(lambda struct: struct.volume)

df_perov["formula"] = df_perov["structure"].map(lambda cryst: cryst.formula)

df_perov["crystal_system"] = df_perov[moyo_spg_num_key].map(kemio.crystal_system)
Fetching matbench_perovskites.json.gz from https://ml.materialsproject.org/projects/matbench_perovskites.json.gz to /Users/janosh/.cache/uv/archive-v0/1_wltjNhVoTmZT20/lib/python3.14/site-packages/matminer/datasets/matbench_perovskites.json.gz
Fetching https://ml.materialsproject.org/projects/matbench_perovskites.json.gz in MB:   0%|          | 0.0/4.193112 [00:00<?, ?MB/s]
Fetching https://ml.materialsproject.org/projects/matbench_perovskites.json.gz in MB: 4.194304MB [00:00, 1145.03MB/s]               

  0%|          | 0/18928 [00:00<?, ?it/s]
  0%|          | 76/18928 [00:00<00:25, 737.46it/s]
  2%|▏         | 406/18928 [00:00<00:08, 2225.67it/s]
  4%|▍         | 787/18928 [00:00<00:06, 2916.87it/s]
  6%|▌         | 1127/18928 [00:00<00:05, 3102.25it/s]
  8%|▊         | 1473/18928 [00:00<00:05, 3019.99it/s]
 10%|▉         | 1806/18928 [00:00<00:05, 3115.32it/s]
 11%|█         | 2119/18928 [00:00<00:06, 2749.43it/s]
 13%|█▎        | 2402/18928 [00:00<00:06, 2645.87it/s]
 15%|█▍        | 2816/18928 [00:00<00:05, 3062.59it/s]
 17%|█▋        | 3131/18928 [00:01<00:05, 2852.94it/s]
 18%|█▊        | 3468/18928 [00:01<00:05, 2993.98it/s]
 21%|██        | 3936/18928 [00:01<00:04, 3459.43it/s]
 23%|██▎       | 4291/18928 [00:01<00:04, 3164.90it/s]
 25%|██▍       | 4639/18928 [00:01<00:04, 3151.60it/s]
 26%|██▌       | 4962/18928 [00:01<00:04, 2968.68it/s]
 28%|██▊       | 5265/18928 [00:01<00:04, 2736.76it/s]
 30%|██▉       | 5611/18928 [00:01<00:04, 2903.09it/s]
 31%|███       | 5908/18928 [00:02<00:04, 2911.96it/s]
 33%|███▎      | 6254/18928 [00:02<00:04, 3062.54it/s]
 36%|███▌      | 6768/18928 [00:02<00:03, 3645.56it/s]
 38%|███▊      | 7139/18928 [00:02<00:03, 3165.35it/s]
 39%|███▉      | 7471/18928 [00:02<00:03, 3036.49it/s]
 41%|████      | 7786/18928 [00:02<00:03, 2914.37it/s]
 43%|████▎     | 8226/18928 [00:02<00:03, 2749.97it/s]
 45%|████▍     | 8510/18928 [00:02<00:04, 2568.89it/s]
 46%|████▋     | 8773/18928 [00:03<00:04, 2280.71it/s]
 48%|████▊     | 9055/18928 [00:03<00:04, 2399.82it/s]
 49%|████▉     | 9303/18928 [00:03<00:04, 2357.31it/s]
 50%|█████     | 9544/18928 [00:03<00:05, 1715.88it/s]
 52%|█████▏    | 9863/18928 [00:03<00:04, 2024.80it/s]
 53%|█████▎    | 10097/18928 [00:03<00:04, 2074.60it/s]
 56%|█████▌    | 10602/18928 [00:03<00:02, 2805.22it/s]
 58%|█████▊    | 11024/18928 [00:03<00:02, 3165.59it/s]
 60%|██████    | 11369/18928 [00:04<00:02, 2586.49it/s]
 62%|██████▏   | 11664/18928 [00:04<00:02, 2461.77it/s]
 63%|██████▎   | 11968/18928 [00:04<00:02, 2579.54it/s]
 65%|██████▍   | 12247/18928 [00:04<00:02, 2541.46it/s]
 66%|██████▌   | 12539/18928 [00:04<00:02, 2499.14it/s]
 68%|██████▊   | 12799/18928 [00:04<00:02, 2361.99it/s]
 70%|███████   | 13264/18928 [00:04<00:01, 2946.39it/s]
 72%|███████▏  | 13574/18928 [00:04<00:01, 2797.93it/s]
 73%|███████▎  | 13865/18928 [00:05<00:01, 2645.07it/s]
 75%|███████▍  | 14193/18928 [00:05<00:01, 2809.00it/s]
 77%|███████▋  | 14483/18928 [00:05<00:01, 2814.49it/s]
 78%|███████▊  | 14795/18928 [00:05<00:01, 2897.02it/s]
 80%|███████▉  | 15090/18928 [00:05<00:01, 2775.92it/s]
 81%|████████  | 15372/18928 [00:05<00:01, 2762.17it/s]
 84%|████████▍ | 15878/18928 [00:05<00:00, 3411.60it/s]
 86%|████████▌ | 16225/18928 [00:05<00:00, 2931.79it/s]
 88%|████████▊ | 16597/18928 [00:05<00:00, 3127.55it/s]
 89%|████████▉ | 16924/18928 [00:06<00:00, 3089.78it/s]
 91%|█████████ | 17243/18928 [00:06<00:00, 2773.82it/s]
 93%|█████████▎| 17532/18928 [00:06<00:00, 2395.98it/s]
 94%|█████████▍| 17861/18928 [00:06<00:00, 2610.17it/s]
 96%|█████████▌| 18138/18928 [00:06<00:00, 2560.37it/s]
 97%|█████████▋| 18405/18928 [00:06<00:00, 2040.70it/s]
 98%|█████████▊| 18632/18928 [00:06<00:00, 1895.20it/s]
100%|█████████▉| 18858/18928 [00:07<00:00, 1968.73it/s]
100%|██████████| 18928/18928 [00:07<00:00, 2657.94it/s]

pmv.widget_grid(
    {
        idx: pmv.structure(structure=struct)
        for idx, struct in df_perov["structure"].iloc[:12].items()
    },
    n_cols=4,
)
0
No description has been provided for this image
1
No description has been provided for this image
2
No description has been provided for this image
3
No description has been provided for this image
4
No description has been provided for this image
5
No description has been provided for this image
6
No description has been provided for this image
7
No description has been provided for this image
8
No description has been provided for this image
9
No description has been provided for this image
10
No description has been provided for this image
11
No description has been provided for this image
# Matbench Perovskites Formation Energy Distribution
widget = pmv.histogram(
    df_perov["e_form"], bins=300, x_axis={"label": "Formation Energy (eV/atom)"}
)
widget.ref_lines = [
    {"type": "vertical", "x": 0, "style": {"color": "black", "width": 2, "dash": "4 4"}}
]
widget
No description has been provided for this image
widget = pmv.ptable_heatmap(
    df_perov["formula"],
    exclude_elements=["O"],
    heat_mode="percent",
    color_bar={"title": "Elements in Matbench Perovskites dataset"},
)
widget.show()
No description has been provided for this image
# Crystal systems in Matbench Perovskites
crys_sys_counts = df_perov["crystal_system"].value_counts()
pmv.bar_plot(
    [{"x": crys_sys_counts.index.astype(str).to_list(), "y": crys_sys_counts}],
    x_axis={"label": "Crystal System"},
    y_axis={"label": "Count"},
)
No description has been provided for this image
# Matbench Perovskites Formation Energy vs. Volume
pmv.scatter_plot(
    [
        {
            "x": df_perov["volume"],
            "y": df_perov["e_form"],
            "color_values": df_perov[moyo_spg_num_key],
            "markers": "points",
        }
    ],
    x_axis={"label": "Volume (ų)"},
    y_axis={"label": "Formation Energy (eV/atom)"},
    color_bar={"title": "Space group number"},
)
No description has been provided for this image
pmv.spacegroup_sunburst(df_perov[moyo_spg_num_key], label_text="label+percent")
No description has been provided for this image
# originally generated with aviary calling out to Aflow CLI, takes ~6h when running
# uninterrupted. see https://github.com/CompRhys/aviary/blob/14b2ab204ec/aviary/wren/utils.py#L158
# rows follow the Matbench dataset order, to_numpy raises if the lengths differ
aflow_protostructure_key = "aflow_wyckoff"
df_perov[aflow_protostructure_key] = pd.read_csv(
    # 2022-05-17-matbench_perovskites_aflow_labels.csv
    "https://docs.google.com/spreadsheets/d/"
    "1Mhk5t3Ac_aHOTWMjZ1DL4LtUBIB21nWt7oy2t3M-fQU/export?format=csv"
)[aflow_protostructure_key].to_numpy()

extract spacegroups and crystal systems from Aflow Wyckoff labels

aflow_spg_num_key = "aflow_spg_num"
df_perov[aflow_spg_num_key] = (
    df_perov[aflow_protostructure_key].str.split("_").str[2].astype(int)
)
df_perov["aflow_crys_sys"] = df_perov[aflow_spg_num_key].map(kemio.crystal_system)

Compare the spacegroups and crystal systems assigned by moyopy and AFLOW.

AFLOW uses an adaptive symmetry algorithm, so its assignments can differ from moyopy.

for moyo_col, aflow_col in (
    (moyo_spg_num_key, aflow_spg_num_key),
    ("crystal_system", "aflow_crys_sys"),
):
    df_compare = df_perov[[moyo_col, aflow_col]].set_axis(["Moyopy", "AFLOW"], axis=1)
    pmv.sankey(df_compare, "Moyopy", "AFLOW").show()
No description has been provided for this image
No description has been provided for this image