models
py3dinterpolations.modelling.models
¶
Model registry for 3D interpolation.
BaseModel
¶
Bases: ABC
Interface for interpolation models.
All models must implement fit() and predict() with consistent signatures.
name
abstractmethod
property
¶
Human-readable model name.
fit(x, y, z, v)
abstractmethod
¶
Fit the model to training data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray
|
X coordinates of training points. |
required |
y
|
ndarray
|
Y coordinates of training points. |
required |
z
|
ndarray
|
Z coordinates of training points. |
required |
v
|
ndarray
|
Values at training points. |
required |
Source code in py3dinterpolations/modelling/models/base.py
16 17 18 19 20 21 22 23 24 25 26 | |
predict(grid_x, grid_y, grid_z, **kwargs)
abstractmethod
¶
Predict on 1D grid arrays.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grid_x
|
ndarray
|
1D array of X grid coordinates. |
required |
grid_y
|
ndarray
|
1D array of Y grid coordinates. |
required |
grid_z
|
ndarray
|
1D array of Z grid coordinates. |
required |
Returns:
| Type | Description |
|---|---|
InterpolationResult
|
Interpolation result with at least the interpolated field. |
Source code in py3dinterpolations/modelling/models/base.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | |
IDWModel(power=1.0, threshold=1e-10)
¶
Bases: BaseModel
Vectorized IDW interpolation.
Uses numpy broadcasting instead of Python loops for ~1000x speedup on typical workloads. Batches computation for memory safety.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
power
|
float
|
Power parameter controlling distance decay. Higher values give more weight to nearby points. |
1.0
|
threshold
|
float
|
Distance below which a point is treated as coincident with a training point (exact interpolation). |
1e-10
|
Source code in py3dinterpolations/modelling/models/idw.py
25 26 27 28 29 | |
fit(x, y, z, v)
¶
Store training data.
Source code in py3dinterpolations/modelling/models/idw.py
31 32 33 34 | |
predict(grid_x, grid_y, grid_z, **kwargs)
¶
Predict on a regular grid defined by 1D arrays.
Returns:
| Type | Description |
|---|---|
InterpolationResult
|
InterpolationResult with shape (len(grid_z), len(grid_y), len(grid_x)) |
InterpolationResult
|
to match pykrige's output convention. |
Source code in py3dinterpolations/modelling/models/idw.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
KrigingModel(**kriging_params)
¶
Bases: BaseModel
Ordinary Kriging 3D wrapper around pykrige.
pykrige fits at construction time, so fit() constructs the OrdinaryKriging3D instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kriging_params
|
object
|
Parameters passed to OrdinaryKriging3D constructor. |
{}
|
Source code in py3dinterpolations/modelling/models/kriging.py
20 21 22 | |
fit(x, y, z, v)
¶
Fit by constructing the OrdinaryKriging3D model.
Source code in py3dinterpolations/modelling/models/kriging.py
24 25 26 | |
predict(grid_x, grid_y, grid_z, **kwargs)
¶
Execute kriging on the given grid arrays.
Returns:
| Type | Description |
|---|---|
InterpolationResult
|
InterpolationResult with interpolated and variance arrays. |
InterpolationResult
|
Shape is (len(grid_z), len(grid_y), len(grid_x)) per pykrige convention. |
Source code in py3dinterpolations/modelling/models/kriging.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
SklearnModel(estimator, model_name='sklearn')
¶
Bases: BaseModel
Wrapper for any sklearn estimator with fit/predict interface.
Handles classifiers (predict_proba) and regressors (predict).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
estimator
|
SklearnEstimator
|
A sklearn estimator instance. |
required |
model_name
|
str
|
Human-readable name for this model. |
'sklearn'
|
Source code in py3dinterpolations/modelling/models/sklearn_model.py
19 20 21 | |
fit(x, y, z, v)
¶
Fit the sklearn estimator.
Source code in py3dinterpolations/modelling/models/sklearn_model.py
23 24 25 26 | |
predict(grid_x, grid_y, grid_z, **kwargs)
¶
Predict on a regular grid.
Returns:
| Type | Description |
|---|---|
InterpolationResult
|
InterpolationResult with shape (len(grid_z), len(grid_y), len(grid_x)) |
InterpolationResult
|
to match the convention of other models. |
Source code in py3dinterpolations/modelling/models/sklearn_model.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
get_model(model_type, **kwargs)
¶
Instantiate a model by type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_type
|
ModelType | str
|
Model identifier, either a ModelType enum or its string value. |
required |
**kwargs
|
object
|
Parameters passed to the model constructor. |
{}
|
Returns:
| Type | Description |
|---|---|
BaseModel
|
An instantiated model ready for fit(). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If model_type is not in the registry. |
Source code in py3dinterpolations/modelling/models/__init__.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |