Skip to content

[MRG] Changed self.rng to private (self.rng_) in sklearn/gaussian_process/g… #7766

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

Closed
wants to merge 3 commits into from
Closed
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
6 changes: 4 additions & 2 deletions sklearn/gaussian_process/gpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ def optimizer(obj_func, initial_theta, bounds):
log_marginal_likelihood_value_ : float
The log-marginal-likelihood of ``self.kernel_.theta``

rng_ : numpy.RandomState

Copy link
Contributor

Choose a reason for hiding this comment

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

You need to explain what this attribute is. Look at the above declarations. The user needs to know what this stands for.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe like this:

rng_ : numpy.RandomState
   random_state used at the time of initialization

"""
def __init__(self, kernel=None, alpha=1e-10,
optimizer="fmin_l_bfgs_b", n_restarts_optimizer=0,
Expand Down Expand Up @@ -161,7 +163,7 @@ def fit(self, X, y):
else:
self.kernel_ = clone(self.kernel)

self.rng = check_random_state(self.random_state)
self.rng_ = check_random_state(self.random_state)
Copy link
Contributor

@dalmia dalmia Nov 11, 2016

Choose a reason for hiding this comment

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

@tayyabpw You need to add 'rng_' in the 'Attributes' section in the docstring above.


X, y = check_X_y(X, y, multi_output=True, y_numeric=True)

Expand Down Expand Up @@ -211,7 +213,7 @@ def obj_func(theta, eval_gradient=True):
bounds = self.kernel_.bounds
for iteration in range(self.n_restarts_optimizer):
theta_initial = \
self.rng.uniform(bounds[:, 0], bounds[:, 1])
self.rng_.uniform(bounds[:, 0], bounds[:, 1])
optima.append(
self._constrained_optimization(obj_func, theta_initial,
bounds))
Expand Down