neighpy
neighphy is a Python implementation of the Neighbourhood Algorithm for the optimisation and appraisal of high-dimensional loss surfaces.
First presented in two papers by M. Sambridge at the Australian National University in 1999, it has since been widely used, particularly in the geophysical community, for the optimisation of complex, high-dimensional functions.
This implementation hopes to replace the original Fortran code with a more modern, user-friendly and flexible Python package.
It is a very simple implementation, with just two classes to implement the two phases of the algorithm: the neighpy.search.NASearcher class for the optimisation phase, and the neighpy.appraise.NAAppraiser class for the appraisal phase
Installation
pip install neighpy
Basic Usage
import numpy as np
from neighpy import NASearcher, NAAppraiser
def objective(x):
# Objective function to be minimised
return np.linalg.norm(data - predict_data(x))
# Bounds of the parameter space
bounds = ((-5, 5), (-5, 5))
# Initialise direct search phase
searcher = NASearcher(
objective,
ns=100, # number of samples per iteration
nr=10, # number of cells to resample
ni=100, # size of initial random search
n=20, # number of iterations
bounds=bounds
)
# Run the direct search phase
searcher.run() # results stored in searcher.samples and searcher.objectives
# Initialise the appraisal phase
appraiser = NAAppraiser(
searcher.samples, # points of parameter space already sampled
np.exp(-searcher.objectives), # objective function values (as a probability distribution)
bounds=bounds,
n_resample=500000, # number of desired new samples
n_walkers=10 # number of parallel walkers
)
# Run the appraisal phase
appraiser.run() # Results stored in appraiser.samples
Licence
This code is distributed under a GNU General Public License.
Contributing
If you have any questions, please to open an issue in this repository.
Metadata
Release files for neighpy 0.1.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| neighpy-0.1.9.tar.gz | 20.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| neighpy-0.1.9-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 42.3 kB
Release files / neighpy-0.1.9.tar.gz
| Download URL | neighpy-0.1.9.tar.gz |
|---|---|
| Size | 20.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3fc19bccd411feb81762a2526210e2e5af5e438e77edead1b14211af687af495
|
|
BLAKE2b-256 checksum How to use checksums |
03c00b66fc5468b46ad343f0168050e423c5f5fcf4df585b8829b5e0123ff05b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.2 CPython/3.12.3 Linux/6.11.0-1018-azure
|
Release files / neighpy-0.1.9-py3-none-any.whl
| Download URL | neighpy-0.1.9-py3-none-any.whl |
|---|---|
| Size | 22.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1deb5f9a3f2e031894147f23235ca947e73aa7ab2cc5c065a97f12d88ff47d30
|
|
BLAKE2b-256 checksum How to use checksums |
7ab8da5ad63bd00ca392c1c4b378611a4de1fed3fc9cedc933be6a52b09aa04a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.2 CPython/3.12.3 Linux/6.11.0-1018-azure
|