Skip to content

Commit

Permalink
Fixed bug with adding model points with no prior
Browse files Browse the repository at this point in the history
  • Loading branch information
ianran committed Nov 27, 2023
1 parent 80c95d3 commit ccec230
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions examples/GaussianProcess/User2DGP.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def f_sq(x, data=None):
#gp = gr.PreferenceGP(gr.RBF_kern(0.2,0.5)*gr.linear_kern(0.2, 0.1, 0))
#gp = gr.PreferenceGP(gr.linear_kern(0.3, 0.1, 0.0))
gp = gr.PreferenceGP(gr.RBF_kern(1.0, 1.0), pareto_pairs=True, \
use_hyper_optimization=False)
use_hyper_optimization=False, normalize_positive=True)
gp.add_prior(bounds=np.array(bounds))


Expand Down Expand Up @@ -99,7 +99,7 @@ def f_sq(x, data=None):
ax = plt.axes(projection='3d')
#ax.contour3D(X, Y, Z_pred, 50, cmap='binary')
ax.plot_wireframe(X, Y, Z, color= 'black')
ax.plot_wireframe(X, Y, UCB_pred, color= 'red')
#ax.plot_wireframe(X, Y, UCB_pred, color= 'red')
ax.plot_surface(X, Y, Z_pred, rstride=1, cstride=1, cmap='magma', edgecolor='none')
ax.scatter(gp.X_train[:,0], gp.X_train[:,1], gp.F)
ax.set_xlabel('x')
Expand Down
8 changes: 5 additions & 3 deletions src/rdml_graph/gaussian_process/PreferenceModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,11 @@ def add(self, X, y, type='relative_discrete', training_sigma=0):
if self.y_train[self.probit_idxs['relative_discrete']] is None:
self.y_train[self.probit_idxs['relative_discrete']] = np.array(pairs)
else:
self.y_train[self.probit_idxs['relative_discrete']] = \
np.append(self.y_train[self.probit_idxs['relative_discrete']], \
np.array(pairs), axis=0)
# only add pairs if there is any pareto pairs to add.
if len(pairs) > 0:
self.y_train[self.probit_idxs['relative_discrete']] = \
np.append(self.y_train[self.probit_idxs['relative_discrete']], \
np.array(pairs), axis=0)
# end if for pareto_pairs


Expand Down

0 comments on commit ccec230

Please sign in to comment.