Skip to content

Commit cddda31

Browse files
committed
add date_published field to model metadata
1 parent d5cd5d7 commit cddda31

File tree

13 files changed

+48
-35
lines changed

13 files changed

+48
-35
lines changed

.gitattributes

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# exclude Svelte files in figures/ when calculating repo language statistics on GitHub
2-
figures/* linguist-generated
1+
# exclude generated plot files when calculating repo language statistics on GitHub
2+
*/figs/* linguist-generated
33
data/**/*.svelte linguist-generated

matbench_discovery/data.py

+13-11
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,13 @@
2626

2727
class Files(dict): # type: ignore
2828
"""Files instance inherits from dict so that .values(), items(), etc. are supported
29-
but also allows accessing attributes by dot notation. E.g. FILES.wbm_summary
30-
instead of FILES["wbm_summary"]. This enables tab completion in IDEs and
31-
auto-updating attribute names across the code base when changing the name of an
32-
attribute.
33-
Every subclass must set the _root attribute to a path that serves as the root
34-
directory w.r.t. which all files will be turned into absolute paths.
35-
The _key_map attribute can be used to map attribute names to different names in the
36-
dict. This is useful if you want to have keys that are not valid Python identifiers.
29+
but also allows accessing attributes by dot notation. E.g. FILES.wbm_summary instead
30+
of FILES["wbm_summary"]. This enables tab completion in IDEs and auto-updating
31+
attribute names across the code base when changing the name of an attribute. Every
32+
subclass must set the _root attribute to a path that serves as the root directory
33+
w.r.t. which all files will be turned into absolute paths. The _key_map attribute
34+
can be used to map attribute names to different names in the dict. Useful if you
35+
want to have keys like 'foo+bar' that are not valid Python identifiers.
3736
"""
3837

