Skip to content

Commit

Permalink
Merge pull request #483 from pybop-team/459-replace-MAP-class
Browse files Browse the repository at this point in the history
Replace `pybop.MAP` with `pybop.LogPosterior`
  • Loading branch information
martinjrobins authored Sep 9, 2024
2 parents eb5a632 + 9018f75 commit 1822ddb
Show file tree
Hide file tree
Showing 18 changed files with 1,040 additions and 303 deletions.
39 changes: 5 additions & 34 deletions examples/notebooks/comparing_cost_functions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"/Users/engs2510/Documents/Git/PyBOP/.nox/notebooks-overwrite/bin/python3: No module named pip\r\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Note: you may need to restart the kernel to use updated packages.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"/Users/engs2510/Documents/Git/PyBOP/.nox/notebooks-overwrite/bin/python3: No module named pip\r\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Note: you may need to restart the kernel to use updated packages.\n"
]
}
],
"outputs": [],
"source": [
"%pip install --upgrade pip ipywidgets -q\n",
"%pip install pybop -q\n",
Expand Down Expand Up @@ -206,7 +177,7 @@
{
"data": {
"text/plain": [
"2.0269652551213878e-10"
"1.1753460077019054e-09"
]
},
"execution_count": null,
Expand Down Expand Up @@ -240,7 +211,7 @@
{
"data": {
"text/plain": [
"2.0269652551213878e-10"
"1.1753460077019054e-09"
]
},
"execution_count": null,
Expand Down Expand Up @@ -269,13 +240,13 @@
"name": "stdout",
"output_type": "stream",
"text": [
"[8.19241247e-05 5.09035035e-06]\n"
"[7.60957550e-05 5.48691392e-06]\n"
]
},
{
"data": {
"text/plain": [
"0.030472774516224807"
"0.014466627355628724"
]
},
"execution_count": null,
Expand Down
21 changes: 0 additions & 21 deletions examples/notebooks/cost-compute-methods.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,6 @@
"id": "1",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"/Users/engs2510/Documents/Git/PyBOP/.nox/notebooks-overwrite/bin/python3: No module named pip\r\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Note: you may need to restart the kernel to use updated packages.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"/Users/engs2510/Documents/Git/PyBOP/.nox/notebooks-overwrite/bin/python3: No module named pip\r\n"
]
},
{
"name": "stdout",
"output_type": "stream",
Expand Down
878 changes: 878 additions & 0 deletions examples/notebooks/maximum_a_posteriori.ipynb

Large diffs are not rendered by default.

31 changes: 1 addition & 30 deletions examples/notebooks/multi_model_identification.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,36 +25,7 @@
"id": "X87NUGPW04py",
"outputId": "0d785b07-7cff-4aeb-e60a-4ff5a669afbf"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"/Users/engs2510/Documents/Git/PyBOP/.nox/notebooks-overwrite/bin/python3: No module named pip\r\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Note: you may need to restart the kernel to use updated packages.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"/Users/engs2510/Documents/Git/PyBOP/.nox/notebooks-overwrite/bin/python3: No module named pip\r\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Note: you may need to restart the kernel to use updated packages.\n"
]
}
],
"outputs": [],
"source": [
"%pip install --upgrade pip ipywidgets pybamm -q\n",
"%pip install pybop -q"
Expand Down
4 changes: 2 additions & 2 deletions examples/scripts/spm_MAP.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@

# Generate problem, cost function, and optimisation class
problem = pybop.FittingProblem(model, parameters, dataset)
cost = pybop.MAP(problem, pybop.GaussianLogLikelihoodKnownSigma, sigma0=sigma)
optim = pybop.AdamW(
cost = pybop.LogPosterior(pybop.GaussianLogLikelihoodKnownSigma(problem, sigma0=sigma))
optim = pybop.IRPropMin(
cost,
sigma0=0.05,
max_unchanged_iterations=20,
Expand Down
1 change: 0 additions & 1 deletion pybop/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@
GaussianLogLikelihood,
GaussianLogLikelihoodKnownSigma,
LogPosterior,
MAP,
)
from .costs._weighted_cost import WeightedCost

Expand Down
Loading

0 comments on commit 1822ddb

Please sign in to comment.