%global _empty_manifest_terminate_build 0
Name: python-Constrained-GaussianProcess
Version: 0.1.1
Release: 1
Summary: Implementation of Python package for Fitting and Inference of Linearly Constrained Gaussian Processes
License: MIT License
URL: https://gitlab.inf.ethz.ch/mmutny/contrained-gps
Source0: https://mirrors.aliyun.com/pypi/web/packages/15/2f/0ec2f0aa5eeb68b4560e32a7e97038d22189bb466271d54709972e250bb2/Constrained_GaussianProcess-0.1.1.tar.gz
BuildArch: noarch
%description
# Constrained_GaussianProcess
Constrained_GaussianProcess is able to deal with linear inequality constraints in Gaussian Process frameworks. Check out the paper [Finite-Dimensional Gaussian Approximation with Linear Inequality Constraints](https://epubs.siam.org/doi/pdf/10.1137/17M1153157) for a detail explanation.

There are also [Hamiltonian Monte Carlo](https://arxiv.org/abs/1208.4118) method and Gibbs sampling method to sample from truncated multivariate Gaussian.
## Requirement
The code requires [Python 3.7](https://www.python.org/downloads/release/python-373/) , as well as the following python libraries:
- [cvxpy](https://www.cvxpy.org/#)==1.0.25
- numpy==1.17.3
- scipy==1.2.1
Those modules can be installed using: `pip install numpy scipy cvxpy` or `pip install -r requirements.txt`.
## Installation
Use the package manager [pip](https://pip.pypa.io/en/stable/) to install Constrained_GaussianProcess.
```bash
pip install Constrained-GaussianProcess
```
## Usage
```python
from Constrained_GaussianProcess import ConstrainedGP
m=30
# specify the constraints
constraints={'increasing': True, 'bounded': [0,1], 'convex': False}
interval=[0,1]
Gp = ConstrainedGP(m, constraints=constraints, interval=interval)
# Training data
x_train = np.array([0.25, 0.5, 0.75])
y_train = norm().cdf((x-0.5)/0.2)
# the MCMC methods are used to approximate the posterior distribution,
# so apart from training data, 'method' ('HMC' or 'Gibbs'), required number of samples
# 'n' and the burn in numbers 'burn_in' should be specified when fitting the data.
Gp.fit_gp(x_train, y_train, n=100, burn_in=100, method='HMC')
x_test = np.arange(0, 1 + 0.01, 0.5)
y_pred = Gp.mean(x_test) # get the conditional mean
```
Sampling from
with constraints 
```python
from Constrained_GaussianProcess import tmg
# set the number of samples and number in burn in phase
n = 150
burn_in = 30
#Define the covariance matrix and mean vector
M = np.array([[0.5, -0.4], [-0.4, 0.5]])
mu = np.array([0,0])
# Set initial point for the Markov chain
initial = np.array([4,1])
# Define two linear constraints
f = np.array([[1,1],[1,0]])
g = np.array([0,0])
# Sample
samples = tmg(n, mu, M, initial, f, g, burn_in=burn_in)
```
## Acknowledment
The `HMC` method for MCMC is based on the R package [tmg](https://cran.r-project.org/web/packages/tmg/index.html).
## License
[MIT](https://choosealicense.com/licenses/mit/)
%package -n python3-Constrained-GaussianProcess
Summary: Implementation of Python package for Fitting and Inference of Linearly Constrained Gaussian Processes
Provides: python-Constrained-GaussianProcess
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-pip
%description -n python3-Constrained-GaussianProcess
# Constrained_GaussianProcess
Constrained_GaussianProcess is able to deal with linear inequality constraints in Gaussian Process frameworks. Check out the paper [Finite-Dimensional Gaussian Approximation with Linear Inequality Constraints](https://epubs.siam.org/doi/pdf/10.1137/17M1153157) for a detail explanation.

There are also [Hamiltonian Monte Carlo](https://arxiv.org/abs/1208.4118) method and Gibbs sampling method to sample from truncated multivariate Gaussian.
## Requirement
The code requires [Python 3.7](https://www.python.org/downloads/release/python-373/) , as well as the following python libraries:
- [cvxpy](https://www.cvxpy.org/#)==1.0.25
- numpy==1.17.3
- scipy==1.2.1
Those modules can be installed using: `pip install numpy scipy cvxpy` or `pip install -r requirements.txt`.
## Installation
Use the package manager [pip](https://pip.pypa.io/en/stable/) to install Constrained_GaussianProcess.
```bash
pip install Constrained-GaussianProcess
```
## Usage
```python
from Constrained_GaussianProcess import ConstrainedGP
m=30
# specify the constraints
constraints={'increasing': True, 'bounded': [0,1], 'convex': False}
interval=[0,1]
Gp = ConstrainedGP(m, constraints=constraints, interval=interval)
# Training data
x_train = np.array([0.25, 0.5, 0.75])
y_train = norm().cdf((x-0.5)/0.2)
# the MCMC methods are used to approximate the posterior distribution,
# so apart from training data, 'method' ('HMC' or 'Gibbs'), required number of samples
# 'n' and the burn in numbers 'burn_in' should be specified when fitting the data.
Gp.fit_gp(x_train, y_train, n=100, burn_in=100, method='HMC')
x_test = np.arange(0, 1 + 0.01, 0.5)
y_pred = Gp.mean(x_test) # get the conditional mean
```
Sampling from
with constraints 
```python
from Constrained_GaussianProcess import tmg
# set the number of samples and number in burn in phase
n = 150
burn_in = 30
#Define the covariance matrix and mean vector
M = np.array([[0.5, -0.4], [-0.4, 0.5]])
mu = np.array([0,0])
# Set initial point for the Markov chain
initial = np.array([4,1])
# Define two linear constraints
f = np.array([[1,1],[1,0]])
g = np.array([0,0])
# Sample
samples = tmg(n, mu, M, initial, f, g, burn_in=burn_in)
```
## Acknowledment
The `HMC` method for MCMC is based on the R package [tmg](https://cran.r-project.org/web/packages/tmg/index.html).
## License
[MIT](https://choosealicense.com/licenses/mit/)
%package help
Summary: Development documents and examples for Constrained-GaussianProcess
Provides: python3-Constrained-GaussianProcess-doc
%description help
# Constrained_GaussianProcess
Constrained_GaussianProcess is able to deal with linear inequality constraints in Gaussian Process frameworks. Check out the paper [Finite-Dimensional Gaussian Approximation with Linear Inequality Constraints](https://epubs.siam.org/doi/pdf/10.1137/17M1153157) for a detail explanation.

There are also [Hamiltonian Monte Carlo](https://arxiv.org/abs/1208.4118) method and Gibbs sampling method to sample from truncated multivariate Gaussian.
## Requirement
The code requires [Python 3.7](https://www.python.org/downloads/release/python-373/) , as well as the following python libraries:
- [cvxpy](https://www.cvxpy.org/#)==1.0.25
- numpy==1.17.3
- scipy==1.2.1
Those modules can be installed using: `pip install numpy scipy cvxpy` or `pip install -r requirements.txt`.
## Installation
Use the package manager [pip](https://pip.pypa.io/en/stable/) to install Constrained_GaussianProcess.
```bash
pip install Constrained-GaussianProcess
```
## Usage
```python
from Constrained_GaussianProcess import ConstrainedGP
m=30
# specify the constraints
constraints={'increasing': True, 'bounded': [0,1], 'convex': False}
interval=[0,1]
Gp = ConstrainedGP(m, constraints=constraints, interval=interval)
# Training data
x_train = np.array([0.25, 0.5, 0.75])
y_train = norm().cdf((x-0.5)/0.2)
# the MCMC methods are used to approximate the posterior distribution,
# so apart from training data, 'method' ('HMC' or 'Gibbs'), required number of samples
# 'n' and the burn in numbers 'burn_in' should be specified when fitting the data.
Gp.fit_gp(x_train, y_train, n=100, burn_in=100, method='HMC')
x_test = np.arange(0, 1 + 0.01, 0.5)
y_pred = Gp.mean(x_test) # get the conditional mean
```
Sampling from
with constraints 
```python
from Constrained_GaussianProcess import tmg
# set the number of samples and number in burn in phase
n = 150
burn_in = 30
#Define the covariance matrix and mean vector
M = np.array([[0.5, -0.4], [-0.4, 0.5]])
mu = np.array([0,0])
# Set initial point for the Markov chain
initial = np.array([4,1])
# Define two linear constraints
f = np.array([[1,1],[1,0]])
g = np.array([0,0])
# Sample
samples = tmg(n, mu, M, initial, f, g, burn_in=burn_in)
```
## Acknowledment
The `HMC` method for MCMC is based on the R package [tmg](https://cran.r-project.org/web/packages/tmg/index.html).
## License
[MIT](https://choosealicense.com/licenses/mit/)
%prep
%autosetup -n Constrained_GaussianProcess-0.1.1
%build
%py3_build
%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
find usr/lib -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
find usr/lib64 -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
find usr/bin -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
find usr/sbin -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
find usr/share/man -type f -printf "\"/%h/%f.gz\"\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .
%files -n python3-Constrained-GaussianProcess -f filelist.lst
%dir %{python3_sitelib}/*
%files help -f doclist.lst
%{_docdir}/*
%changelog
* Tue Jun 20 2023 Python_Bot - 0.1.1-1
- Package Spec generated