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 13, 2024
1 parent 4f069df commit 4ba040b
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
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
end
return K
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 4ba040b

Please sign in to comment.