Matbench Dielectric Dataset

Exploratory Data Analysis (EDA). MPContribs link

# make-assets supplies matminer
%pip install "pymatviz[make-assets]"
/Users/janosh/.cache/uv/builds-v0/.tmpdKxgDu/bin/python: No module named pip
Note: you may need to restart the kernel to use updated packages.
from typing import get_args

import kemio
from kemio.options import CrystalSystem
from matminer.datasets import load_dataset
from tqdm import tqdm

import pymatviz as pmv


__author__ = "Janosh Riebesell"
__date__ = "2022-03-19"
df_diel = load_dataset("matbench_dielectric")
df_diel[["spg_symbol", "spg_num"]] = [
    struct.get_space_group_info() for struct in tqdm(df_diel["structure"])
]
df_diel["crystal_system"] = df_diel["spg_num"].map(kemio.crystal_system)
  0%|          | 0/4764 [00:00<?, ?it/s]
  3%|▎         | 142/4764 [00:00<00:03, 1189.45it/s]
  5%|▌         | 261/4764 [00:00<00:04, 1057.38it/s]
  8%|▊         | 376/4764 [00:00<00:04, 1077.68it/s]
 10%|█         | 485/4764 [00:00<00:05, 765.72it/s] 
spglib: ssm_get_exact_positions failed.
spglib: get_bravais_exact_positions_and_lattice failed.
spglib: ssm_get_exact_positions failed.
spglib: get_bravais_exact_positions_and_lattice failed.

 14%|█▎        | 654/4764 [00:00<00:04, 1014.71it/s]
 16%|█▌        | 770/4764 [00:00<00:04, 933.89it/s] 
 19%|█▊        | 890/4764 [00:00<00:04, 953.39it/s]
 23%|██▎       | 1085/4764 [00:01<00:03, 1193.83it/s]
 25%|██▌       | 1214/4764 [00:01<00:04, 878.17it/s] 
 28%|██▊       | 1319/4764 [00:01<00:03, 906.89it/s]
 30%|██▉       | 1423/4764 [00:01<00:03, 852.59it/s]
 32%|███▏      | 1517/4764 [00:01<00:03, 835.90it/s]
 34%|███▎      | 1607/4764 [00:01<00:04, 720.02it/s]
 36%|███▌      | 1694/4764 [00:01<00:04, 753.65it/s]
 38%|███▊      | 1827/4764 [00:02<00:03, 891.07it/s]
spglib: ssm_get_exact_positions failed.
spglib: get_bravais_exact_positions_and_lattice failed.

 41%|████      | 1949/4764 [00:02<00:02, 970.72it/s]
 45%|████▍     | 2127/4764 [00:02<00:02, 1172.72it/s]
 48%|████▊     | 2266/4764 [00:02<00:02, 1223.76it/s]
 50%|█████     | 2393/4764 [00:02<00:02, 1111.36it/s]
 53%|█████▎    | 2509/4764 [00:02<00:02, 1034.63it/s]
 55%|█████▍    | 2617/4764 [00:02<00:02, 919.89it/s] 
 57%|█████▋    | 2714/4764 [00:02<00:02, 771.18it/s]
 59%|█████▉    | 2808/4764 [00:03<00:02, 808.38it/s]
 61%|██████▏   | 2924/4764 [00:03<00:02, 892.08it/s]
 63%|██████▎   | 3019/4764 [00:03<00:02, 852.45it/s]
 65%|██████▌   | 3109/4764 [00:03<00:01, 841.69it/s]
 68%|██████▊   | 3221/4764 [00:03<00:01, 895.23it/s]
 70%|██████▉   | 3313/4764 [00:03<00:02, 656.16it/s]
 72%|███████▏  | 3422/4764 [00:03<00:01, 750.69it/s]
 74%|███████▎  | 3508/4764 [00:03<00:01, 747.14it/s]
 75%|███████▌  | 3591/4764 [00:04<00:01, 738.22it/s]
 78%|███████▊  | 3715/4764 [00:04<00:01, 863.87it/s]
 80%|████████  | 3824/4764 [00:04<00:01, 889.15it/s]
 82%|████████▏ | 3918/4764 [00:04<00:01, 828.94it/s]
 84%|████████▍ | 4005/4764 [00:04<00:01, 731.56it/s]
 86%|████████▌ | 4083/4764 [00:04<00:00, 731.25it/s]
 87%|████████▋ | 4159/4764 [00:04<00:00, 678.53it/s]
 89%|████████▉ | 4231/4764 [00:04<00:00, 678.87it/s]
 91%|█████████▏| 4351/4764 [00:05<00:00, 811.23it/s]
 95%|█████████▍| 4504/4764 [00:05<00:00, 988.79it/s]
 97%|█████████▋| 4606/4764 [00:05<00:00, 544.24it/s]
 98%|█████████▊| 4685/4764 [00:05<00:00, 527.84it/s]
100%|█████████▉| 4755/4764 [00:05<00:00, 556.94it/s]
100%|██████████| 4764/4764 [00:05<00:00, 819.41it/s]

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

title = "Elements in Matbench Dielectric"
pmv.ptable_heatmap(df_diel["formula"], log=True, color_bar={"title": title}).show()
No description has been provided for this image
_ = df_diel.hist(bins=80, log=True, figsize=(20, 4), layout=(1, 3))
No description has been provided for this image
pmv.spacegroup_bar_plot(df_diel["spg_num"])
No description has been provided for this image
pmv.spacegroup_sunburst(df_diel["spg_num"], label_text="label+percent")
No description has been provided for this image
# Refractive index distribution by crystal system
crystal_systems = get_args(CrystalSystem)  # ordered triclinic to cubic
pmv.box_plot(
    [
        {"y": df_group["n"], "label": cry_sys}
        for cry_sys, df_group in sorted(
            df_diel.groupby("crystal_system"),
            key=lambda x: crystal_systems.index(x[0]),
        )
    ],
    kind="violin",
    title="Refractive index distribution by crystal system",
    show_legend=False,
    y_axis={"label": "Refractive index n"},
)
No description has been provided for this image