Skip to content

Commit f0c5174

Browse files
committed
test metallic glass feature engineering and model evaluation
- `gfa_from_shallow_ml.py` now performs more versatile model evaluation - rename `negative_examples.py` to `synthetic_non_glasses.py` - `plot_metrics_heatmap.py` visualizes model performance metrics - write GFA metrics to YAML files with different model splits and feature sets
1 parent 0fbe166 commit f0c5174

File tree

5 files changed

+1273
-408
lines changed

5 files changed

+1273
-408
lines changed

examples/dataset_exploration/ward_metallic_glasses/formula_features.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def calc_atomic_size_difference(composition: Composition) -> float:
188188
return ((np.average((1 - radii / mean_radius) ** 2, weights=amounts)) ** 0.5) * 100
189189

190190

191-
def calc_miedema_maximum_heat_of_mixing(composition: Composition) -> float:
191+
def calc_miedema_maximum_heat_of_mixing(composition: Composition) -> float | None:
192192
"""Calculate the maximum heat of mixing feature for a general alloy.
193193
194194
The assumption behind this feature is that the largest magnitude heat of
@@ -202,7 +202,7 @@ def calc_miedema_maximum_heat_of_mixing(composition: Composition) -> float:
202202
if len(composition) < 2:
203203
return 0
204204

205-
mixing_enthalpy = MixingEnthalpy()
205+
mixing_enthalpy = MixingEnthalpy(impute_nan=True)
206206

207207
delta_h_max = delta_h_best = 0
208208
binary_fracs_max = [0, 0] # Initialize with zeros
@@ -214,14 +214,16 @@ def calc_miedema_maximum_heat_of_mixing(composition: Composition) -> float:
214214
delta_h_best = delta_h
215215
binary_fracs_max = binary_fracs
216216

217+
if np.sum(binary_fracs_max) == 0:
218+
return None
217219
return delta_h_best * 2 * np.prod(binary_fracs_max) / np.sum(binary_fracs_max)
218220

219221

220222
def calc_liu_features(
221223
formulas: str | Composition | Sequence[str | Composition],
222224
include: Sequence[str] = (),
223225
binary_liquidus_data: dict[str, interp1d] | None = None,
224-
) -> dict[str, dict[str, float]]:
226+
) -> dict[str, dict[str, float | None]]:
225227
"""Calculate Liu et al.'s (2023) compositional features for metallic glasses.
226228
227229
Args:
@@ -250,7 +252,7 @@ def calc_liu_features(
250252
formulas = [formulas]
251253

252254
results = {}
253-
feature_funcs: dict[str, Callable[[Any], float]] = {
255+
feature_funcs: dict[str, Callable[[Any], float | None]] = {
254256
"mixing_enthalpy": calc_miedema_maximum_heat_of_mixing,
255257
"atomic_size_diff": calc_atomic_size_difference,
256258
}

0 commit comments

Comments
 (0)