Pipeline Examples¶
This notebook demonstrates the end-to-end process of building a machine learning pipeline using PLAID datasets and PLAID’s scikit-learn-compatible blocks.
📦 Imports¶
import warnings
warnings.filterwarnings('ignore', module='sklearn')
warnings.filterwarnings("ignore", message=".*IProgress not found.*")
import os
os.environ["OMP_PROC_BIND"] = "spread"
os.environ["OMP_PLACES"] = "threads"
from pathlib import Path
import yaml
import numpy as np
import optuna
from datasets.utils.logging import disable_progress_bar
from datasets import load_dataset
from sklearn.base import clone
from sklearn.pipeline import Pipeline
from sklearn.decomposition import PCA
from sklearn.preprocessing import MinMaxScaler
from sklearn.gaussian_process import GaussianProcessRegressor
from sklearn.gaussian_process.kernels import Matern
from sklearn.multioutput import MultiOutputRegressor
from sklearn.model_selection import KFold, GridSearchCV
from plaid.bridges.huggingface_bridge import huggingface_dataset_to_plaid, huggingface_description_to_problem_definition
from plaid.pipelines.sklearn_block_wrappers import WrappedPlaidSklearnTransformer, WrappedPlaidSklearnRegressor
from plaid.pipelines.plaid_blocks import PlaidTransformedTargetRegressor, PlaidColumnTransformer
from mmgp.pipelines.mmgp_blocks import MMGPPreparer, MMGPTransformer, renumber_mesh_for_parametrization, floater_mesh_parametrization
from Muscat.Containers.MeshGraphTools import FloaterMeshParametrization, RenumberMeshForParametrization
disable_progress_bar()
n_processes = min(max(1, os.cpu_count()), 4)
🚀 MMGP for U1 field prediction of Tensile2d dataset¶
Key steps covered:
Loading and preparing the PLAID dataset using Hugging Face integration and PLAID’s dataset classes
Standardizing features with PLAID-wrapped scikit-learn transformers for scalars and fields
Dimensionality reduction of flow fields via Principal Component Analysis (PCA) to reduce output complexity
Regression modeling of PCA coefficients from scalar inputs using Gaussian Process regression
Pipeline assembly combining transformations and regressors into a single scikit-learn-compatible workflow
Hyperparameter tuning using Optuna and scikit-learn’s
GridSearchCVModel evaluation using cross-validation and appropriate metrics
Best practices for working with PLAID datasets and pipelines in a reproducible and modular manner
📥 Load Dataset¶
We load the Tensile2d dataset from Hugging Face and restrict ourselves to the first 24 samples of the training set.
hf_dataset = load_dataset("PLAID-datasets/Tensile2d", split="all_samples[:6]")
dataset_train, _ = huggingface_dataset_to_plaid(hf_dataset, processes_number = 6, verbose = False)
try:
filename = Path(__file__).parent.parent.parent / "docs" / "source" / "notebooks" / "config_pipeline.yml"
except NameError:
filename = "config_pipeline.yml"
with open(filename, 'r') as f:
config = yaml.safe_load(f)
all_feature_id = config['input_scalar_scaler']['in_features_identifiers'] +\
config['pca_nodes']['in_features_identifiers'] + config['pca_u1']['in_features_identifiers']
dataset_train = dataset_train.from_features_identifier(all_feature_id)
print("dataset_train:", dataset_train)
print("scalar names =", dataset_train.get_scalar_names())
print("field names =", dataset_train.get_field_names())
dataset_train: Dataset(6 samples, 6 scalars, 0 time_series, 1 field)
scalar names = ['P', 'p1', 'p2', 'p3', 'p4', 'p5']
field names = ['U1']
def morphing(mesh):
mesh_renumb, _, n_boundary = RenumberMeshForParametrization(
mesh, inPlace=False)
mesh_renumb.elemFields = mesh_renumb.nodeFields = {}
morphed_mesh, _ = FloaterMeshParametrization(
mesh_renumb, n_boundary)
return morphed_mesh
preparator = MMGPPreparer(common_mesh_id = 1, morphing = morphing)
input_scalar_scaler = WrappedPlaidSklearnTransformer(MinMaxScaler(), **config['input_scalar_scaler'])
nodes_preprocessor = Pipeline(
steps=[
("mmgp_nodes_transf", MMGPTransformer(**config['mmgp_nodes_transf'])),
('pca_nodes', WrappedPlaidSklearnTransformer(PCA(n_components=4), **config['pca_nodes'])),
]
)
column_preprocessor = PlaidColumnTransformer(
[
('input_scalar_scaler', input_scalar_scaler),
('nodes_preprocessor', nodes_preprocessor),
]
)
preprocessor = Pipeline(
steps=[
("preparator", preparator),
('column_preprocessor', column_preprocessor),
]
)
preprocessor
Pipeline(steps=[('preparator',
MMGPPreparer(common_mesh_id=1,
morphing=<function morphing at 0x7651fca6b560>)),
('column_preprocessor',
PlaidColumnTransformer(plaid_transformers=[('input_scalar_scaler',
WrappedPlaidSklearnTransformer(in_features_identifiers=[{'name': 'P',
'type': 'scalar'},
{'name': 'p1',
'type': 'scalar'},
{'name': 'p2',
'type': 'scalar'},
{'name': 'p...
sklearn_block=MinMaxScaler())),
('nodes_preprocessor',
Pipeline(steps=[('mmgp_nodes_transf',
MMGPTransformer(in_features_identifiers=[{'type': 'nodes'}])),
('pca_nodes',
WrappedPlaidSklearnTransformer(in_features_identifiers=[{'type': 'nodes'}],
out_features_identifiers=[{'name': 'reduced_nodes_*',
'type': 'scalar'}],
sklearn_block=PCA(n_components=4)))]))]))])In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
Parameters
| steps | [('preparator', ...), ('column_preprocessor', ...)] | |
| transform_input | None | |
| memory | None | |
| verbose | False |
Parameters
| common_mesh_id | 1 | |
| morphing | <function mor...x7651fca6b560> |
Parameters
| plaid_transformers | [('input_scalar_scaler', ...), ('nodes_preprocessor', ...)] |
_
MinMaxScaler()
Parameters
| feature_range | (0, ...) | |
| copy | True | |
| clip | False |
_
Parameters
| in_features_identifiers | [{'type': 'nodes'}] |
Parameters
| sklearn_block | PCA(n_components=4) | |
| in_features_identifiers | [{'type': 'nodes'}] | |
| out_features_identifiers | [{'name': 'reduced_nodes_*', 'type': 'scalar'}] |
PCA(n_components=4)
Parameters
| n_components | 4 | |
| copy | True | |
| whiten | False | |
| svd_solver | 'auto' | |
| tol | 0.0 | |
| iterated_power | 'auto' | |
| n_oversamples | 10 | |
| power_iteration_normalizer | 'auto' | |
| random_state | None |
kernel = Matern(length_scale_bounds=(1e-8, 1e8), nu = 2.5)
gpr = GaussianProcessRegressor(
kernel=kernel,
optimizer='fmin_l_bfgs_b',
n_restarts_optimizer=1,
random_state=42)
reg = MultiOutputRegressor(gpr)
def length_scale_init(X):
return np.ones(X.shape[1])
dynamics_params_factory = {'estimator__kernel__length_scale':length_scale_init}
regressor = WrappedPlaidSklearnRegressor(reg, **config['regressor_mach'], dynamics_params_factory = dynamics_params_factory)
postprocessor = Pipeline(
steps=[
("mmgp_u1_transf", MMGPTransformer(**config['mmgp_u1_transf'])),
('pca_u1', WrappedPlaidSklearnTransformer(PCA(n_components=4), **config['pca_u1'])),
]
)
target_regressor = PlaidTransformedTargetRegressor(
regressor=regressor,
transformer=postprocessor,
# out_features_identifiers = config['pca_u1']['in_features_identifiers']
)
target_regressor
PlaidTransformedTargetRegressor(regressor=WrappedPlaidSklearnRegressor(dynamics_params_factory={'estimator__kernel__length_scale': <function length_scale_init at 0x7651fca6b740>},
in_features_identifiers=[{'name': 'P',
'type': 'scalar'},
{'name': 'p1',
'type': 'scalar'},
{'name': 'p2',
'type': 'scalar'},
{'name': 'p3',
'type': 'scalar'},
{'name': 'p4',
'type': 'scalar'},
{...
n_restarts_optimizer=1,
random_state=42))),
transformer=Pipeline(steps=[('mmgp_u1_transf',
MMGPTransformer(in_features_identifiers=[{'name': 'U1',
'type': 'field'}])),
('pca_u1',
WrappedPlaidSklearnTransformer(in_features_identifiers=[{'name': 'U1',
'type': 'field'}],
out_features_identifiers=[{'name': 'reduced_U1_*',
'type': 'scalar'}],
sklearn_block=PCA(n_components=4)))]))In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
Parameters
| regressor | WrappedPlaidS...om_state=42))) | |
| transformer | Pipeline(step...ponents=4)))]) |
WrappedPlaidSklearnRegressor(dynamics_params_factory={'estimator__kernel__length_scale': <function length_scale_init at 0x7651fca6b740>},
in_features_identifiers=[{'name': 'P',
'type': 'scalar'},
{'name': 'p1',
'type': 'scalar'},
{'name': 'p2',
'type': 'scalar'},
{'name': 'p3',
'type': 'scalar'},
{'name': 'p4',
'type': 'scalar'},
{'name': 'p5',
'type': 'scalar'},
{'name': 'reduced_nodes_*',
'type': 'scalar'}],
out_features_identifiers=[{'name': 'reduced_U1_*',
'type': 'scalar'}],
sklearn_block=MultiOutputRegressor(estimator=GaussianProcessRegressor(kernel=Matern(length_scale=1, nu=2.5),
n_restarts_optimizer=1,
random_state=42)))MultiOutputRegressor(estimator=GaussianProcessRegressor(kernel=Matern(length_scale=1, nu=2.5),
n_restarts_optimizer=1,
random_state=42))GaussianProcessRegressor(kernel=Matern(length_scale=1, nu=2.5),
n_restarts_optimizer=1, random_state=42)Parameters
| kernel | Matern(length_scale=1, nu=2.5) | |
| alpha | 1e-10 | |
| optimizer | 'fmin_l_bfgs_b' | |
| n_restarts_optimizer | 1 | |
| normalize_y | False | |
| copy_X_train | True | |
| n_targets | None | |
| random_state | 42 | |
| kernel__length_scale | 1.0 | |
| kernel__length_scale_bounds | (1e-08, ...) | |
| kernel__nu | 2.5 |
Parameters
| in_features_identifiers | [{'name': 'U1', 'type': 'field'}] |
Parameters
| sklearn_block | PCA(n_components=4) | |
| in_features_identifiers | [{'name': 'U1', 'type': 'field'}] | |
| out_features_identifiers | [{'name': 'reduced_U1_*', 'type': 'scalar'}] |
PCA(n_components=4)
Parameters
| n_components | 4 | |
| copy | True | |
| whiten | False | |
| svd_solver | 'auto' | |
| tol | 0.0 | |
| iterated_power | 'auto' | |
| n_oversamples | 10 | |
| power_iteration_normalizer | 'auto' | |
| random_state | None |
pipeline = Pipeline(
steps=[
("preprocessor", preprocessor),
("regressor", target_regressor),
]
)
pipeline
Pipeline(steps=[('preprocessor',
Pipeline(steps=[('preparator',
MMGPPreparer(common_mesh_id=1,
morphing=<function morphing at 0x7651fca6b560>)),
('column_preprocessor',
PlaidColumnTransformer(plaid_transformers=[('input_scalar_scaler',
WrappedPlaidSklearnTransformer(in_features_identifiers=[{'name': 'P',
'type': 'scalar'},
{'name': 'p1',
'type': 'scalar'},
{'name':...
n_restarts_optimizer=1,
random_state=42))),
transformer=Pipeline(steps=[('mmgp_u1_transf',
MMGPTransformer(in_features_identifiers=[{'name': 'U1',
'type': 'field'}])),
('pca_u1',
WrappedPlaidSklearnTransformer(in_features_identifiers=[{'name': 'U1',
'type': 'field'}],
out_features_identifiers=[{'name': 'reduced_U1_*',
'type': 'scalar'}],
sklearn_block=PCA(n_components=4)))])))])In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
Parameters
| steps | [('preprocessor', ...), ('regressor', ...)] | |
| transform_input | None | |
| memory | None | |
| verbose | False |
Parameters
| steps | [('preparator', ...), ('column_preprocessor', ...)] | |
| transform_input | None | |
| memory | None | |
| verbose | False |
Parameters
| common_mesh_id | 1 | |
| morphing | <function mor...x7651fca6b560> |
Parameters
| plaid_transformers | [('input_scalar_scaler', ...), ('nodes_preprocessor', ...)] |
_
MinMaxScaler()
Parameters
| feature_range | (0, ...) | |
| copy | True | |
| clip | False |
_
Parameters
| in_features_identifiers | [{'type': 'nodes'}] |
Parameters
| sklearn_block | PCA(n_components=4) | |
| in_features_identifiers | [{'type': 'nodes'}] | |
| out_features_identifiers | [{'name': 'reduced_nodes_*', 'type': 'scalar'}] |
PCA(n_components=4)
Parameters
| n_components | 4 | |
| copy | True | |
| whiten | False | |
| svd_solver | 'auto' | |
| tol | 0.0 | |
| iterated_power | 'auto' | |
| n_oversamples | 10 | |
| power_iteration_normalizer | 'auto' | |
| random_state | None |
Parameters
| regressor | WrappedPlaidS...om_state=42))) | |
| transformer | Pipeline(step...ponents=4)))]) |
WrappedPlaidSklearnRegressor(dynamics_params_factory={'estimator__kernel__length_scale': <function length_scale_init at 0x7651fca6b740>},
in_features_identifiers=[{'name': 'P',
'type': 'scalar'},
{'name': 'p1',
'type': 'scalar'},
{'name': 'p2',
'type': 'scalar'},
{'name': 'p3',
'type': 'scalar'},
{'name': 'p4',
'type': 'scalar'},
{'name': 'p5',
'type': 'scalar'},
{'name': 'reduced_nodes_*',
'type': 'scalar'}],
out_features_identifiers=[{'name': 'reduced_U1_*',
'type': 'scalar'}],
sklearn_block=MultiOutputRegressor(estimator=GaussianProcessRegressor(kernel=Matern(length_scale=1, nu=2.5),
n_restarts_optimizer=1,
random_state=42)))MultiOutputRegressor(estimator=GaussianProcessRegressor(kernel=Matern(length_scale=1, nu=2.5),
n_restarts_optimizer=1,
random_state=42))GaussianProcessRegressor(kernel=Matern(length_scale=1, nu=2.5),
n_restarts_optimizer=1, random_state=42)Parameters
| kernel | Matern(length_scale=1, nu=2.5) | |
| alpha | 1e-10 | |
| optimizer | 'fmin_l_bfgs_b' | |
| n_restarts_optimizer | 1 | |
| normalize_y | False | |
| copy_X_train | True | |
| n_targets | None | |
| random_state | 42 | |
| kernel__length_scale | 1.0 | |
| kernel__length_scale_bounds | (1e-08, ...) | |
| kernel__nu | 2.5 |
Parameters
| in_features_identifiers | [{'name': 'U1', 'type': 'field'}] |
Parameters
| sklearn_block | PCA(n_components=4) | |
| in_features_identifiers | [{'name': 'U1', 'type': 'field'}] | |
| out_features_identifiers | [{'name': 'reduced_U1_*', 'type': 'scalar'}] |
PCA(n_components=4)
Parameters
| n_components | 4 | |
| copy | True | |
| whiten | False | |
| svd_solver | 'auto' | |
| tol | 0.0 | |
| iterated_power | 'auto' | |
| n_oversamples | 10 | |
| power_iteration_normalizer | 'auto' | |
| random_state | None |
pipeline.fit(dataset_train)
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
Pipeline(steps=[('preprocessor',
Pipeline(steps=[('preparator',
MMGPPreparer(common_mesh_id=1,
morphing=<function morphing at 0x7651fca6b560>)),
('column_preprocessor',
PlaidColumnTransformer(plaid_transformers=[('input_scalar_scaler',
WrappedPlaidSklearnTransformer(in_features_identifiers=[{'name': 'P',
'type': 'scalar'},
{'name': 'p1',
'type': 'scalar'},
{'name':...
n_restarts_optimizer=1,
random_state=42))),
transformer=Pipeline(steps=[('mmgp_u1_transf',
MMGPTransformer(in_features_identifiers=[{'name': 'U1',
'type': 'field'}])),
('pca_u1',
WrappedPlaidSklearnTransformer(in_features_identifiers=[{'name': 'U1',
'type': 'field'}],
out_features_identifiers=[{'name': 'reduced_U1_*',
'type': 'scalar'}],
sklearn_block=PCA(n_components=4)))])))])In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
Parameters
| steps | [('preprocessor', ...), ('regressor', ...)] | |
| transform_input | None | |
| memory | None | |
| verbose | False |
Parameters
| steps | [('preparator', ...), ('column_preprocessor', ...)] | |
| transform_input | None | |
| memory | None | |
| verbose | False |
Parameters
| common_mesh_id | 1 | |
| morphing | <function mor...x7651fca6b560> |
Parameters
| plaid_transformers | [('input_scalar_scaler', ...), ('nodes_preprocessor', ...)] |
_
MinMaxScaler()
Parameters
| feature_range | (0, ...) | |
| copy | True | |
| clip | False |
_
Parameters
| in_features_identifiers | [{'type': 'nodes'}] |
Parameters
| sklearn_block | PCA(n_components=4) | |
| in_features_identifiers | [{'type': 'nodes'}] | |
| out_features_identifiers | [{'name': 'reduced_nodes_*', 'type': 'scalar'}] |
PCA(n_components=4)
Parameters
| n_components | 4 | |
| copy | True | |
| whiten | False | |
| svd_solver | 'auto' | |
| tol | 0.0 | |
| iterated_power | 'auto' | |
| n_oversamples | 10 | |
| power_iteration_normalizer | 'auto' | |
| random_state | None |
Parameters
| regressor | WrappedPlaidS...om_state=42))) | |
| transformer | Pipeline(step...ponents=4)))]) |
WrappedPlaidSklearnRegressor(dynamics_params_factory={'estimator__kernel__length_scale': <function length_scale_init at 0x7651fca6b740>},
in_features_identifiers=[{'name': 'P',
'type': 'scalar'},
{'name': 'p1',
'type': 'scalar'},
{'name': 'p2',
'type': 'scalar'},
{'name': 'p3',
'type': 'scalar'},
{'name': 'p4',
'type': 'scalar'},
{'name': 'p5',
'type': 'scalar'},
{'name': 'reduced_nodes_*',
'type': 'scalar'}],
out_features_identifiers=[{'name': 'reduced_U1_*',
'type': 'scalar'}],
sklearn_block=MultiOutputRegressor(estimator=GaussianProcessRegressor(kernel=Matern(length_scale=1, nu=2.5),
n_restarts_optimizer=1,
random_state=42)))MultiOutputRegressor(estimator=GaussianProcessRegressor(kernel=Matern(length_scale=1, nu=2.5),
n_restarts_optimizer=1,
random_state=42))GaussianProcessRegressor(kernel=Matern(length_scale=1, nu=2.5),
n_restarts_optimizer=1, random_state=42)Parameters
| kernel | Matern(length_scale=1, nu=2.5) | |
| alpha | 1e-10 | |
| optimizer | 'fmin_l_bfgs_b' | |
| n_restarts_optimizer | 1 | |
| normalize_y | False | |
| copy_X_train | True | |
| n_targets | None | |
| random_state | 42 | |
| kernel__length_scale | 1.0 | |
| kernel__length_scale_bounds | (1e-08, ...) | |
| kernel__nu | 2.5 |
Parameters
| in_features_identifiers | [{'name': 'U1', 'type': 'field'}] |
Parameters
| sklearn_block | PCA(n_components=4) | |
| in_features_identifiers | [{'name': 'U1', 'type': 'field'}] | |
| out_features_identifiers | [{'name': 'reduced_U1_*', 'type': 'scalar'}] |
PCA(n_components=4)
Parameters
| n_components | 4 | |
| copy | True | |
| whiten | False | |
| svd_solver | 'auto' | |
| tol | 0.0 | |
| iterated_power | 'auto' | |
| n_oversamples | 10 | |
| power_iteration_normalizer | 'auto' | |
| random_state | None |
dataset_pred = pipeline.predict(dataset_train)
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
for index in range(4):
print("rel_dif =", np.linalg.norm(dataset_pred[index].get_field("U1") - dataset_train[index].get_field("U1")))
rel_dif = 0.011357718020950529
rel_dif = 0.0009937571171721588
rel_dif = 0.023616072381513243
rel_dif = 0.029824957733092912
pipeline.score(dataset_train)
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
np.float64(0.9033857148166287)
param_grid = {
'preprocessor__preparator__common_mesh_id': [0, 2],
'regressor__transformer__pca_u1__sklearn_block__n_components': [2],
'preprocessor__column_preprocessor__nodes_preprocessor__pca_nodes__sklearn_block__n_components': [2]
}
cv = KFold(n_splits=2, shuffle=True, random_state=42)
search = GridSearchCV(pipeline, param_grid=param_grid, cv = cv, verbose=3, error_score='raise')
search.fit(dataset_train)
Fitting 2 folds for each of 2 candidates, totalling 4 fits
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
[CV 1/2] END preprocessor__column_preprocessor__nodes_preprocessor__pca_nodes__sklearn_block__n_components=2, preprocessor__preparator__common_mesh_id=0, regressor__transformer__pca_u1__sklearn_block__n_components=2;, score=0.812 total time= 4.2s
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
[CV 2/2] END preprocessor__column_preprocessor__nodes_preprocessor__pca_nodes__sklearn_block__n_components=2, preprocessor__preparator__common_mesh_id=0, regressor__transformer__pca_u1__sklearn_block__n_components=2;, score=0.797 total time= 4.3s
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
[CV 1/2] END preprocessor__column_preprocessor__nodes_preprocessor__pca_nodes__sklearn_block__n_components=2, preprocessor__preparator__common_mesh_id=2, regressor__transformer__pca_u1__sklearn_block__n_components=2;, score=0.811 total time= 4.2s
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
[CV 2/2] END preprocessor__column_preprocessor__nodes_preprocessor__pca_nodes__sklearn_block__n_components=2, preprocessor__preparator__common_mesh_id=2, regressor__transformer__pca_u1__sklearn_block__n_components=2;, score=0.797 total time= 4.4s
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
GridSearchCV(cv=KFold(n_splits=2, random_state=42, shuffle=True),
error_score='raise',
estimator=Pipeline(steps=[('preprocessor',
Pipeline(steps=[('preparator',
MMGPPreparer(common_mesh_id=1,
morphing=<function morphing at 0x7651fca6b560>)),
('column_preprocessor',
PlaidColumnTransformer(plaid_transformers=[('input_scalar_scaler',
WrappedPlaidSklearnTransformer...
'type': 'field'}],
out_features_identifiers=[{'name': 'reduced_U1_*',
'type': 'scalar'}],
sklearn_block=PCA(n_components=4)))])))]),
param_grid={'preprocessor__column_preprocessor__nodes_preprocessor__pca_nodes__sklearn_block__n_components': [2],
'preprocessor__preparator__common_mesh_id': [0, 2],
'regressor__transformer__pca_u1__sklearn_block__n_components': [2]},
verbose=3)In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
Parameters
| estimator | Pipeline(step...nts=4)))])))]) | |
| param_grid | {'preprocessor__column_p...arn_block__n_components': [2], 'preprocessor__preparator__common_mesh_id': [0, 2], 'regressor__transformer...arn_block__n_components': [2]} | |
| scoring | None | |
| n_jobs | None | |
| refit | True | |
| cv | KFold(n_split... shuffle=True) | |
| verbose | 3 | |
| pre_dispatch | '2*n_jobs' | |
| error_score | 'raise' | |
| return_train_score | False |
Parameters
| steps | [('preparator', ...), ('column_preprocessor', ...)] | |
| transform_input | None | |
| memory | None | |
| verbose | False |
Parameters
| common_mesh_id | 0 | |
| morphing | <function mor...x7651fca6b560> |
Parameters
| plaid_transformers | [('input_scalar_scaler', ...), ('nodes_preprocessor', ...)] |
_
MinMaxScaler()
Parameters
| feature_range | (0, ...) | |
| copy | True | |
| clip | False |
_
Parameters
| in_features_identifiers | [{'type': 'nodes'}] |
Parameters
| sklearn_block | PCA(n_components=2) | |
| in_features_identifiers | [{'type': 'nodes'}] | |
| out_features_identifiers | [{'name': 'reduced_nodes_*', 'type': 'scalar'}] |
PCA(n_components=2)
Parameters
| n_components | 2 | |
| copy | True | |
| whiten | False | |
| svd_solver | 'auto' | |
| tol | 0.0 | |
| iterated_power | 'auto' | |
| n_oversamples | 10 | |
| power_iteration_normalizer | 'auto' | |
| random_state | None |
Parameters
| regressor | WrappedPlaidS...om_state=42))) | |
| transformer | Pipeline(step...ponents=2)))]) |
WrappedPlaidSklearnRegressor(dynamics_params_factory={'estimator__kernel__length_scale': <function length_scale_init at 0x7651fca6b740>},
in_features_identifiers=[{'name': 'P',
'type': 'scalar'},
{'name': 'p1',
'type': 'scalar'},
{'name': 'p2',
'type': 'scalar'},
{'name': 'p3',
'type': 'scalar'},
{'name': 'p4',
'type': 'scalar'},
{'name': 'p5',
'type': 'scalar'},
{'name': 'reduced_nodes_*',
'type': 'scalar'}],
out_features_identifiers=[{'name': 'reduced_U1_*',
'type': 'scalar'}],
sklearn_block=MultiOutputRegressor(estimator=GaussianProcessRegressor(kernel=Matern(length_scale=1, nu=2.5),
n_restarts_optimizer=1,
random_state=42)))MultiOutputRegressor(estimator=GaussianProcessRegressor(kernel=Matern(length_scale=1, nu=2.5),
n_restarts_optimizer=1,
random_state=42))GaussianProcessRegressor(kernel=Matern(length_scale=1, nu=2.5),
n_restarts_optimizer=1, random_state=42)Parameters
| kernel | Matern(length_scale=1, nu=2.5) | |
| alpha | 1e-10 | |
| optimizer | 'fmin_l_bfgs_b' | |
| n_restarts_optimizer | 1 | |
| normalize_y | False | |
| copy_X_train | True | |
| n_targets | None | |
| random_state | 42 | |
| kernel__length_scale | 1.0 | |
| kernel__length_scale_bounds | (1e-08, ...) | |
| kernel__nu | 2.5 |
Parameters
| in_features_identifiers | [{'name': 'U1', 'type': 'field'}] |
Parameters
| sklearn_block | PCA(n_components=2) | |
| in_features_identifiers | [{'name': 'U1', 'type': 'field'}] | |
| out_features_identifiers | [{'name': 'reduced_U1_*', 'type': 'scalar'}] |
PCA(n_components=2)
Parameters
| n_components | 2 | |
| copy | True | |
| whiten | False | |
| svd_solver | 'auto' | |
| tol | 0.0 | |
| iterated_power | 'auto' | |
| n_oversamples | 10 | |
| power_iteration_normalizer | 'auto' | |
| random_state | None |
print("best_params =", search.best_params_)
optimized_pipeline = clone(pipeline).set_params(**search.best_params_)
optimized_pipeline.fit(dataset_train)
best_params = {'preprocessor__column_preprocessor__nodes_preprocessor__pca_nodes__sklearn_block__n_components': 2, 'preprocessor__preparator__common_mesh_id': 0, 'regressor__transformer__pca_u1__sklearn_block__n_components': 2}
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
Pipeline(steps=[('preprocessor',
Pipeline(steps=[('preparator',
MMGPPreparer(common_mesh_id=0,
morphing=<function morphing at 0x7651fca6b560>)),
('column_preprocessor',
PlaidColumnTransformer(plaid_transformers=[('input_scalar_scaler',
WrappedPlaidSklearnTransformer(in_features_identifiers=[{'name': 'P',
'type': 'scalar'},
{'name': 'p1',
'type': 'scalar'},
{'name':...
n_restarts_optimizer=1,
random_state=42))),
transformer=Pipeline(steps=[('mmgp_u1_transf',
MMGPTransformer(in_features_identifiers=[{'name': 'U1',
'type': 'field'}])),
('pca_u1',
WrappedPlaidSklearnTransformer(in_features_identifiers=[{'name': 'U1',
'type': 'field'}],
out_features_identifiers=[{'name': 'reduced_U1_*',
'type': 'scalar'}],
sklearn_block=PCA(n_components=2)))])))])In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
Parameters
| steps | [('preprocessor', ...), ('regressor', ...)] | |
| transform_input | None | |
| memory | None | |
| verbose | False |
Parameters
| steps | [('preparator', ...), ('column_preprocessor', ...)] | |
| transform_input | None | |
| memory | None | |
| verbose | False |
Parameters
| common_mesh_id | 0 | |
| morphing | <function mor...x7651fca6b560> |
Parameters
| plaid_transformers | [('input_scalar_scaler', ...), ('nodes_preprocessor', ...)] |
_
MinMaxScaler()
Parameters
| feature_range | (0, ...) | |
| copy | True | |
| clip | False |
_
Parameters
| in_features_identifiers | [{'type': 'nodes'}] |
Parameters
| sklearn_block | PCA(n_components=2) | |
| in_features_identifiers | [{'type': 'nodes'}] | |
| out_features_identifiers | [{'name': 'reduced_nodes_*', 'type': 'scalar'}] |
PCA(n_components=2)
Parameters
| n_components | 2 | |
| copy | True | |
| whiten | False | |
| svd_solver | 'auto' | |
| tol | 0.0 | |
| iterated_power | 'auto' | |
| n_oversamples | 10 | |
| power_iteration_normalizer | 'auto' | |
| random_state | None |
Parameters
| regressor | WrappedPlaidS...om_state=42))) | |
| transformer | Pipeline(step...ponents=2)))]) |
WrappedPlaidSklearnRegressor(dynamics_params_factory={'estimator__kernel__length_scale': <function length_scale_init at 0x7651fca6b740>},
in_features_identifiers=[{'name': 'P',
'type': 'scalar'},
{'name': 'p1',
'type': 'scalar'},
{'name': 'p2',
'type': 'scalar'},
{'name': 'p3',
'type': 'scalar'},
{'name': 'p4',
'type': 'scalar'},
{'name': 'p5',
'type': 'scalar'},
{'name': 'reduced_nodes_*',
'type': 'scalar'}],
out_features_identifiers=[{'name': 'reduced_U1_*',
'type': 'scalar'}],
sklearn_block=MultiOutputRegressor(estimator=GaussianProcessRegressor(kernel=Matern(length_scale=1, nu=2.5),
n_restarts_optimizer=1,
random_state=42)))MultiOutputRegressor(estimator=GaussianProcessRegressor(kernel=Matern(length_scale=1, nu=2.5),
n_restarts_optimizer=1,
random_state=42))GaussianProcessRegressor(kernel=Matern(length_scale=1, nu=2.5),
n_restarts_optimizer=1, random_state=42)Parameters
| kernel | Matern(length_scale=1, nu=2.5) | |
| alpha | 1e-10 | |
| optimizer | 'fmin_l_bfgs_b' | |
| n_restarts_optimizer | 1 | |
| normalize_y | False | |
| copy_X_train | True | |
| n_targets | None | |
| random_state | 42 | |
| kernel__length_scale | 1.0 | |
| kernel__length_scale_bounds | (1e-08, ...) | |
| kernel__nu | 2.5 |
Parameters
| in_features_identifiers | [{'name': 'U1', 'type': 'field'}] |
Parameters
| sklearn_block | PCA(n_components=2) | |
| in_features_identifiers | [{'name': 'U1', 'type': 'field'}] | |
| out_features_identifiers | [{'name': 'reduced_U1_*', 'type': 'scalar'}] |
PCA(n_components=2)
Parameters
| n_components | 2 | |
| copy | True | |
| whiten | False | |
| svd_solver | 'auto' | |
| tol | 0.0 | |
| iterated_power | 'auto' | |
| n_oversamples | 10 | |
| power_iteration_normalizer | 'auto' | |
| random_state | None |
score = optimized_pipeline.score(dataset_train)
print("score =", score, ", error =", 1. - score)
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
score = 0.8640837074545124 , error = 0.13591629254548765
for index in range(len(dataset_pred)):
print("rel_dif =", np.linalg.norm(dataset_pred[index].get_field("U1") - dataset_train[index].get_field("U1")))
rel_dif = 0.011357718020950529
rel_dif = 0.0009937571171721588
rel_dif = 0.023616072381513243
rel_dif = 0.029824957733092912
rel_dif = 0.028615925832433036
rel_dif = 0.024394942084450828
optimal_common_mesh_id = search.best_params_['preprocessor__preparator__common_mesh_id']
print("optimal_common_mesh_id =", optimal_common_mesh_id)
optimized_pipeline = clone(pipeline).set_params(
preprocessor__preparator__common_mesh_id = optimal_common_mesh_id,
regressor__transformer__pca_u1__sklearn_block__n_components = len(dataset_train),
preprocessor__column_preprocessor__nodes_preprocessor__pca_nodes__sklearn_block__n_components = len(dataset_train)
)
optimized_pipeline.fit(dataset_train)
optimal_common_mesh_id = 0
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
Pipeline(steps=[('preprocessor',
Pipeline(steps=[('preparator',
MMGPPreparer(common_mesh_id=0,
morphing=<function morphing at 0x7651fca6b560>)),
('column_preprocessor',
PlaidColumnTransformer(plaid_transformers=[('input_scalar_scaler',
WrappedPlaidSklearnTransformer(in_features_identifiers=[{'name': 'P',
'type': 'scalar'},
{'name': 'p1',
'type': 'scalar'},
{'name':...
n_restarts_optimizer=1,
random_state=42))),
transformer=Pipeline(steps=[('mmgp_u1_transf',
MMGPTransformer(in_features_identifiers=[{'name': 'U1',
'type': 'field'}])),
('pca_u1',
WrappedPlaidSklearnTransformer(in_features_identifiers=[{'name': 'U1',
'type': 'field'}],
out_features_identifiers=[{'name': 'reduced_U1_*',
'type': 'scalar'}],
sklearn_block=PCA(n_components=6)))])))])In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
Parameters
| steps | [('preprocessor', ...), ('regressor', ...)] | |
| transform_input | None | |
| memory | None | |
| verbose | False |
Parameters
| steps | [('preparator', ...), ('column_preprocessor', ...)] | |
| transform_input | None | |
| memory | None | |
| verbose | False |
Parameters
| common_mesh_id | 0 | |
| morphing | <function mor...x7651fca6b560> |
Parameters
| plaid_transformers | [('input_scalar_scaler', ...), ('nodes_preprocessor', ...)] |
_
MinMaxScaler()
Parameters
| feature_range | (0, ...) | |
| copy | True | |
| clip | False |
_
Parameters
| in_features_identifiers | [{'type': 'nodes'}] |
Parameters
| sklearn_block | PCA(n_components=6) | |
| in_features_identifiers | [{'type': 'nodes'}] | |
| out_features_identifiers | [{'name': 'reduced_nodes_*', 'type': 'scalar'}] |
PCA(n_components=6)
Parameters
| n_components | 6 | |
| copy | True | |
| whiten | False | |
| svd_solver | 'auto' | |
| tol | 0.0 | |
| iterated_power | 'auto' | |
| n_oversamples | 10 | |
| power_iteration_normalizer | 'auto' | |
| random_state | None |
Parameters
| regressor | WrappedPlaidS...om_state=42))) | |
| transformer | Pipeline(step...ponents=6)))]) |
WrappedPlaidSklearnRegressor(dynamics_params_factory={'estimator__kernel__length_scale': <function length_scale_init at 0x7651fca6b740>},
in_features_identifiers=[{'name': 'P',
'type': 'scalar'},
{'name': 'p1',
'type': 'scalar'},
{'name': 'p2',
'type': 'scalar'},
{'name': 'p3',
'type': 'scalar'},
{'name': 'p4',
'type': 'scalar'},
{'name': 'p5',
'type': 'scalar'},
{'name': 'reduced_nodes_*',
'type': 'scalar'}],
out_features_identifiers=[{'name': 'reduced_U1_*',
'type': 'scalar'}],
sklearn_block=MultiOutputRegressor(estimator=GaussianProcessRegressor(kernel=Matern(length_scale=1, nu=2.5),
n_restarts_optimizer=1,
random_state=42)))MultiOutputRegressor(estimator=GaussianProcessRegressor(kernel=Matern(length_scale=1, nu=2.5),
n_restarts_optimizer=1,
random_state=42))GaussianProcessRegressor(kernel=Matern(length_scale=1, nu=2.5),
n_restarts_optimizer=1, random_state=42)Parameters
| kernel | Matern(length_scale=1, nu=2.5) | |
| alpha | 1e-10 | |
| optimizer | 'fmin_l_bfgs_b' | |
| n_restarts_optimizer | 1 | |
| normalize_y | False | |
| copy_X_train | True | |
| n_targets | None | |
| random_state | 42 | |
| kernel__length_scale | 1.0 | |
| kernel__length_scale_bounds | (1e-08, ...) | |
| kernel__nu | 2.5 |
Parameters
| in_features_identifiers | [{'name': 'U1', 'type': 'field'}] |
Parameters
| sklearn_block | PCA(n_components=6) | |
| in_features_identifiers | [{'name': 'U1', 'type': 'field'}] | |
| out_features_identifiers | [{'name': 'reduced_U1_*', 'type': 'scalar'}] |
PCA(n_components=6)
Parameters
| n_components | 6 | |
| copy | True | |
| whiten | False | |
| svd_solver | 'auto' | |
| tol | 0.0 | |
| iterated_power | 'auto' | |
| n_oversamples | 10 | |
| power_iteration_normalizer | 'auto' | |
| random_state | None |
dataset_pred = optimized_pipeline.predict(dataset_train)
for index in range(len(dataset_pred)):
print(f"rel_dif(id={index}) =", np.linalg.norm(dataset_pred[index].get_field("U1") - dataset_train[index].get_field("U1")))
print(f"error at id {optimal_common_mesh_id } should be numerical zero")
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 485
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
starting walking along line boundary at point... = [-1. -1.] of rank: 7
... walking toward point = [-0.98 -1. ] of rank: 483
rel_dif(id=0) = 3.4162145000325305e-12
rel_dif(id=1) = 0.012683731194877484
rel_dif(id=2) = 0.014442053702096612
rel_dif(id=3) = 0.03092973408790886
rel_dif(id=4) = 0.019543583546195502
rel_dif(id=5) = 0.02276154165008207
error at id 0 should be numerical zero