Skip to content

Commit

Permalink
refactor: use train data if test data is empty for a cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
sathvikbhagavan committed Jan 14, 2024
1 parent 4f069df commit f7f289d
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions lib/SurrogatesMOE/src/SurrogatesMOE.jl
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,9 @@ function _find_best_model(clustered_train_values, clustered_test_values, dim,
xtest_mat = _vector_of_tuples_to_matrix(x_test_vec)
end

X = vcat(xtrain_mat, xtest_mat)
X = !isnothing(xtest_mat) ? vcat(xtrain_mat, xtest_mat) : xtrain_mat
x_test_vec = !isnothing(xtest_mat) ? x_test_vec : x_vec
y_test_vec = !isnothing(xtest_mat) ? y_test_vec : y_vec

Check warning on line 246 in lib/SurrogatesMOE/src/SurrogatesMOE.jl

View check run for this annotation

Codecov / codecov/patch

lib/SurrogatesMOE/src/SurrogatesMOE.jl#L244-L246

Added lines #L244 - L246 were not covered by tests
lb, ub = _find_upper_lower_bounds(X)

# call on _surrogate_builder with clustered_train_vals, enabled expert types, lb, ub
Expand Down Expand Up @@ -385,15 +387,18 @@ end
takes in a vector of tuples or vector of vectors and converts it into a matrix
"""
function _vector_of_tuples_to_matrix(v)
num_rows = length(v)
num_cols = length(first(v))
K = zeros(num_rows, num_cols)
for row in 1:num_rows
for col in 1:num_cols
K[row, col] = v[row][col]
if !isempty(v)
num_rows = length(v)
num_cols = length(first(v))
K = zeros(num_rows, num_cols)
for row in 1:num_rows
for col in 1:num_cols
K[row, col] = v[row][col]
end

Check warning on line 397 in lib/SurrogatesMOE/src/SurrogatesMOE.jl

View check run for this annotation

Codecov / codecov/patch

lib/SurrogatesMOE/src/SurrogatesMOE.jl#L390-L397

Added lines #L390 - L397 were not covered by tests
end
return K

Check warning on line 399 in lib/SurrogatesMOE/src/SurrogatesMOE.jl

View check run for this annotation

Codecov / codecov/patch

lib/SurrogatesMOE/src/SurrogatesMOE.jl#L399

Added line #L399 was not covered by tests
end
return K
return nothing

Check warning on line 401 in lib/SurrogatesMOE/src/SurrogatesMOE.jl

View check run for this annotation

Codecov / codecov/patch

lib/SurrogatesMOE/src/SurrogatesMOE.jl#L401

Added line #L401 was not covered by tests
end

end #module

0 comments on commit f7f289d

Please sign in to comment.