docs/pyLatticeOpti.md¶
API — pyLatticeOpti¶
Core modules¶
pyLatticeOpti.lattice_opti
¶
Classes:
| Name | Description |
|---|---|
Cell |
Class representing a cell in the lattice structure. |
OptimizationPlotter |
Class to plot the optimization progress of a lattice structure. |
LatticeOpti |
Superclass of lattice for optimization purposes |
Functions:
| Name | Description |
|---|---|
open_lattice_parameters |
Open a JSON file containing lattice parameters. |
_find_path_to_data |
Determine a default dataset path based on lattice geometry. |
_opt_import |
|
Attributes:
| Name | Type | Description |
|---|---|---|
timing |
|
|
NonlinearConstraint |
|
|
Bounds |
|
|
minimize |
|
timing = Timing()
module-attribute
¶
NonlinearConstraint = _opt_import('scipy.optimize', 'NonlinearConstraint', pkg_label='SciPy')
module-attribute
¶
Bounds = _opt_import('scipy.optimize', 'Bounds', pkg_label='SciPy')
module-attribute
¶
minimize = _opt_import('scipy.optimize', 'minimize', pkg_label='SciPy')
module-attribute
¶
Cell
¶
Bases: object
Class representing a cell in the lattice structure.
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize a Cell with its dimensions and position |
dispose |
Dispose of the cell by detaching beams and points, and cleaning up references. |
generate_cell_properties |
Generate cell properties including beams and nodes. |
generate_beams |
Generate beams and nodes using a given lattice type_beam and parameters. |
get_beam_material |
Get the material of the beam based on the material gradient. |
get_radius |
Calculate and return the beam radii |
def_cell_size |
Calculate and return the cell size |
def_cell_center |
Calculate the center point of the cell |
get_point_on_surface |
Get the points on the surface specified in the global reference frame. |
remove_beam |
Removing beam from cell |
remove_point |
Removing point from cell |
add_beam |
Adding beam to cell |
add_point |
Adding point to cell |
add_cell_neighbour |
Add a neighbour cell in a structured dict format. |
get_all_cell_neighbours |
Get all neighbour cells in a flat list. |
refresh_from_global |
Rebuild self.beams_cell and self.points_cell from the current lattice state. |
define_node_order_to_simulate |
Define a deterministic order for boundary nodes to ensure consistent simulation results. |
set_reaction_force_on_nodes |
Set reaction force on each boundary node in the established local order. |
get_displacement_at_nodes |
Return displacement vectors ordered consistently with the provided local list/dict of Points. |
set_displacement_at_boundary_nodes |
Set displacement at nodes. |
build_coupling_operator |
Build the coupling operator B using the deterministic local boundary-node order. |
build_local_preconditioner |
Build the local preconditioner matrix B^T * S * B |
get_number_boundary_nodes |
Get the number of unique boundary nodes in the cell. |
get_internal_energy |
Get cell internal energy from all boundary points |
get_displacement_data |
Build and return displacement data on cell for dataset generation |
get_number_nodes_at_boundary |
Get the number of nodes at the boundary |
change_beam_radius |
WARNING: BEAM MOD IS NOT WORKING |
get_relative_density_kriging |
Get the relative density of the cell using kriging model |
get_relative_density_gradient |
Get the gradient of the relative density |
get_relative_density_gradient_kriging |
Finite difference gradient of the relative density (predictive mean) w.r.t. the radii using the trained |
get_relative_density_gradient_kriging_exact |
Exact gradient of the relative density (predictive mean) w.r.t. the radii using the trained |
get_RGBcolor_depending_of_radius |
Get the RGB color of the cell depending on the radii. |
print_data |
Print the data of the cell for debugging purposes. |
get_translation_rigid_body |
Get the translation of the rigid body |
get_rotation_rigid_body |
Get the rotation matrix of the rigid body using SVD. |
Attributes:
| Name | Type | Description |
|---|---|---|
volume |
Calculate the volume of the cell. |
|
relative_density |
float
|
Calculate the relative density of the cell based on the volume of beams and the cell volume. |
volume_each_geom |
ndarray
|
Get the volume of the cell separated by geometry type_beam. |
boundary_box |
list
|
Get the boundary box of the cell |
boundary_edges |
list[tuple[tuple[float, float, float], tuple[float, float, float]]]
|
Return the 12 edge segments of the cell’s axis-aligned bounding box |
corner_coordinates |
list
|
Get the corner coordinates of the cell. |
volume
property
¶
Calculate the volume of the cell.
relative_density
property
¶
Calculate the relative density of the cell based on the volume of beams and the cell volume.
volume_each_geom
property
¶
Get the volume of the cell separated by geometry type_beam.
boundary_box
property
¶
boundary_edges
property
¶
Return the 12 edge segments of the cell’s axis-aligned bounding box as pairs of 3D points ((x,y,z), (x,y,z)).
corner_coordinates
property
¶
Get the corner coordinates of the cell.
Returns:¶
list of tuples List of (x, y, z) coordinates of the corner points.
__init__(pos, initial_size, coordinate, geom_types, radii, grad_radius, grad_dim, grad_mat, uncertainty_node=0.0, _verbose=0, beams_already_defined=None, nodes_already_defined=None)
¶
Parameters:¶
pos: list Position of the cell in the lattice
list
Initial size of the cell
list
Coordinates of the cell minimum corner in the lattice
list[str]
Type of lattice geometry
float
Base radii of the beam
list
Gradient of the radii
list
Gradient of the dimensions
list
Gradient of the material
float
Standard deviation for adding uncertainty to node coordinates. Defaults to 0.0.
bool
If True, prints additional information during initialization. Defaults to False.
set
Set of beams already defined in the lattice to avoid duplication. Defaults to None.
set
Set of nodes already defined in the lattice to avoid duplication. Defaults to None.
dispose()
¶
Dispose of the cell by detaching beams and points, and cleaning up references.
generate_cell_properties(initial_cell_size, beams_already_defined=None, nodes_already_defined=None)
¶
Generate cell properties including beams and nodes.
Parameters:¶
initialCellSize: list Initial size of the cell without modification
set
Set of beams already defined in the lattice to avoid duplication
set
Set of nodes already defined in the lattice to avoid duplication
generate_beams(latticeType, beamRadius, beamType=0, beams_already_defined=None, nodes_already_defined=None)
¶
Generate beams and nodes using a given lattice type_beam and parameters.
Parameters:¶
latticeType: str Type of lattice structure (e.g., ‘BCC’, ‘Hybrid1’, etc.)
float
Radius of the beam
int
Type index of the beam
set
Set of beams already defined in the lattice to avoid duplication
set
Set of nodes already defined in the lattice to avoid duplication
get_beam_material()
¶
Get the material of the beam based on the material gradient.
get_radius(base_radius)
¶
def_cell_size(initial_cell_size)
¶
def_cell_center()
¶
Calculate the center point of the cell
get_point_on_surface(surfaceName)
¶
Get the points on the surface specified in the global reference frame.
Parameters:¶
surfaceName: str Name of the surface. Choose from ‘Xmin’, ‘Xmax’, ‘Ymin’, ‘Ymax’, ‘Zmin’, ‘Zmax’, ‘Xmid’, ‘Ymid’, ‘Zmid’. If ‘Xmid’, ‘Ymid’, or ‘Zmid’ is specified, it returns the points at the bottom of the cell
Returns:¶
list List of points on the specified surface.
remove_beam(beam_to_delete)
¶
Removing beam from cell
Parameters:¶
beam_to_delete: Beam or Iterable[Beam] Beam or list of beams to remove from the cell
remove_point(point_to_delete)
¶
Removing point from cell
Parameters:¶
point_to_delete: Point or Iterable[Point] Point or list of points to remove from the cell
add_beam(beam_to_add)
¶
Adding beam to cell
Parameters:¶
beam_to_add: Beam or Iterable[Beam] Beam or list of beams to add to the cell
add_point(point_to_add)
¶
Adding point to cell
Parameters:¶
point_to_add: Point or Iterable[Point] Point or list of points to add to the cell
add_cell_neighbour(direction, sign, neighbour_cell)
¶
Add a neighbour cell in a structured dict format.
Parameters¶
direction : str One of “x”, “y”, “z” sign : str Either “positif” or “negatif” neighbour_cell : Cell Neighbour cell to add
get_all_cell_neighbours()
¶
refresh_from_global(all_beams)
¶
Rebuild self.beams_cell and self.points_cell from the current lattice state. Keeps only beams that still declare this cell as a belonging, and derives points from those beams.
define_node_order_to_simulate(face_priority=None, tol=1e-09)
¶
Define a deterministic order for boundary nodes to ensure consistent simulation results.
Parameters:¶
face_priority: Optional[List[str]] List defining the priority order of faces to assign nodes to when they lie on multiple faces. Default is [“Xmin”, “Xmax”, “Ymin”, “Ymax”, “Zmin”, “Zmax”].
float
Tolerance for determining if a point lies on a face. Default is 1e-9.
set_reaction_force_on_nodes(reactionForce)
¶
Set reaction force on each boundary node in the established local order.
Parameters:¶
reactionForce: list List of reaction force vectors corresponding to each boundary node.
get_displacement_at_nodes(nodeList)
¶
set_displacement_at_boundary_nodes(displacementArray)
¶
Set displacement at nodes.
Parameters:¶
displacementArray: list or array-like Flattened array of displacement values.
build_coupling_operator(nb_free_DOF)
¶
Build the coupling operator B using the deterministic local boundary-node order.
Parameters:¶
nb_free_DOF: int Total number of free degrees of freedom in the global system.
build_local_preconditioner(schur_mean=None)
¶
Build the local preconditioner matrix B^T * S * B
Parameters:¶
schur_mean: array-like or None Schur complement matrix to use. If None, uses self.schur_complement.
get_number_boundary_nodes()
¶
Get the number of unique boundary nodes in the cell.
get_internal_energy()
¶
Get cell internal energy from all boundary points
get_displacement_data()
¶
Build and return displacement data on cell for dataset generation
get_number_nodes_at_boundary()
¶
change_beam_radius(new_radius)
¶
WARNING: BEAM MOD IS NOT WORKING Change beam radii in the cell
Parameters:¶
newRadius: list beam radii wanted to assign
get_relative_density_kriging(kriging_model)
¶
Get the relative density of the cell using kriging model
Parameters:¶
krigingModel: Kriging Kriging model to use for prediction
get_relative_density_gradient(relative_density_poly_deriv)
¶
get_relative_density_gradient_kriging(model, geometries_types)
¶
Finite difference gradient of the relative density (predictive mean) w.r.t. the radii using the trained Pipeline(StandardScaler -> GaussianProcessRegressor) with Constant*RBF kernel. Returns an array of size len(geometries_types) where entries for geometries not present in the cell are 0.
get_relative_density_gradient_kriging_exact(model, geometries_types)
¶
Exact gradient of the relative density (predictive mean) w.r.t. the radii using the trained Pipeline(StandardScaler -> GaussianProcessRegressor) with Constant*RBF kernel.
Returns an array of size len(geometries_types) where entries for geometries not present in the cell are 0.
Parameters:¶
model: Pipeline Trained kriging model
list
List of geometry types in the trained kriging model
get_RGBcolor_depending_of_radius()
¶
Get the RGB color of the cell depending on the radii.
print_data()
¶
Print the data of the cell for debugging purposes.
get_translation_rigid_body()
¶
Get the translation of the rigid body
get_rotation_rigid_body()
¶
Get the rotation matrix of the rigid body using SVD.
OptimizationPlotter
¶
Class to plot the optimization progress of a lattice structure.
Parameters¶
lattice : LatticeOpti The lattice optimization object.
bool, optional
Whether to enable the radius field subplot (default: False).
Methods:
| Name | Description |
|---|---|
update |
Update the plots with new data. |
finalize |
Finalize the plotting. |
LatticeOpti
¶
Bases: LatticeSim
Superclass of lattice for optimization purposes
Methods:
| Name | Description |
|---|---|
optimize_lattice |
Runs the optimization process using SLSQP. |
redefine_optim_parameters |
Redefine optimization parameters |
objective |
Objective function for the optimization |
set_optimization_parameters |
Set optimization parameters for the lattice |
calculate_objective |
Calculate objective function for the lattice optimization |
compute_compliance |
Compliance (external work of applied loads): |
compute_global_energy |
Global external work = global strain energy |
compute_global_energy_ddm |
Global external work = global strain energy for DDM simulation |
gradient |
Gradient function for the optimization |
calculate_gradient |
Compute d(objective)/d(params) for the current state. |
finite_difference_gradient |
Approximate the gradient of the normalized objective w.r.t. the optimizer parameters |
density_constraint |
Density constraint function |
density_constraint_gradient |
Density constraint gradient function |
get_relative_density_constraint |
Get relative density of the lattice |
get_relative_density |
Get mean relative density of all cells in lattice |
get_relative_density_gradient |
Get relative density gradient of the lattice |
get_relative_density_gradient_kriging |
Get relative density gradient of the lattice using kriging model |
finite_difference_density_gradient |
Approximate the gradient of the density constraint g(θ) = ρ̄(θ) - ρ_target |
define_relative_density_function |
Define relative density function |
normalize_objective |
Return C/C_0 when normalization is enabled; otherwise return C. |
denormalize_optimization_parameters |
Denormalize optimization parameters |
normalize_optimization_parameters |
Normalize optimization parameters |
get_radius_continuity_difference |
Get the difference in radii between connected beams in the lattice |
get_radius_continuity_jacobian |
Compute the Jacobian of the radii continuity constraint. |
load_relative_density_model |
Load the relative density model from a file |
callback_function |
Callback function for the optimization (Printing and plotting) |
save_optimization_json |
Save optimization data (history + summary + useful metadata) to a JSON file. |
optimize_lattice()
¶
Runs the optimization process using SLSQP.
redefine_optim_parameters(max_iteration=None, ftol=None, disp=None, eps=None)
¶
Redefine optimization parameters
Parameters:¶
max_iteration: int Maximum number of iterations for the optimizer
float
Tolerance for termination by the optimizer
bool
Whether to display optimization messages
float
Step size for numerical approximation of the Jacobian
objective(r)
¶
set_optimization_parameters(optimization_parameters_actual)
¶
Set optimization parameters for the lattice
Parameters:¶
optimization_parameters_actual: list of float List of actual optimization parameters
calculate_objective()
¶
Calculate objective function for the lattice optimization
Returns¶
objectiveValue: float Objective function value
compute_compliance()
¶
Compliance (external work of applied loads): C = sum_k f_k * u_k
compute_global_energy()
¶
Global external work = global strain energy
compute_global_energy_ddm()
¶
Global external work = global strain energy for DDM simulation
Returns:¶
energy: float Global strain energy
gradient(r)
¶
Gradient function for the optimization
Parameters:¶
r: list of float List of optimization parameters
calculate_gradient()
¶
Compute d(objective)/d(params) for the current state. - ‘compliance’: u^T (dS/dr) u (per parameter block). - ‘displacement’: λ^T (dS/dr) u with adjoint S λ = ∂J/∂u, J = average of |selected DOFs|.
Returns:¶
grad: np.ndarray Gradient vector
finite_difference_gradient(r, eps=1e-06, scheme='central')
¶
Approximate the gradient of the normalized objective w.r.t. the optimizer parameters using finite differences, in the same parameter space as SLSQP.
Parameters¶
r : array-like Current optimization parameters (normalized if enable_normalization=True).
float
Finite-difference step (applied in the same space as r).
{“central”,”forward”,”backward”}
Finite-difference scheme.
Returns¶
np.ndarray Approximate gradient vector (same shape as r).
density_constraint(r)
¶
density_constraint_gradient(r)
¶
get_relative_density_constraint()
¶
Get relative density of the lattice
get_relative_density()
¶
Get mean relative density of all cells in lattice
Returns:¶
meanRelDens: float Mean relative density of the lattice
get_relative_density_gradient()
¶
Get relative density gradient of the lattice
Returns:¶
grad: list of float Gradient of relative density
get_relative_density_gradient_kriging()
¶
Get relative density gradient of the lattice using kriging model
Returns:¶
grad: list of float Gradient of relative density
finite_difference_density_gradient(r, eps=0.01, scheme='central')
¶
Approximate the gradient of the density constraint g(θ) = ρ̄(θ) - ρ_target with finite differences in the SAME parameter space as the optimizer (θ).
Parameters:¶
r: list of float List of optimization parameters
float
Finite difference step size
str
Finite difference scheme: “forward”, “backward”, or “central”
define_relative_density_function(degree=3)
¶
Define relative density function Possible to define a more complex function with dependency on hybrid cells
Parameters:¶
degree: int Degree of the polynomial function
normalize_objective(value)
¶
Return C/C_0 when normalization is enabled; otherwise return C.
denormalize_optimization_parameters(r_norm)
¶
normalize_optimization_parameters(r)
¶
get_radius_continuity_difference(delta=0.01)
¶
Get the difference in radii between connected beams in the lattice
Parameters:¶
delta: float Minimum difference in radii between connected cells
get_radius_continuity_jacobian()
¶
Compute the Jacobian of the radii continuity constraint.
Returns:¶
np.ndarray Jacobian matrix of shape (num_constraints, num_radii)
load_relative_density_model()
¶
callback_function(r)
¶
Callback function for the optimization (Printing and plotting)
open_lattice_parameters(file_name)
¶
Open a JSON file containing lattice parameters.
Parameters:¶
file_name: str Name of the JSON file containing lattice parameters.
_find_path_to_data(lattice_cell)
¶
Determine a default dataset path based on lattice geometry.
_opt_import(mod, name, pkg_label='SciPy')
¶
pyLatticeOpti.plotting_lattice_optim
¶
Classes:
| Name | Description |
|---|---|
OptimizationPlotter |
Class to plot the optimization progress of a lattice structure. |
OptimizationPlotter
¶
Class to plot the optimization progress of a lattice structure.
Parameters¶
lattice : LatticeOpti The lattice optimization object.
bool, optional
Whether to enable the radius field subplot (default: False).
Methods:
| Name | Description |
|---|---|
update |
Update the plots with new data. |
finalize |
Finalize the plotting. |
pyLatticeOpti.surrogate_model_relative_densities
¶
Functions:
| Name | Description |
|---|---|
_import_sklearn_pipeline |
|
_opt_import |
Import a symbol lazily. If unavailable, return a stub that raises |
_find_path_to_data |
Determine a default dataset path based on lattice geometry. |
compute_relative_densities_dataset |
Compute relative densities for a range of radii in the lattice. |
save_dataset |
Save the dataset as a pickle file (atomic write). |
load_dataset |
Load a dataset previously saved as a pickle file and optionally filter it. |
csv_to_dataset |
Convert a CSV file with columns Radius1, Radius2, Radius3, Volume |
_valid_combinations |
Generate all valid radius combinations given the grid and a sum threshold. |
check_missing_entries |
Check which radius combinations are missing in an existing dataset file (if any). |
_load_dataset_for_plotting |
Helper to load dataset for plotting functions. |
plot_3D_iso_surface |
Plot 3D iso-surfaces of volume as a function of three radii using interpolation. |
plot_3D_scatter |
Plot 3D scatter of relative densities as a function of three radii. |
remove_large_volume_variations_dict |
Delete entries in the relative_densities dict where neighboring points (in radius space) |
evaluate_kriging_from_pickle |
Train and evaluate a Kriging (GPR) model from a relative-density dataset saved as a pickle. |
plot_parity |
Plot parity plot (true vs predicted values) with R² and RMSE annotation. |
evaluate_saved_kriging |
Load a previously trained Kriging model and a dataset, then evaluate and (optionally) plot a parity plot. |
gp_mean_gradient_rbf_pipeline |
Exact gradient of the GPR predictive mean wrt inputs for either: |
Attributes:
| Name | Type | Description |
|---|---|---|
Pipeline |
|
|
StandardScaler |
|
|
GaussianProcessRegressor |
|
|
RBF |
|
|
ConstantKernel |
|
|
WhiteKernel |
|
|
train_test_split |
|
|
mean_squared_error |
|
|
r2_score |
|
|
mean_absolute_error |
|
|
griddata |
|
Pipeline = _import_sklearn_pipeline()
module-attribute
¶
StandardScaler = _opt_import('sklearn.preprocessing', 'StandardScaler')
module-attribute
¶
GaussianProcessRegressor = _opt_import('sklearn.gaussian_process', 'GaussianProcessRegressor')
module-attribute
¶
RBF = _opt_import('sklearn.gaussian_process.kernels', 'RBF')
module-attribute
¶
ConstantKernel = _opt_import('sklearn.gaussian_process.kernels', 'ConstantKernel')
module-attribute
¶
WhiteKernel = _opt_import('sklearn.gaussian_process.kernels', 'WhiteKernel')
module-attribute
¶
train_test_split = _opt_import('sklearn.model_selection', 'train_test_split')
module-attribute
¶
mean_squared_error = _opt_import('sklearn.metrics', 'mean_squared_error')
module-attribute
¶
r2_score = _opt_import('sklearn.metrics', 'r2_score')
module-attribute
¶
mean_absolute_error = _opt_import('sklearn.metrics', 'mean_absolute_error')
module-attribute
¶
griddata = _opt_import('scipy.interpolate', 'griddata', pkg_label='SciPy')
module-attribute
¶
_import_sklearn_pipeline()
¶
_opt_import(mod, name, pkg_label='scikit-learn')
¶
Import a symbol lazily. If unavailable, return a stub that raises a clear RuntimeError only when used (runtime), not at import time.
_find_path_to_data(lattice_cell)
¶
Determine a default dataset path based on lattice geometry.
compute_relative_densities_dataset(lattice_cell, step_radius=0.01, range_radius=(0.0, 0.11), save_every=1, resume=True)
¶
Compute relative densities for a range of radii in the lattice.
Periodically saves partial results every save_every iterations and can resume if a file exists.
save_dataset(path_dataset, name_dataset, relative_densities_dict)
¶
Save the dataset as a pickle file (atomic write).
load_dataset(path_dataset, name_dataset, min_vol=0.0, max_vol=0.6, apply_variation_filter=True)
¶
Load a dataset previously saved as a pickle file and optionally filter it.
Parameters¶
path_dataset : Path Path to the directory containing the dataset.
str
Name of the dataset (without extension).
float, optional
Minimum volume to keep (None = no lower filter).
float, optional
Maximum volume to keep (None = no upper filter).
bool, optional
If True, apply the remove_large_volume_variations_dict filter.
Returns¶
dict Dictionary of relative densities keyed by radii tuple.
csv_to_dataset(csv_file)
¶
Convert a CSV file with columns Radius1, Radius2, Radius3, Volume into the dict format { (r1, r2, r3): volume } and save it with save_dataset.
_valid_combinations(step_radius, range_radius, n_geom, threshold=0.001)
¶
Generate all valid radius combinations given the grid and a sum threshold.
check_missing_entries(path_dataset, name_dataset, step_radius, range_radius, n_geom, threshold=0.001)
¶
Check which radius combinations are missing in an existing dataset file (if any). Returns a dict with counts and the list of missing combinations.
_load_dataset_for_plotting(lattice_cell=None, name_dataset=None)
¶
Helper to load dataset for plotting functions.
plot_3D_iso_surface(lattice_cell=None, name_dataset=None, n_levels=10)
¶
Plot 3D iso-surfaces of volume as a function of three radii using interpolation.
Parameters¶
lattice_cell : Lattice Lattice object with exactly one cell and three geometry types.
str
Name of the dataset to load (without extension).
int, optional
Number of iso-surface levels to plot (default is 10).
plot_3D_scatter(lattice_cell=None, name_dataset=None)
¶
Plot 3D scatter of relative densities as a function of three radii.
Parameters¶
lattice_cell : Lattice Lattice object with exactly one cell and three geometry types.
remove_large_volume_variations_dict(relative_densities, distance_threshold=0.02, variation_threshold=0.1)
¶
Delete entries in the relative_densities dict where neighboring points (in radius space) have volume differences exceeding variation_threshold.
Parameters¶
relative_densities : dict Dictionary with keys as radius tuples and values as relative densities.
float
Maximum distance in radius space to consider points as neighbors.
float
Maximum allowed volume difference between neighboring points.
Returns¶
dict Filtered dictionary with large variations removed.
evaluate_kriging_from_pickle(dataset_dir, name_dataset, test_size=0.2, model_name='kriging_model_', normalize_y=True, random_state=42, min_vol=0.0, max_vol=0.6, apply_variation_filter=True)
¶
Train and evaluate a Kriging (GPR) model from a relative-density dataset saved as a pickle.
Parameters¶
dataset_dir : Path
Directory that contains ‘compute_relative_densities_dataset.
str
Dataset base name (without extension).
float, optional
Fraction of samples used for testing (default 0.2).
str | Path, optional
Relative path (from the project root) where the trained model will be saved.
bool, optional
Whether to normalize the target inside the regressor (default True).
int, optional
Random seed for reproducibility.
min_vol, max_vol : float, optional Filtering bounds for volumes (default 0.0–0.6).
bool, optional
If True, apply the remove_large_volume_variations_dict filter.
Returns¶
dict Evaluation metrics and paths. Keys: ‘MSE’, ‘RMSE’, ‘NRMSE’, ‘MAE’, ‘R2’, ‘n_train’, ‘n_test’, ‘model_path’, ‘kernel_’
plot_parity(y_true, y_pred, save_path=None)
¶
Plot parity plot (true vs predicted values) with R² and RMSE annotation.
Parameters¶
y_true : array-like Ground-truth values (test set).
array-like
Predicted values (test set).
str or Path, optional
If provided, saves the figure to this path.
evaluate_saved_kriging(dataset_dir, name_dataset, model_name=None, use_test_split=True, test_size=0.9, random_state=42, min_vol=0.0, max_vol=0.6, apply_variation_filter=True, save_parity_path=None)
¶
Load a previously trained Kriging model and a dataset, then evaluate and (optionally) plot a parity plot.
Parameters¶
dataset_dir : Path | None
Directory containing ‘
str
Dataset base name (without extension).
str | None
Relative path (from the project root) to the saved model.
bool
If True, evaluate on a train/test split (reproducible with random_state).
If False, evaluate on the whole dataset.
float
Fraction of samples for testing when use_test_split=True.
int
Random seed for the split.
min_vol, max_vol : float
Volume filtering bounds passed to load_dataset.
bool
Apply remove_large_volume_variations_dict during dataset loading.
Path | None
If provided, saves the parity plot to this path.
Returns¶
dict Metrics and metadata: ‘MSE’,’RMSE’,’NRMSE’,’MAE’,’R2’,’n_eval’,’model_kernel’,’model_path’
gp_mean_gradient_rbf_pipeline(model, x_row)
¶
Exact gradient of the GPR predictive mean wrt inputs for either
• Pipeline(StandardScaler -> GaussianProcessRegressor), or • bare GaussianProcessRegressor trained in original space.
Supports kernels
- RBF
- ConstantKernel * RBF
- (ConstantKernel * RBF) + WhiteKernel
- RBF + WhiteKernel
Returns dmu/dx in ORIGINAL (unscaled) space.