NSGP-Torch
Examples
gpytorch model with skgpytorch
# Import packages
import torch
from regdata import NonStat2D
from gpytorch.kernels import RBFKernel, ScaleKernel
from skgpytorch.models import ExactGPRegressor
from skgpytorch.metrics import mean_squared_error
# Hyperparameters
n_iters = 100
# Load data
datafunc = NonStat2D(backend="torch")
X_train, y_train, X_test = map(lambda x: x.to(torch.float32), datafunc.get_data())
y_test = datafunc.f(X_test[:, 0], X_test[:, 1]).to(torch.float32)
# Define a kernel
kernel = ScaleKernel(RBFKernel(ard_num_dims=X_train.shape[1]))
# Define a model
model = ExactGPRegressor(X_train, y_train, kernel, device='cpu')
# Train the model
model.fit(n_iters=n_iters, random_state=seed)
# Predict the distribution
pred_dist = model.predict(X_train, y_train, X_test)
# Compute RMSE and/or NLPD
mse = mean_squared_error(pred_dist, y_test, squared=False)
nlpd = neg_log_posterior_density(pred_dist, y_test)
nsgptorch model with skgpytorch
# Import packages
import torch
from regdata import NonStat2D
from nsgptorch.kernels import rbf
from skgpytorch.models import ExactNSGPRegressor
from skgpytorch.metrics import mean_squared_error
# Hyperparameters
n_iters = 100
# Load data
datafunc = NonStat2D(backend="torch")
X_train, y_train, X_test = map(lambda x: x.to(torch.float32), datafunc.get_data())
y_test = datafunc.f(X_test[:, 0], X_test[:, 1]).to(torch.float32)
# Define a kernel list for each dimension
kernel_list = [rbf, rbf]
# Define inducing points for each dimension (must be none if not applicable)
inducing_points = [None, None]
# Define a model
model = ExactNSGPRegressor(kernel_list, input_dim=2, inducing_points, device='cpu')
# Train the model
model.fit(X_train, y_train, n_iters=n_iters, random_state=seed)
# Predict the distribution
pred_dist = model.predict(X_train, y_train, X_test)
# Compute RMSE and/or NLPD
mse = mean_squared_error(pred_dist, y_test, squared=False)
nlpd = neg_log_posterior_density(pred_dist, y_test)
Plan
- Each kernel is 1D
- Multiply kernels to each other
Ideas
- Compute distance once and save it
- Update skgpytorch to use 1 std instead of 0.1
- Do something about mean learning of gpytorch for comparison
Metadata
Release files for nsgptorch 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nsgptorch-0.1.2.tar.gz | 7.3 kB | Without provenance | Details for nsgptorch-0.1.2.tar.gz |
Release files / nsgptorch-0.1.2.tar.gz
| Download URL | nsgptorch-0.1.2.tar.gz |
|---|---|
| Size | 7.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
354ada35852bac3ea02f6488a87b7e727ab53c48ac8fe95d5b798009c4dbc818
|
|
BLAKE2b-256 checksum How to use checksums |
d10f53f20f1a351be5a0116929f795cd06aa522fb92e0bf7dfcad5bf5afa997b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1
|
Security for nsgptorch 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.