Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use train data if test data is empty for a cluster #466

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 @@
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
Loading