Skip to content
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

Unable to use mean function with inputs raised to a power #239

Open
joshnevin opened this issue Jul 28, 2022 · 0 comments
Open

Unable to use mean function with inputs raised to a power #239

joshnevin opened this issue Jul 28, 2022 · 0 comments

Comments

@joshnevin
Copy link

I am new to the mean function interface and apologise if this is a trivial issue...
I want to do GP regression with 5-dimensional input space and 1-dimensional output.
I am trying to specify a mean function using Patsy of the form

"x[0]^3+x[1]^3+x[2]^3+x[3]^3+x[4]^3"

Checking this using

mf = "x[0]^3+x[1]^3+x[2]^3+x[3]^3+x[4]^3"
print(MeanFunction(mf))

gives

c + cx[0]^3.0 + cx[1]^3.0 + cx[2]^3.0 + cx[3]^3.0 + c*x[4]^3.0

which is what I want, i.e., each input raised to the third power, plus an intercept. However, when I try to create the GP model using

gp_map = mogp_emulator.GaussianProcess(inputs, targets, mean="x[0]^3+x[1]^3+x[2]^3+x[3]^3+x[4]^3", kernel='SquaredExponential', nugget="fit")

I get the error

File ~/nli_char/nlienv/lib/python3.8/site-packages/mogp_emulator/GaussianProcess.py:507, in GaussianProcess.get_design_matrix(self, inputs)
505 dm = np.array(dmatrix(self._mean, data={"x": inputs.T}))
506 except PatsyError:
--> 507 raise ValueError("Provided mean function is invalid")
508 if not dm.shape[0] == inputs.shape[0]:
509 raise ValueError("Provided design matrix is of the wrong shape")
ValueError: Provided mean function is invalid

I am not sure what is wrong with this mean function. I get no errors and can fit a model with a linear mean function
"x[0]+x[1]+x[2]+x[3]+x[4]"
I also get the same error with the mean function
c + c*x[0]^2.0
which is mentioned in the examples: https://mogp-emulator.readthedocs.io/en/latest/implementation/MeanFunction.html.
So, the issue seems to be using a mean function with inputs raised to any power.

Running pip list:
Package Version


anyio 3.6.1
appnope 0.1.3
argon2-cffi 21.3.0
argon2-cffi-bindings 21.2.0
asttokens 2.0.5
attrs 21.4.0
Babel 2.10.3
backcall 0.2.0
beautifulsoup4 4.11.1
bleach 5.0.1
certifi 2022.6.15
cffi 1.15.1
charset-normalizer 2.1.0
cycler 0.11.0
debugpy 1.6.0
decorator 5.1.1
defusedxml 0.7.1
entrypoints 0.4
executing 0.8.3
fastjsonschema 2.15.3
fonttools 4.33.3
idna 3.3
importlib-metadata 4.12.0
importlib-resources 5.8.0
ipykernel 6.15.0
ipython 8.4.0
ipython-genutils 0.2.0
ipywidgets 7.7.1
jedi 0.18.1
Jinja2 3.1.2
joblib 1.1.0
json5 0.9.8
jsonschema 4.6.1
jupyter 1.0.0
jupyter-client 7.3.4
jupyter-console 6.4.4
jupyter-core 4.10.0
jupyter-server 1.18.0
jupyterlab 3.4.3
jupyterlab-pygments 0.2.2
jupyterlab-server 2.14.0
jupyterlab-widgets 1.1.1
kiwisolver 1.4.3
MarkupSafe 2.1.1
matplotlib 3.5.2
matplotlib-inline 0.1.3
mistune 0.8.4
mogp-emulator 0.7.0
nbclassic 0.4.0
nbclient 0.6.6
nbconvert 6.5.0
nbformat 5.4.0
nest-asyncio 1.5.5
notebook 6.4.12
notebook-shim 0.1.0
numpy 1.23.0
packaging 21.3
pandas 1.4.3
pandocfilters 1.5.0
parso 0.8.3
patsy 0.5.2
pexpect 4.8.0
pickle-mixin 1.0.2
pickleshare 0.7.5
Pillow 9.2.0
pip 22.1.2
prometheus-client 0.14.1
prompt-toolkit 3.0.30
psutil 5.9.1
ptyprocess 0.7.0
pure-eval 0.2.2
pycparser 2.21
Pygments 2.12.0
pyparsing 3.0.9
pyrsistent 0.18.1
python-dateutil 2.8.2
pytz 2022.1
pyzmq 23.2.0
qtconsole 5.3.1
QtPy 2.1.0
requests 2.28.1
scikit-learn 1.1.1
scipy 1.8.1
Send2Trash 1.8.0
setuptools 41.2.0
six 1.16.0
sniffio 1.2.0
soupsieve 2.3.2.post1
stack-data 0.3.0
terminado 0.15.0
threadpoolctl 3.1.0
tinycss2 1.1.1
tornado 6.2
traitlets 5.3.0
urllib3 1.26.9
wcwidth 0.2.5
webencodings 0.5.1
websocket-client 1.3.3
widgetsnbextension 3.6.1
zipp 3.8.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant