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

Make theta a user-supplied array param #370

Merged
Merged
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions docs/src/gekpls.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,11 @@ y_true = water_flow.(x_test)
n_comp = 2
delta_x = 0.0001
extra_points = 2
initial_theta = 0.01
initial_theta = [0.01 for i in 1:n_comp]
g = GEKPLS(X, y, grads, n_comp, delta_x, xlimits, extra_points, initial_theta)
y_pred = g(X_test)
rmse = sqrt(sum(((y_pred - y_true).^2)/n_test)) #root mean squared error
println(rmse)
println(rmse) #0.0347

```

3 changes: 1 addition & 2 deletions src/GEKPLS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,14 @@ function bounds_error(x, xl)
end

#constructor for GEKPLS Struct
function GEKPLS(X, y, grads, n_comp, delta_x, xlimits, extra_points, θ)
function GEKPLS(X, y, grads, n_comp, delta_x, xlimits, extra_points, theta)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should docstring these. Anyways, that's for the future.


#ensure that X values are within the upper and lower bounds
if bounds_error(X, xlimits)
println("X values outside bounds")
return
end

theta = [θ for i in 1:n_comp]
pls_mean, X_after_PLS, y_after_PLS = _ge_compute_pls(X, y, n_comp, grads, delta_x,
xlimits, extra_points)
X_after_std, y_after_std, X_offset, y_mean, X_scale, y_std = standardization(X_after_PLS,
Expand Down
18 changes: 9 additions & 9 deletions test/GEKPLS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ y_true = water_flow.(x_test)
n_comp = 2
delta_x = 0.0001
extra_points = 2
initial_theta = 0.01
initial_theta = [0.01 for i in 1:n_comp]
g = GEKPLS(X, y, grads, n_comp, delta_x, xlimits, extra_points, initial_theta)
y_pred = g(X_test)
rmse = sqrt(sum(((y_pred - y_true) .^ 2) / n_test))
Expand All @@ -71,7 +71,7 @@ end
n_comp = 3
delta_x = 0.0001
extra_points = 2
initial_theta = 0.01
initial_theta = [0.01 for i in 1:n_comp]
g = GEKPLS(X, y, grads, n_comp, delta_x, xlimits, extra_points, initial_theta) #change hard-coded 2 param to variable
y_pred = g(X_test)
rmse = sqrt(sum(((y_pred - y_true) .^ 2) / n_test))
Expand All @@ -82,7 +82,7 @@ end
n_comp = 3
delta_x = 0.0001
extra_points = 3
initial_theta = 0.01
initial_theta = [0.01 for i in 1:n_comp]
g = GEKPLS(X, y, grads, n_comp, delta_x, xlimits, extra_points, initial_theta)
y_pred = g(X_test)
rmse = sqrt(sum(((y_pred - y_true) .^ 2) / n_test))
Expand Down Expand Up @@ -118,7 +118,7 @@ y_true = welded_beam.(x_test)
n_comp = 3
delta_x = 0.0001
extra_points = 2
initial_theta = 0.01
initial_theta = [0.01 for i in 1:n_comp]
g = GEKPLS(X, y, grads, n_comp, delta_x, xlimits, extra_points, initial_theta)
y_pred = g(X_test)
rmse = sqrt(sum(((y_pred - y_true) .^ 2) / n_test))
Expand All @@ -129,7 +129,7 @@ end
n_comp = 2
delta_x = 0.0001
extra_points = 2
initial_theta = 0.01
initial_theta = [0.01 for i in 1:n_comp]
g = GEKPLS(X, y, grads, n_comp, delta_x, xlimits, extra_points, initial_theta)
y_pred = g(X_test)
rmse = sqrt(sum(((y_pred - y_true) .^ 2) / n_test))
Expand All @@ -141,7 +141,7 @@ end
n_comp = 2
delta_x = 0.0001
extra_points = 4
initial_theta = 0.01
initial_theta = [0.01 for i in 1:n_comp]
g = GEKPLS(X, y, grads, n_comp, delta_x, xlimits, extra_points, initial_theta)
y_pred = g(X_test)
rmse = sqrt(sum(((y_pred - y_true) .^ 2) / n_test))
Expand Down Expand Up @@ -171,7 +171,7 @@ y_true = sphere_function.(x_test)
n_comp = 2
delta_x = 0.0001
extra_points = 2
initial_theta = 0.01
initial_theta = [0.01 for i in 1:n_comp]
g = GEKPLS(X, y, grads, n_comp, delta_x, xlimits, extra_points, initial_theta)
y_pred = g(X_test)
rmse = sqrt(sum(((y_pred - y_true) .^ 2) / n_test))
Expand All @@ -197,7 +197,7 @@ y_true = sphere_function.(x_test)
n_comp = 2
delta_x = 0.0001
extra_points = 2
initial_theta = 0.01
initial_theta = [0.01 for i in 1:n_comp]
g = GEKPLS(X, y, grads, n_comp, delta_x, xlimits, extra_points, initial_theta)
y_pred = g(X_test)
rmse = sqrt(sum(((y_pred - y_true) .^ 2) / n_test))
Expand All @@ -216,7 +216,7 @@ end
n_comp = 2
delta_x = 0.0001
extra_points = 2
initial_theta = 0.01
initial_theta = [0.01 for i in 1:n_comp]
g = GEKPLS(initial_X, initial_y, initial_grads, n_comp, delta_x, xlimits, extra_points,
initial_theta)
n_test = 100
Expand Down