-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add alpha to args
#612
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
+7
−1
Closed
Add alpha to args
#612
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
Does scikit-learn GaussianProcessRegressor validate that the alpha parameter is positive?💡 Result:
No clear positive-only validation is enforced for GaussianProcessRegressor(alpha=...). In the public API docs, alpha is described as a nonnegative “value added to the diagonal” to help ensure a positive definite matrix, but the docs do not explicitly state that scikit-learn validates alpha > 0 at input time [1]. In the current scikit-learn implementation file for GaussianProcessRegressor (sklearn/gaussian_process/_gpr.py), the fitting code shown performs shape/compatibility checks (e.g., alpha must be a scalar or an array with the same number of entries as the training data), but the snippet does not include any explicit check rejecting alpha <= 0 [2]. Therefore, based on the evidence found in the official documentation and the examined implementation, scikit-learn does not explicitly validate that alpha is strictly positive; instead, incorrect (e.g., nonpositive) values may lead to numerical issues later (e.g., failure to produce a positive definite matrix), rather than being rejected by an immediate ValueError [1][2].
Citations:
🏁 Script executed:
Repository: bayesian-optimization/BayesianOptimization
Length of output: 129
🏁 Script executed:
Repository: bayesian-optimization/BayesianOptimization
Length of output: 129
🏁 Script executed:
Repository: bayesian-optimization/BayesianOptimization
Length of output: 2876
🏁 Script executed:
Repository: bayesian-optimization/BayesianOptimization
Length of output: 2137
Validate
alphais strictly positive inBayesianOptimization.__init__alphais passed directly tosklearn.gaussian_process.GaussianProcessRegressor(alpha=...), and scikit-learn doesn’t enforcealpha > 0at input time—nonpositive values may fail later during GP fitting. Add an explicit check to fail fast with a clearValueError.🛡️ Suggested validation
def __init__( self, f: Callable[..., float] | None, pbounds: BoundsMapping, acquisition_function: AcquisitionFunction | None = None, constraint: NonlinearConstraint | None = None, random_state: int | RandomState | None = None, alpha: float = 1e-6, verbose: int = 2, bounds_transformer: DomainTransformer | None = None, allow_duplicate_points: bool = False, ): + if alpha <= 0: + msg = "alpha must be positive" + raise ValueError(msg) self._random_state = ensure_rng(random_state)📝 Committable suggestion
🤖 Prompt for AI Agents