IDW Functions#
- spatialize.gs.idw.idw_griddata(points, values, xi, **kwargs)#
Perform IDW interpolation on a grid.
- Parameters:
points – Array of input data points.
values – Array of values corresponding to input data points.
xi – Array of grid points where interpolation is desired.
- Returns:
IDWResult containing the interpolation results on a grid.
- spatialize.gs.idw.idw_nongriddata(points, values, xi, **kwargs)#
Perform IDW interpolation on non-grid data.
- Parameters:
points – Array of input data points.
values – Array of values corresponding to input data points.
xi – Array of non-grid points where interpolation is desired.
- Returns:
IDWResult containing the interpolation results on non-grid data.
- spatialize.gs.idw.idw_hparams_search(points, values, xi, k=10, griddata=False, radius=(0.1, 0.2, 0.5, 0.1, 0.2), exponent=(np.float64(0.8), np.float64(0.9)), folding_seed=5438, callback=<function default_singleton_callback>)#
Perform a hyperparameter search for IDW interpolation.
- Parameters:
points – Array of input data points.
values – Array of values corresponding to input data points.
xi – Array of points where interpolation is desired.
k – Number of folds for cross-validation.
griddata – Boolean indicating whether to use grid data.
radius – Tuple of radius values for grid search.
exponent – Tuple of exponent values for grid search.
folding_seed – Seed for random number generator in cross-validation.
callback – Callback function for logging progress.
- Returns:
IDWGridSearchResult containing the grid search results.
- class spatialize.gs.idw.IDWGridSearchResult(search_result_data)#
A class to store the results of an Inverse Distance Weighting (IDW) grid search.
Methods
best_result([optimize_data_usage])Retrieve the best result from the grid search.
plot_cv_error([theme, color, fig_args])It shows a graph of the cross-validation errors of the hyperparameter search process.
load
save
- best_result(optimize_data_usage=False, **kwargs)#
Retrieve the best result from the grid search.
- Parameters:
optimize_data_usage – Boolean indicating whether to optimize data usage.
- Returns:
Dictionary containing the best parameters and their corresponding results.
- plot_cv_error(theme='alges', color=None, fig_args=None)#
It shows a graph of the cross-validation errors of the hyperparameter search process. The graph has two components: the first is the error histogram, and the second is the error level for each of the estimation scenarios generated by the gridded parameter search.
- Parameters:
fig_args (
Optional[Dict[str,Any]]) – Dictionary with figure configuration for plt.subplots(). Default assigns figsize=(10, 4) if not specified.subplot_args – Dictionary with subplot configuration for plt.subplots_adjust(). Default assigns wspace=0.45 if not specified.
theme (
Optional[str]) – Theme name. Available: ‘whitegrid’, ‘darkgrid’, ‘white’, ‘dark’, ‘alges’, ‘minimal’, ‘publication’color (
Optional[str]) – Color for the plots. If None, uses theme default or ‘skyblue’
- Returns:
Tuple with matplotlib figure and tuple of axes (fig, (ax1, ax2))
- Raises:
ValueError – If the specified theme does not exist.
- class spatialize.gs.idw.IDWResult(estimation, griddata=False, original_shape=None, xi=None)#
A class template to store the results of an IDW estimation.
Methods
Returns the estimated values at locations xi by aggregating all ESI samples using the aggregation function provided in the agg_function argument (in both function
esi_griddata()andesi_nongriddata()).plot_estimation([ax, w, h, theme, cmap])Plots the estimation using matplotlib.
quick_plot([w, h])Quickly plots the estimation using matplotlib.
- estimation()#
Returns the estimated values at locations xi by aggregating all ESI samples using the aggregation function provided in the agg_function argument (in both function
esi_griddata()andesi_nongriddata()). This estimate can be changed using another aggregation function with there_estimate()method of this same class.- Returns:
An array of dimension \(N_{x^*}\), for non-gridded data, and of dimension \(d_1 imes d_2\) for gridded data – remember that, in this case, \(d_1 imes d_2 = N_{x^*}\)
- plot_estimation(ax=None, w=None, h=None, theme='alges', cmap=None, **imshow_args)#
Plots the estimation using matplotlib.
- Parameters:
ax ((matplotlib.axes.Axes, optional)) – The Axes object to render the plot on. If None, a new Axes object is created.
w ((int, optional)) – The width of the image (if the data is reshaped).
h ((int, optional)) – The height of the image (if the data is reshaped).
theme ((str, optional)) – Theme name. Available: ‘whitegrid’, ‘darkgrid’, ‘white’, ‘dark’, ‘alges’, ‘minimal’, ‘publication’
cmap ((str, optional)) – Colormap for the plot. If None, uses theme default or ‘coolwarm’
**imshow_args ((optional)) – Additional keyword arguments passed to the _plot_data function (e.g., vmin, vmax, alpha).
- quick_plot(w=None, h=None, **imshow_args)#
Quickly plots the estimation using matplotlib.
- Parameters:
w ((int, optional)) – The width of the image (if the data is reshaped).
h ((int, optional)) – The height of the image (if the data is reshaped).
**imshow_args ((optional)) – Additional keyword arguments passed to the figure creation (e.g., DPI, figure size).