-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathutils.py
More file actions
66 lines (55 loc) · 2.96 KB
/
Copy pathutils.py
File metadata and controls
66 lines (55 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import numpy as np
import pandas as pd
import torch
from CBFV import composition
def set_seeds(seed: int = 42):
"""Set random seeds for reproducibility."""
np.random.seed(seed)
torch.manual_seed(seed)
def featurize_data(data):
"""Featurize the data using CBFV and filter out irrelevant features."""
data.columns = ["formula", "target", "load"]
X, y, _, _ = composition.generate_features(data)
# indices of features found to be most relevant for prediction
indices = [15, 235, 11, 56, 220, 4, 14, 84, 16, 58, 48, 34]
X = X.iloc[:, indices]
X["load"] = data["load"].values
return X, y
# fmt: off
# hardness = np.array(
# [15.03, 33.5, 12.01, 4.00, 3.58, 42.02, 45., 4.9, 7.06,
# 8.73, 1.27, 2.75, 3.97, 2.99, 1.47, 46.46, 39.73, 38.82,
# 8.38, 8.14, 16.8, 21.5, 22.2, 21.8, 21.6, 22.1, 20.69,
# 14.71, 7.02, 27.5, 26.1, 6.24, 6.12, 6.32, 5.58, 6.9,
# 4.41, 3.92, 4.81, 1.27, 7.45, 4.9, 11.1, 26.09, 7.01,
# 5.88, 6.28, 6.86, 39.95, 37.39, 38.39, 39.48, 8.4, 9.11,
# 5.7, 7.72, 15., 5.7, 5.8, 7.2, 12.4, 3.89, 4.36,
# 37.9, 7.3, 4.78, 8.05, 4.33, 5.2, 44.25, 39.58, 32.29,
# 8.3, 11.2, 45.08, 38.11, 33., 14.06, 13.53, 20.3, 20.5,
# 12.07, 19.4, 12.75, 0.53, 12.26, 4.41, 3.73, 9.11, 6.8,
# 9.1, 10.42, 9.65, 10.42, 7.8, 4.61, 4.9, 19.61, 14.22,
# 5.05, 2.54, 2.7, 1.73, 24.22, 38.03, 10.79, 12.75, 16.57,
# 16.18, 35.08, 17.16, 22.56, 11.08, 2.06, 9.22, 10.2, 11.38,
# 10.79, 11.03, 10.79, 16.74, 35.04, 35.91, 35.85, 36.88, 37.52,
# 39.63, 36.07, 38.44, 31.84, 35.19, 5.88, 8.2, 19., 20.,
# 11., 4.71, 24.52, 5.51, 29., 44.7, 41.24, 30.5, 39.91,
# 28.5, 36.93, 33.79, 23.58, 22.56, 7.45, 22.65, 5.6, 5.75,
# 5.51, 3.85, 6.28, 39.89, 37.28, 34.41, 15.5, 2.04, 2.98,
# 9.51, 26., 3.01, 5.82, 18., 19.91, 5.1, 21.2, 5.2,
# 7.81, 9.02, 7.9, 7., 9.81, 9.81, 7.73, 31.33, 32.24,
# 29.07, 33.43, 32.28, 34.73, 34., 28.58, 32.33, 34.46, 33.02,
# 34.53, 43., 36.9, 33.72, 35.24, 32.77, 36.29, 33.22, 34.78,
# 31.55, 32.33, 32.88, 44.1, 46.7, 29.86, 33.31, 34.36, 35.83,
# 35.36, 32.11, 36.3, 28.81, 35.61, 37.01, 20.5, 34.07, 25.93,
# 38., 29.95, 32.46, 30.9, 35.9, 36.5, 32.01, 32.39, 36.4,
# 37.4, 35.37, 33.87, 38.41, 33.06, 33.95, 35.76, 32.49, 33.9,
# 34.16, 33.64, 32.94, 25.48, 30.22, 34.11, 32.46, 5.16, 34.64,
# 34.4, 33.14, 32.99, 37.15, 33.16, 31.13, 30.42, 35.75, 40.71,
# 41.2, 43.79, 38.51, 36.5, 33.8, 33.9, 35.5, 36., 33.5,
# 7.84, 39.41, 34.5, 36.9, 36.4, 38.85, 35.1, 34.4, 8.95,
# 35., 7.68, 7.35, 4.31, 5.9, 11.7, 10.33, 35.2, 34.9,
# 7.4, 5.7, 7.86, 10.74, 6.52, 13., 6.37, 3.6, 11.1]
# )
hardness = pd.read_csv("data/candidate_ans.csv", usecols=['hardness']).values.flatten()
def measure_hardness(material_idex, hardness=hardness):
return hardness[material_idex]