3938
def __init__(self) -> None:
@@ -246,13 +245,16 @@ def glob_to_df(
246245

247246

248247
def load_df_wbm_preds(
249-
models: Sequence[str], pbar: bool = True, id_col: str = "material_id", **kwargs: Any
248+
models: Sequence[str] = (*PRED_FILES,),
249+
pbar: bool = True,
250+
id_col: str = "material_id",
251+
**kwargs: Any,
250252
) -> pd.DataFrame:
251253
"""Load WBM summary dataframe with model predictions from disk.
252254
253255
Args:
254-
models (Sequence[str]): Model names must be keys of the dict
255-
matbench_discovery.data.PRED_FILES.
256+
models (Sequence[str], optional): Model names must be keys of
257+
matbench_discovery.data.PRED_FILES. Defaults to all models.
256258
pbar (bool, optional): Whether to show progress bar. Defaults to True.
257259
id_col (str, optional): Column to set as df.index. Defaults to "material_id".
258260
**kwargs: Keyword arguments passed to glob_to_df().

matbench_discovery/preds.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,11 @@
1010
__author__ = "Janosh Riebesell"
1111
__date__ = "2023-02-04"
1212

13-
models = sorted(
14-
"Wrenformer, CGCNN+P, Voronoi Random Forest, MEGNet, M3GNet + MEGNet, "
15-
"BOWSR + MEGNet".split(", ")
16-
)
1713
e_form_col = "e_form_per_atom_mp2020_corrected"
1814
each_true_col = "e_above_hull_mp2020_corrected_ppd_mp"
1915
each_pred_col = "e_above_hull_pred"
2016

21-
df_wbm = load_df_wbm_preds(list(PRED_FILES)).round(3)
22-
drop_cols = {*PRED_FILES} - {*models}
17+
df_wbm = load_df_wbm_preds().round(3)
2318

2419

2520
df_metrics = pd.DataFrame()

models/bowsr/metadata.yml

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ model_name: BOWSR + MEGNet
22
model_version: 2022.9.20
33
matbench_discovery_version: 1.0
44
date_added: "2022-11-17"
5+
date_published: "2021-04-20"
56
authors:
67
- name: Yunxing Zuo
78
affiliation: UC San Diego

models/cgcnn/metadata.yml

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
model_version: 0.1.0 # the aviary version
33
matbench_discovery_version: 1.0
44
date_added: "2022-12-28"
5+
date_published: "2017-10-27"
56
authors:
67
- name: Tian Xie
78
@@ -34,6 +35,7 @@
3435
model_version: 0.1.0 # the aviary version
3536
matbench_discovery_version: 1.0
3637
date_added: "2023-02-03"
38+
date_published: "2022-02-28"
3739
authors:
3840
- name: Jason B. Gibson
3941
affiliation: University of Florida

models/m3gnet/metadata.yml

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
model_version: 2022.9.20
33
matbench_discovery_version: 1.0
44
date_added: "2022-09-20"
5+
date_published: "2022-02-05"
56
authors:
67
- name: Chi Chen
78
affiliation: UC San Diego
@@ -30,6 +31,7 @@
3031
model_version: 2022.9.20
3132
matbench_discovery_version: 1.0
3233
date_added: "2023-02-03"
34+
date_published: "2022-02-05"
3335
authors:
3436
- name: Chi Chen
3537
affiliation: UC San Diego

models/megnet/metadata.yml

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ model_name: MEGNet
22
model_version: 2022.9.20
33
matbench_discovery_version: 1.0
44
date_added: "2022-11-14"
5+
date_published: "2021-12-18"
56
authors:
67
- name: Chi Chen
78
affiliation: UC San Diego

models/voronoi/metadata.yml

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ model_name: Voronoi Random Forest
22
model_version: 1.1.2 # scikit learn version which implements the random forest
33
matbench_discovery_version: 1.0
44
date_added: "2022-11-26"
5+
date_published: "2017-07-14"
56
authors:
67
- name: Logan Ward
78
affiliation: Argonne National Laboratory

models/wrenformer/metadata.yml

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ model_name: Wrenformer
22
model_version: 0.1.0 # the aviary version
33
matbench_discovery_version: 1.0
44
date_added: "2022-11-26"
5+
date_published: "2021-06-21"
56
authors:
67
- name: Janosh Riebesell
78
affiliation: University of Cambridge, Lawrence Berkeley National Laboratory

scripts/scatter_e_above_hull_models.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
df_melt = df_wbm.melt(
3434
id_vars=hover_cols,
3535
var_name=facet_col,
36-
value_vars=df_metrics.T.MAE.nsmallest(6).index,
36+
# value_vars=df_metrics.T.MAE.nsmallest(6).index, # top 6 models by MAE
37+
value_vars=list(df_metrics), # all models
3738
value_name=e_form_pred_col,
3839
)
3940

@@ -112,14 +113,14 @@
112113
x=each_true_col,
113114
y=each_pred_col,
114115
facet_col=facet_col,
115-
facet_col_wrap=2,
116+
facet_col_wrap=4,
116117
facet_col_spacing=0.02,
117118
facet_row_spacing=0.04,
118119
hover_data=hover_cols,
119120
hover_name=df_wbm.index.name,
120121
color=clf_col,
121122
color_discrete_map=clf_color_map,
122-
opacity=0.4,
123+
# opacity=0.4,
123124
range_x=(-xy_max, xy_max),
124125
range_y=(-xy_max, xy_max),
125126
)
@@ -131,7 +132,7 @@
131132
# iterate over subplots and set new title
132133
for idx, anno in enumerate(fig.layout.annotations, 1):
133134
traces = [t for t in fig.data if t.xaxis == f"x{idx if idx > 1 else ''}"]
134-
assert len(traces) == 4, f"Expected 4 traces, got {len(traces)=}"
135+
assert len(traces) in (0, 4), f"Plots be empty or have 4 traces, got {len(traces)=}"
135136

136137
model = anno.text.split("=", 1)[1]
137138
assert model in df_wbm, f"Unexpected {model=} not in {list(df_wbm)=}"
@@ -182,9 +183,9 @@
182183
fig.update_xaxes(nticks=5)
183184
fig.update_yaxes(nticks=5)
184185

185-
# remove legend title and place legend centered above subplots
186+
# remove legend title and place legend centered above subplots, increase marker size
186187
fig.layout.legend.update(
187-
title="", orientation="h", x=0.5, xanchor="center", y=1.1, yanchor="top"
188+
title="", orientation="h", x=0.5, xanchor="center", y=1.2, itemsizing="constant"
188189
)
189190

190191
# fig.update_layout(yaxis=dict(scaleanchor="x", scaleratio=1))
@@ -211,4 +212,4 @@
211212
# %%
212213
img_name = "each-scatter-models"
213214
save_fig(fig, f"{STATIC}/{img_name}.webp", scale=4, width=600, height=800)
214-
save_fig(fig, f"{ROOT}/tmp/figures/{img_name}.pdf")
215+
save_fig(fig, f"{ROOT}/tmp/figures/{img_name}.pdf", width=1200)

site/src/lib/ModelCard.svelte

+14-8
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,18 @@
4343
{/each}
4444
</nav>
4545
<p>
46-
<span
47-
><Icon icon="ion:ios-calendar" inline />
48-
{data.date_added}
46+
<span title="Date added">
47+
<Icon icon="ion:ios-calendar" inline />
48+
Added {data.date_added}
4949
</span>
50-
<span
51-
><Icon icon="carbon:version" inline />
50+
{#if data.date_published}
51+
<span title="Date published">
52+
<Icon icon="ri:calendar-check-line" inline />
53+
Published {data.date_published}
54+
</span>
55+
{/if}
56+
<span>
57+
<Icon icon="carbon:version" inline />
5258
Benchmark version: {data.matbench_discovery_version}
5359
</span>
5460
<span>
@@ -176,9 +182,9 @@
176182
place-items: center;
177183
}
178184
p {
179-
display: flex;
180-
gap: 3pt 12pt;
181-
flex-wrap: wrap;
185+
display: grid;
186+
gap: 3pt;
187+
grid-template-columns: 1fr 1fr;
182188
}
183189
div {
184190
display: grid;

site/src/lib/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export type ModelMetadata = {
1111
model_version: string
1212
matbench_discovery_version: string
1313
date_added: string
14+
date_published?: string
1415
authors: Author[]
1516
repo: string
1617
url?: string

tests/test_plots.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
)
1717

1818
AxLine = Literal["x", "y", "xy", ""]
19-
models = ["Wrenformer", "CGCNN", "Voronoi Random Forest"]
19+
models = ["MEGNet", "CGCNN", "Voronoi Random Forest"]
2020
df_wbm = load_df_wbm_preds(models, nrows=100)
2121
each_true_col = "e_above_hull_mp2020_corrected_ppd_mp"
2222
each_pred_col = "e_above_hull_pred"

0 commit comments

Comments
 (0)