Spaces:
Runtime error
Runtime error
Update utils.py
Browse files
utils.py
CHANGED
|
@@ -11,30 +11,15 @@ import matplotlib.pyplot as plt
|
|
| 11 |
explainer_filename = "explainer.bz2"
|
| 12 |
|
| 13 |
feature_names = ['PROPERTY: Calculated Density (g/cm$^3$)',
|
| 14 |
-
'PROPERTY: Calculated Young modulus (GPa)', '
|
| 15 |
-
'
|
| 16 |
-
'
|
| 17 |
-
'
|
| 18 |
-
'
|
| 19 |
-
'
|
| 20 |
-
'
|
| 21 |
-
'
|
| 22 |
-
'
|
| 23 |
-
'Microstructure BCC+BCC+Laves(C15)', 'Microstructure BCC+FCC',
|
| 24 |
-
'Microstructure BCC+HCP', 'Microstructure BCC+Laves',
|
| 25 |
-
'Microstructure BCC+Laves(C14)', 'Microstructure BCC+Laves(C15)',
|
| 26 |
-
'Microstructure BCC+Laves+Sec.', 'Microstructure BCC+Sec.',
|
| 27 |
-
'Microstructure FCC', 'Microstructure FCC+B2',
|
| 28 |
-
'Microstructure FCC+B2+Sec.', 'Microstructure FCC+BCC',
|
| 29 |
-
'Microstructure FCC+BCC+B2', 'Microstructure FCC+BCC+B2+Sec.',
|
| 30 |
-
'Microstructure FCC+BCC+BCC', 'Microstructure FCC+BCC+Sec.',
|
| 31 |
-
'Microstructure FCC+FCC', 'Microstructure FCC+HCP',
|
| 32 |
-
'Microstructure FCC+HCP+Sec.', 'Microstructure FCC+L12',
|
| 33 |
-
'Microstructure FCC+L12+B2', 'Microstructure FCC+L12+Sec.',
|
| 34 |
-
'Microstructure FCC+Laves', 'Microstructure FCC+Laves(C14)',
|
| 35 |
-
'Microstructure FCC+Laves+Sec.', 'Microstructure FCC+Sec.',
|
| 36 |
-
'Microstructure L12+B2', 'Microstructure Laves(C14)+Sec.',
|
| 37 |
-
'Microstructure OTHER', 'Preprocessing method ANNEAL',
|
| 38 |
'Preprocessing method CAST', 'Preprocessing method OTHER',
|
| 39 |
'Preprocessing method POWDER', 'Preprocessing method WROUGHT',
|
| 40 |
'BCC/FCC/other BCC', 'BCC/FCC/other FCC', 'BCC/FCC/other OTHER',
|
|
@@ -138,7 +123,7 @@ def turn_into_one_hot(X, mapping_dict):
|
|
| 138 |
one_hot = X
|
| 139 |
num_classes_one_hot = {'Num classes microstructure': 45, 'Num classes preprocessing': 5,
|
| 140 |
'Num classes single/multiphase': 3, 'Num classes bcc/fcc/other': 3}
|
| 141 |
-
one_hot["Microstructure One Hot"] = X["PROPERTY: Microstructure"].apply(to_categorical_num_classes_microstructure, num_classes_one_hot=num_classes_one_hot)
|
| 142 |
one_hot["Processing Method One Hot"] = X["PROPERTY: Processing method"].apply(to_categorical_num_classes_processing,
|
| 143 |
num_classes_one_hot=num_classes_one_hot)
|
| 144 |
one_hot["BCC/FCC/other One Hot"] = X["PROPERTY: BCC/FCC/other"].apply(to_categorical_bcc_fcc_other,
|
|
@@ -146,17 +131,18 @@ def turn_into_one_hot(X, mapping_dict):
|
|
| 146 |
one_hot["Single/Multiphase One Hot"] = X["PROPERTY: Single/Multiphase"].apply(to_categorical_single_multiphase,
|
| 147 |
num_classes_one_hot=num_classes_one_hot)
|
| 148 |
|
| 149 |
-
flatten_microstructure = one_hot["Microstructure One Hot"].apply(pd.Series)
|
| 150 |
flatten_processing = one_hot["Processing Method One Hot"].apply(pd.Series)
|
| 151 |
flatten_bcc_fcc_other = one_hot["BCC/FCC/other One Hot"].apply(pd.Series)
|
| 152 |
flatten_single_multiphase = one_hot["Single/Multiphase One Hot"].apply(pd.Series)
|
| 153 |
|
| 154 |
-
one_hot.drop(columns=["Microstructure One Hot",
|
| 155 |
-
|
|
|
|
| 156 |
|
| 157 |
-
for column in flatten_microstructure.columns:
|
| 158 |
-
|
| 159 |
-
|
| 160 |
for column in flatten_processing.columns:
|
| 161 |
one_hot["Preprocessing method " + str(list(mapping_dict["PROPERTY: Processing method"].keys())[int(column)])] = flatten_processing[column]
|
| 162 |
for column in flatten_bcc_fcc_other.columns:
|
|
@@ -164,6 +150,7 @@ def turn_into_one_hot(X, mapping_dict):
|
|
| 164 |
for column in flatten_single_multiphase.columns:
|
| 165 |
one_hot["Single/Multiphase " + str(list(mapping_dict["PROPERTY: Single/Multiphase"].keys())[int(column)])] = flatten_single_multiphase[column]
|
| 166 |
|
| 167 |
-
one_hot = one_hot.drop(columns=["PROPERTY: Microstructure", "Microstructure One Hot",
|
| 168 |
-
|
|
|
|
| 169 |
return one_hot
|
|
|
|
| 11 |
explainer_filename = "explainer.bz2"
|
| 12 |
|
| 13 |
feature_names = ['PROPERTY: Calculated Density (g/cm$^3$)',
|
| 14 |
+
'PROPERTY: Calculated Young modulus (GPa)', 'PROPERTY: Metal Al',
|
| 15 |
+
'PROPERTY: Metal Co', 'PROPERTY: Metal Fe', 'PROPERTY: Metal Ni',
|
| 16 |
+
'PROPERTY: Metal Si', 'PROPERTY: Metal Cr', 'PROPERTY: Metal Nb',
|
| 17 |
+
'PROPERTY: Metal Ti', 'PROPERTY: Metal Mn', 'PROPERTY: Metal V',
|
| 18 |
+
'PROPERTY: Metal Mo', 'PROPERTY: Metal Cu', 'PROPERTY: Metal Ta',
|
| 19 |
+
'PROPERTY: Metal Zr', 'PROPERTY: Metal Hf', 'PROPERTY: Metal W',
|
| 20 |
+
'PROPERTY: Metal Zn', 'PROPERTY: Metal Sn', 'PROPERTY: Metal Re',
|
| 21 |
+
'PROPERTY: Metal C', 'PROPERTY: Metal Pd', 'PROPERTY: Metal Sc',
|
| 22 |
+
'PROPERTY: Metal Y', 'Preprocessing method ANNEAL',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
'Preprocessing method CAST', 'Preprocessing method OTHER',
|
| 24 |
'Preprocessing method POWDER', 'Preprocessing method WROUGHT',
|
| 25 |
'BCC/FCC/other BCC', 'BCC/FCC/other FCC', 'BCC/FCC/other OTHER',
|
|
|
|
| 123 |
one_hot = X
|
| 124 |
num_classes_one_hot = {'Num classes microstructure': 45, 'Num classes preprocessing': 5,
|
| 125 |
'Num classes single/multiphase': 3, 'Num classes bcc/fcc/other': 3}
|
| 126 |
+
#one_hot["Microstructure One Hot"] = X["PROPERTY: Microstructure"].apply(to_categorical_num_classes_microstructure, num_classes_one_hot=num_classes_one_hot)
|
| 127 |
one_hot["Processing Method One Hot"] = X["PROPERTY: Processing method"].apply(to_categorical_num_classes_processing,
|
| 128 |
num_classes_one_hot=num_classes_one_hot)
|
| 129 |
one_hot["BCC/FCC/other One Hot"] = X["PROPERTY: BCC/FCC/other"].apply(to_categorical_bcc_fcc_other,
|
|
|
|
| 131 |
one_hot["Single/Multiphase One Hot"] = X["PROPERTY: Single/Multiphase"].apply(to_categorical_single_multiphase,
|
| 132 |
num_classes_one_hot=num_classes_one_hot)
|
| 133 |
|
| 134 |
+
#flatten_microstructure = one_hot["Microstructure One Hot"].apply(pd.Series)
|
| 135 |
flatten_processing = one_hot["Processing Method One Hot"].apply(pd.Series)
|
| 136 |
flatten_bcc_fcc_other = one_hot["BCC/FCC/other One Hot"].apply(pd.Series)
|
| 137 |
flatten_single_multiphase = one_hot["Single/Multiphase One Hot"].apply(pd.Series)
|
| 138 |
|
| 139 |
+
one_hot.drop(columns=[#"Microstructure One Hot",
|
| 140 |
+
"Processing Method One Hot", "BCC/FCC/other One Hot",
|
| 141 |
+
"Single/Multiphase One Hot"])
|
| 142 |
|
| 143 |
+
#for column in flatten_microstructure.columns:
|
| 144 |
+
# one_hot["Microstructure " + str(
|
| 145 |
+
# list(mapping_dict["PROPERTY: Microstructure"].keys())[int(column)])] = flatten_microstructure[int(column)]
|
| 146 |
for column in flatten_processing.columns:
|
| 147 |
one_hot["Preprocessing method " + str(list(mapping_dict["PROPERTY: Processing method"].keys())[int(column)])] = flatten_processing[column]
|
| 148 |
for column in flatten_bcc_fcc_other.columns:
|
|
|
|
| 150 |
for column in flatten_single_multiphase.columns:
|
| 151 |
one_hot["Single/Multiphase " + str(list(mapping_dict["PROPERTY: Single/Multiphase"].keys())[int(column)])] = flatten_single_multiphase[column]
|
| 152 |
|
| 153 |
+
one_hot = one_hot.drop(columns=[#"PROPERTY: Microstructure", "Microstructure One Hot",
|
| 154 |
+
"BCC/FCC/other One Hot", "Single/Multiphase One Hot",
|
| 155 |
+
"Processing Method One Hot", "PROPERTY: Processing method", "PROPERTY: BCC/FCC/other", "PROPERTY: Single/Multiphase"])
|
| 156 |
return one_hot
|