{"id":9790,"library":"gpy","title":"GPy - Gaussian Process Toolbox","description":"GPy is a Gaussian process (GP) framework written in Python, designed for flexible and robust GP modeling. It provides a comprehensive suite of tools for defining, manipulating, and optimizing Gaussian process models, including various kernels, likelihoods, and inference methods. The current version is 1.13.2, with releases occurring periodically, often tied to maintenance or feature additions rather than a strict schedule.","status":"active","version":"1.13.2","language":"en","source_language":"en","source_url":"https://github.com/SheffieldML/GPy","tags":["machine-learning","gaussian-processes","bayesian","statistics","modeling"],"install":[{"cmd":"pip install gpy","lang":"bash","label":"Install GPy"}],"dependencies":[{"reason":"Core numerical operations and array handling.","package":"numpy","optional":false},{"reason":"Scientific computing routines, including optimization and special functions.","package":"scipy","optional":false},{"reason":"Required for built-in plotting functionalities.","package":"matplotlib","optional":true}],"imports":[{"symbol":"GPy","correct":"import GPy"},{"note":"GPRegression is located within the GPy.models submodule, not directly in the top-level GPy package.","wrong":"from GPy import GPRegression","symbol":"GPRegression","correct":"import GPy; model = GPy.models.GPRegression(...)"},{"note":"Kernels like RBF are found in the GPy.kern submodule.","wrong":"from GPy import RBF","symbol":"RBF","correct":"import GPy; kernel = GPy.kern.RBF(...)"}],"quickstart":{"code":"import GPy\nimport numpy as np\n\n# 1. Generate some synthetic data\nX = np.random.uniform(-3., 3., (20, 1))\nY = np.sin(X) + np.random.randn(20, 1) * 0.05\n\n# 2. Define a kernel (e.g., Radial Basis Function)\nkernel = GPy.kern.RBF(input_dim=1, variance=1., lengthscale=1.)\n\n# 3. Create a GP regression model\nm = GPy.models.GPRegression(X, Y, kernel)\n\n# 4. Optimize the model's hyperparameters\nm.optimize(messages=True, max_iters=100)\n\n# Print optimized parameters\nprint(m)\n\n# To plot (requires matplotlib):\n# import matplotlib.pyplot as plt\n# m.plot()\n# plt.show()","lang":"python","description":"This quickstart demonstrates how to create a simple Gaussian Process regression model, define a kernel, fit it to some synthetic data, and optimize its hyperparameters using GPy. The example also shows how to print the optimized model parameters."},"warnings":[{"fix":"Ensure your environment uses Python 3.9 or a more recent version.","message":"GPy no longer supports Python 2.x. It explicitly requires Python 3.9 or newer.","severity":"breaking","affected_versions":"<=1.9.9 (Python 2.x support), >=1.10.0 (Python 3 only)"},{"fix":"Consider using `m.optimize_restarts(num_restarts=N)` with a sufficient number of restarts, trying different initial parameter values, or increasing `max_iters`. Inspect the objective function carefully.","message":"Optimization (`m.optimize()`) does not guarantee finding the global optimum for complex models and datasets, and can get stuck in local minima or fail to converge.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Install `matplotlib` (`pip install matplotlib`). For non-interactive environments, explicitly set a non-interactive backend for `matplotlib` (e.g., `matplotlib.use('Agg')`) before importing `matplotlib.pyplot`.","message":"GPy's plotting capabilities rely on `matplotlib`. Issues may arise if `matplotlib` is not installed, or if there are backend conflicts in non-interactive environments.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Keep GPy updated to the latest stable version. If encountering issues, try aligning `numpy` and `scipy` versions with those GPy was tested against (check GPy's `setup.py` or documentation).","message":"GPy's dependency on `numpy` and `scipy` means that version mismatches can sometimes lead to unexpected errors or deprecation warnings, especially with very new `numpy`/`scipy` releases and older GPy versions.","severity":"gotcha","affected_versions":"All versions, particularly older GPy with newer numpy/scipy"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"`GPRegression` is located within the `GPy.models` submodule. Use `GPy.models.GPRegression`.","cause":"Attempting to access model classes like `GPRegression` directly from the top-level `GPy` module.","error":"AttributeError: module 'GPy' has no attribute 'GPRegression'"},{"fix":"Install `matplotlib` using `pip install matplotlib`.","cause":"`matplotlib` is a soft dependency for plotting functionality and might not be installed by default.","error":"GPy plotting requires matplotlib to be installed."},{"fix":"Reshape your 1D data arrays using `.reshape(-1, 1)`. For example, `X = X.reshape(-1, 1)` and `Y = Y.reshape(-1, 1)`.","cause":"GPy typically expects input data `X` and output data `Y` to be 2-dimensional arrays (e.g., `(N, 1)` for 1D input/output), not 1D arrays.","error":"ValueError: Inputs must be 2-dimensional. (e.g. X.shape = (N, D))"},{"fix":"Increase the `max_iters` parameter in `m.optimize()`. Consider using `m.optimize_restarts(num_restarts=N)` to run optimization from multiple random starting points to find a better minimum. Inspect your kernel choice and data for potential issues.","cause":"The optimization algorithm (typically a gradient-based method) could not find a stable minimum within the allotted iterations, often due to poor initial parameter values, local optima, or numerical instability.","error":"Optimize failed to converge"}]}