Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -135,17 +135,13 @@ def predict_from_tuple(in1, in2, in3, in4, in5, request: gr.Request):
|
|
135 |
print("One hot columns are ", one_hot.columns)
|
136 |
return predict(one_hot, request)
|
137 |
|
138 |
-
hardness_target
|
139 |
-
ys_target = 2
|
140 |
-
|
141 |
-
def fit_outputs(x):
|
142 |
predictions = predict(x)
|
143 |
error_hardness = np.sqrt(np.square(predictions[0]-hardness_target))
|
144 |
error_ys = np.sqrt(np.square(predictions[2]-ys_target))
|
145 |
print(predictions, hardness_target, ys_target, error_hardness, error_ys)
|
146 |
return error_hardness + error_ys
|
147 |
|
148 |
-
|
149 |
def predict_inverse(hardness_target, ys_target, request: gr.Request):
|
150 |
|
151 |
continuous_variables = ['PROPERTY: Calculated Density (g/cm$^3$)',
|
@@ -176,6 +172,9 @@ def predict_inverse(hardness_target, ys_target, request: gr.Request):
|
|
176 |
constraints.append({'name': constraint + "+1", 'constraint': sum_string + '-1'})
|
177 |
constraints.append({'name': constraint + "-1", 'constraint': '-1*(' + sum_string + ')+1'})
|
178 |
|
|
|
|
|
|
|
179 |
opt = GPyOpt.methods.BayesianOptimization(f = fit_outputs, # function to optimize
|
180 |
domain = domain, # box-constraints of the problem
|
181 |
constraints = constraints,
|
|
|
135 |
print("One hot columns are ", one_hot.columns)
|
136 |
return predict(one_hot, request)
|
137 |
|
138 |
+
def fit_outputs_constraints(x, hardness_target, ys_target):
|
|
|
|
|
|
|
139 |
predictions = predict(x)
|
140 |
error_hardness = np.sqrt(np.square(predictions[0]-hardness_target))
|
141 |
error_ys = np.sqrt(np.square(predictions[2]-ys_target))
|
142 |
print(predictions, hardness_target, ys_target, error_hardness, error_ys)
|
143 |
return error_hardness + error_ys
|
144 |
|
|
|
145 |
def predict_inverse(hardness_target, ys_target, request: gr.Request):
|
146 |
|
147 |
continuous_variables = ['PROPERTY: Calculated Density (g/cm$^3$)',
|
|
|
172 |
constraints.append({'name': constraint + "+1", 'constraint': sum_string + '-1'})
|
173 |
constraints.append({'name': constraint + "-1", 'constraint': '-1*(' + sum_string + ')+1'})
|
174 |
|
175 |
+
def fit_outputs(x):
|
176 |
+
return fit_outputs_constraints(x, harndess_target, ys_target)
|
177 |
+
|
178 |
opt = GPyOpt.methods.BayesianOptimization(f = fit_outputs, # function to optimize
|
179 |
domain = domain, # box-constraints of the problem
|
180 |
constraints = constraints,
|