Skip to content

Regression Nodes

Summary

Reference: nodes that predict numbers from spectra — PLS model fitting, application, and evaluation.

Regression nodes predict quantitative targets from spectra or features.

Training and Prediction Nodes

  • model.fitted_pls: Fit a quantitative calibration while making the reusable numerical state and VIP evidence explicit. Choose components under an explicit validation design rather than calibration fit alone.
  • model.apply_fitted_pls: Apply either a verified upstream fitted state or a verified imported artifact through the same numerical core. Local state is connected by a typed edge; imported mode requires the complete artifact binding and cannot be mixed with local custody.
  • model.pcr: Regress targets on PCA scores when you want explicit PCA compression before regression.
  • model.svr: Nonlinear calibration with support vector regression. Scaling is usually important for SVR.
  • model.linear_regression: Simple baseline calibration or already-selected low-dimensional features.
  • model.load_apply: Load a saved model artifact and apply it to inference data.

Key Outputs

Changing the regression algorithm

Use Predict Regression (model.predict_regression) when comparing PLS, PCR, SVR, or linear regression in a held-out workflow. Connect the trainer's Fitted State output and the split's Test Data to this node. Its Predicted Targets output goes to Test Evaluation together with the matching test references and held-out sample context. It applies retained training state; it does not fit on test rows or replay preprocessing already applied upstream.

Train PCR Regression, Train SVR Regression, and Train Linear Regression now provide a portable Fitted State output in addition to their legacy Model output. Use Fitted State for prediction. The explicit Fit variants are supported too. Prediction identity retains response names/units when the training state contains them; bare response arrays and older states remain explicitly unnamed.

Junior-user note: in older templates, “Predict Test Set” was only a label for a PLS-specific node. For an existing workflow, replace that node with Predict Regression, reconnect Fitted State and Test Data, and reconnect Predicted Targets to the evaluator. Historical runs are not changed. A PLS application node cannot apply PCR state even though both connections say RegressionModel.

Use the explicitly PLS-specific application node when you need PLS prediction intervals or applicability screening. The general predictor does not manufacture equivalent diagnostics for other algorithms. Algorithm-specific application and PCA diagnostic nodes reject incompatible producer ports during graph validation.

Fold-safe PCR, SVR and linear regression

For a workflow you intend to optimize, use Fit PCR (model.fitted_pcr), Fit SVR (model.fitted_svr) or Fit Linear Regression (model.fitted_linear_regression) and the matching Apply node (model.apply_fitted_pcr, model.apply_fitted_svr, or model.apply_fitted_linear_regression). The older single-step Train nodes remain available, but their saved runs are not substituted with a different recipe.

Connect the split's X_train and y_train to Fit, its X_test to Apply, and Fit's fitted_state to Apply. Connect predictions and y_test to a held-out regression evaluator. During optimization, fitting is repeated using only each fold's training rows. PCR compression and any model-internal scaling are fitted there too. These explicit nodes reject missing/nonfinite training values rather than silently changing the scored population.

Junior-user note: the Fit node's predictions describe the training fit, not predictive performance. Compare the held-out evaluator or campaign's common cross-validation scores. Do not fit scaling or select variables on the complete dataset before splitting. Additional learned-preprocessing and branched-workflow support are not part of this expansion.

Canonical PLS exposes training predictions, a closed fitted-state envelope, and producer-owned combined VIP scores. A local regression evaluator scores the arrays supplied to it without independently verifying their cohort. Call its metrics validation only when retained run and split lineage establish out-of-fold or held-out predictions; the fitted node does not relabel training fit as validation evidence.

The implementation follows de Jong's SIMPLS algorithm: S. de Jong, SIMPLS: an alternative approach to partial least squares regression, Chemometrics and Intelligent Laboratory Systems 18 (1993) 251–263, https://doi.org/10.1016/0169-7439(93)85002-X.

Automatic latent-variable selection

New PLS Calibration starters use one-standard-error selection: choose the smallest number of latent variables whose mean fold RMSE is within one standard error of the best mean fold RMSE, then refit on the training samples. Scaling is fitted separately inside each fold. The saved model keeps the actual selected count; Load & Apply uses that frozen model without selecting again.

The held-out test set never participates in selection. Optimize repeats selection within each outer training fold. Bind specimen groups explicitly when there are repeated acquisitions of a specimen; automatic selection keeps those groups together. Insufficient groups, unsafe upstream fitted preprocessing, or unsupported multiresponse selection produces a clear refusal, not a fallback to three latent variables.

Existing saved workflows retain Manual mode and their recorded count. Changing the old Component choice basis annotation alone does not refit or select a model. For new automatic fits, Component curve maximum bounds the search and Component CV folds defines its training-fold protocol. Keep that protocol fixed across Optimize candidates; use Manual mode to compare specific fixed LV counts. The component curve is tuning evidence, while the separate held-out result estimates prediction performance.

PLS1, PLS2, and solver names

PLS1 means one response variable and PLS2 means multiple response variables. Those terms do not select the numerical solver. SIMPLS and NIPALS are distinct algorithms that can be used for PLS regression. The canonical node uses de Jong SIMPLS for both its single-response PLS1 and multi-response PLS2 cases. There is no separate canonical NIPALS regression node in this release.

Decision Notes

  • Use PLS when spectra are collinear and the target is quantitative.
  • Use PCR when you want PCA compression to be explicit and separately inspected.
  • Use SVR only after careful scaling and validation; nonlinear models can overfit small spectral datasets.
  • Use linear regression mainly for selected variables, peak areas, or low-dimensional features.
  • Keep sample-target alignment explicit. If targets arrive separately, use Data/Attach Target or a workflow that preserves row identity.

Good Practice

Confirm sample-target alignment before training. For spectroscopy calibration, this is as important as model choice.

Portable PLS response identity

New fitted PLS states use serializer 9 and retain ordered response names and units. Missing scientific metadata is explicitly unknown; predictor channel names and application-input targets cannot fill it in. Separate labeled X/Y datasets must have the same unique sample identities in the same order. Reorder or join explicitly before fitting. Raw arrays remain positional.

Apply PLS1 / PLS2 Model (SIMPLS) emits Prediction Identity alongside its numeric prediction matrix. This record binds response names/units, row labels or values, shape, a digest of prediction values and the verified model-state identity. Result exports retain the record beside the prediction CSV, including when only the application result is exported. A bare numerical array or CSV without that record is positional and does not by itself establish response authority.

Older PLS states without retained response identity require refitting for current application. Their historical results remain evidence of the original run; current labels are never substituted into them.

Fitted input compatibility

Fitted PLS retains ordered feature identity and the signal units, declared signal quantity and measurement mode used at fit time. Application must match that authority before prediction. Spelling aliases such as Abs and absorbance are equivalent; absorbance and transmittance are not. Convert physical quantities explicitly before fitting/application.

Unknown metadata remains unknown and must match on replay. It does not imply interchangeability or instrument qualification. Declare missing units or measurement mode before fitting a model intended for deployment. Folder-watch inputs must retain those declarations (for example, in portable CSV metadata); missing or conflicting declarations produce a visible failed run.

Missing references and training population

PCR, SVR and linear regression emit a Training population record. It identifies the original predictor dataset by its scientific digest, the bound response by its shape and value digest, response names/units, and the admitted and excluded zero-based input rows. Labels and sample coordinates are retained when available; row positions are explicitly relative to that input digest. SVR also records the selected input response column independently of the one-column matrix fitted by the estimator.

Missing selected reference values exclude the corresponding rows from fitting. An incomplete unselected multi-response table requires explicit target selection. Infinity is invalid rather than missing. Nonfinite predictors and an unmaterialized sample exclusion mask refuse with an actionable error. Other missing ancillary properties do not exclude a measured selected response.

The record is a declared result output and is retained in model artifact metadata and generated Python results. It describes calibration fit, not held-out validation. The mathematical fitted-state serializer alone does not carry the training population; retain the result or model artifact when that evidence is required. Older artifacts lacking the record have unknown original population accounting; current metadata must not be substituted into them.

Per-response regression metrics

PCR, SVR and linear regression use the SDK metric authority for training statistics. R² is unavailable for exactly constant references or a singleton; small but represented variation remains measurable regardless of display rounding. Direct and pooled calculations share scaled, centered moments. SEP is the sample standard deviation of prediction-minus-reference residuals, including when those residuals have a large nonzero bias. Unrepresentable numeric differences or metrics produce an explicit refusal.

Multi-response PCR and linear regression retain named per-response R² and RMSE. Their summaries omit scalar R²/RMSE/score aggregates and state per_response_only. Errors from different physical quantities must not be combined into an unnamed scalar. Select the response when comparing models. Single-response summaries remain available. A true-constant response has null R², never an invented perfect fit.

This corrects numerical implementation of the existing metric definitions. Historical records are not recalculated or upgraded in place. Previously retained multi-response scalar errors are legacy unqualified summaries; use a new calculation from retained observations and predictions for corrected per-response evidence. A historical registry version alone is not proof that a result used the corrected implementation; retain run/source identity.

Registry reference

Generated from registered node metadata. Edit methodology and examples outside the marked section. Defaults and options below are JSON values; null means no concrete default is declared. Internal parameters are retained for contract inspection and are not scientist-editable controls. Conditional visibility describes the editor; execution admission remains node-owned.

Node Operation
Apply Linear Regression model.apply_fitted_linear_regression
Apply PCR model.apply_fitted_pcr
Apply PLS1 / PLS2 Model (SIMPLS) model.apply_fitted_pls
Apply SVR model.apply_fitted_svr
Fit Linear Regression model.fitted_linear_regression
Fit PCR model.fitted_pcr
Fit PLS1 / PLS2 Regression (SIMPLS) model.fitted_pls
Fit SVR model.fitted_svr
Train Linear Regression model.linear_regression
Apply Saved Model Artifact model.load_apply
Train PCR Regression model.pcr
Predict Regression model.predict_regression
Train SVR Regression model.svr

Apply Linear Regression (model.apply_fitted_linear_regression)

Ports

Direction Port Type URI Required Variadic Accepted data roles
input default spectrasherpa://types/SpectralDataset/1.0 true false []
input fitted_state spectrasherpa://types/RegressionModel/1.0 false false []
output default spectrasherpa://types/TargetMatrix/1.0 true false []

Parameters

Parameter Editor type Required Default Options / enum Bounds / step Visibility / category Description
artifact_digest text false null — — {"category": "internal"} —
serializer text false null — — {"category": "internal"} —
source_contract_digest text false null — — {"category": "internal"} —
state_content_digest text false null — — {"category": "internal"} —
state_digest text false null — — {"category": "internal"} —
state_node_id text false null — — {"category": "internal"} —

Apply PCR (model.apply_fitted_pcr)

Ports

Direction Port Type URI Required Variadic Accepted data roles
input default spectrasherpa://types/SpectralDataset/1.0 true false []
input fitted_state spectrasherpa://types/RegressionModel/1.0 false false []
output default spectrasherpa://types/TargetMatrix/1.0 true false []

Parameters

Parameter Editor type Required Default Options / enum Bounds / step Visibility / category Description
artifact_digest text false null — — {"category": "internal"} —
serializer text false null — — {"category": "internal"} —
source_contract_digest text false null — — {"category": "internal"} —
state_content_digest text false null — — {"category": "internal"} —
state_digest text false null — — {"category": "internal"} —
state_node_id text false null — — {"category": "internal"} —

Apply PLS1 / PLS2 Model (SIMPLS) (model.apply_fitted_pls)

Ports

Direction Port Type URI Required Variadic Accepted data roles
input default spectrasherpa://types/SpectralDataset/1.0 true false []
input fitted_state spectrasherpa://types/RegressionModel/1.0 false false []
output default spectrasherpa://types/TargetMatrix/1.0 true false []
output prediction_intervals spectrasherpa://types/PredictionIntervals/1.0 true false []
output applicability spectrasherpa://types/ApplicabilityScreening/1.0 true false []
output prediction_identity spectrasherpa://types/PredictionIdentity/1.0 true false []

Parameters

Parameter Editor type Required Default Options / enum Bounds / step Visibility / category Description
artifact_digest text false null — — {"category": "internal"} Canonical artifact-custody binding populated by import; not a scientist-set parameter.
serializer text false null — — {"category": "internal"} Canonical artifact-custody binding populated by import; not a scientist-set parameter.
source_contract_digest text false null — — {"category": "internal"} Canonical artifact-custody binding populated by import; not a scientist-set parameter.
state_content_digest text false null — — {"category": "internal"} Canonical artifact-custody binding populated by import; not a scientist-set parameter.
state_digest text false null — — {"category": "internal"} Canonical artifact-custody binding populated by import; not a scientist-set parameter.
state_node_id text false null — — {"category": "internal"} Canonical artifact-custody binding populated by import; not a scientist-set parameter.

Apply SVR (model.apply_fitted_svr)

Ports

Direction Port Type URI Required Variadic Accepted data roles
input default spectrasherpa://types/SpectralDataset/1.0 true false []
input fitted_state spectrasherpa://types/RegressionModel/1.0 false false []
output default spectrasherpa://types/TargetMatrix/1.0 true false []

Parameters

Parameter Editor type Required Default Options / enum Bounds / step Visibility / category Description
artifact_digest text false null — — {"category": "internal"} —
serializer text false null — — {"category": "internal"} —
source_contract_digest text false null — — {"category": "internal"} —
state_content_digest text false null — — {"category": "internal"} —
state_digest text false null — — {"category": "internal"} —
state_node_id text false null — — {"category": "internal"} —

Fit Linear Regression (model.fitted_linear_regression)

Ports

Direction Port Type URI Required Variadic Accepted data roles
input default spectrasherpa://types/SpectralDataset/1.0 true false []
input y spectrasherpa://types/TargetMatrix/1.0 false false []
output default spectrasherpa://types/TargetMatrix/1.0 true false []
output fitted_state spectrasherpa://types/RegressionModel/1.0 true false []

Parameters

Parameter Editor type Required Default Options / enum Bounds / step Visibility / category Description
fit_intercept boolean false true — — {"category": "basic"} Calculate intercept (if False, force through origin)

Fit PCR (model.fitted_pcr)

Ports

Direction Port Type URI Required Variadic Accepted data roles
input default spectrasherpa://types/SpectralDataset/1.0 true false []
input y spectrasherpa://types/TargetMatrix/1.0 false false []
output default spectrasherpa://types/TargetMatrix/1.0 true false []
output fitted_state spectrasherpa://types/RegressionModel/1.0 true false []

Parameters

Parameter Editor type Required Default Options / enum Bounds / step Visibility / category Description
n_components number true 3 — {"min_value": 1, "step": 1} {"category": "basic"} Number of PCA components for regression
scale boolean false true — — {"category": "basic"} Scale each predictor to unit variance before the PCA centering step.

Fit PLS1 / PLS2 Regression (SIMPLS) (model.fitted_pls)

Ports

Direction Port Type URI Required Variadic Accepted data roles
input default spectrasherpa://types/SpectralDataset/1.0 true false []
input y spectrasherpa://types/TargetMatrix/1.0 false false []
output default spectrasherpa://types/TargetMatrix/1.0 true false []
output fitted_state spectrasherpa://types/RegressionModel/1.0 true false []
output vip_scores spectrasherpa://types/VariableImportance/1.0 true false []
output calibration_comparison spectrasherpa://types/RegressionComparison/1.0 true false []
output x_scores spectrasherpa://types/ScoreMatrix/1.0 true false []
output x_loadings spectrasherpa://types/LoadingMatrix/1.0 true false []
output explained_variance spectrasherpa://types/ExplainedVarianceMatrix/1.0 true false []
output regression_coefficients spectrasherpa://types/RegressionCoefficientMatrix/1.0 true false []
output component_curve spectrasherpa://types/ValidationResult/1.0 true false []

Parameters

Parameter Editor type Required Default Options / enum Bounds / step Visibility / category Description
n_components number true 2 — {"min_value": 1, "step": 1} {"category": "basic", "visible_when": {"component_fit_mode": ["manual"]}} Requested maximum; the fit reports the effective predictive rank and stops before an unidentifiable direction. Must not exceed min(training samples - 1, input features). This choice is saved; the component CV curve is tuning evidence and must not use the locked test cohort.
component_fit_mode select false "manual" [{"label": "Manual", "value": "manual"}, {"label": "Automatic · one-standard-error", "value": "one_standard_error"}] — {"category": "basic"} Manual uses Latent Variables. One-standard-error selects the smallest model within one standard error of the lowest mean fold RMSE, then refits on training samples only. Uses the component-curve maximum and folds; requires one response and qualified fold-local preprocessing. Held-out samples are never used.
scale boolean false false — — {"category": "basic"} —
component_selection_rule select false "manual_parameter" ["manual_parameter", "minimum_mean_fold_rmse", "one_standard_error"] — {"category": "advanced"} Choose and save the basis after inspecting the curve, then set Latent Variables to the desired count and refit. For a multiresponse model, use manual because each response has its own suggestion.
component_curve_max number false 10 — {"max_value": 20, "min_value": 1, "step": 1} {"category": "advanced"} Automatically includes the selected LV up to 20; a larger selected model is marked outside the bounded curve. Bounds the additional calibration/CV fits and retained per-component evidence.
component_cv_folds number false 5 — {"max_value": 10, "min_value": 2, "step": 1} {"category": "advanced"} Uses group K-fold when sample groups are bound, otherwise row K-fold. Scaling is fitted within each training fold. Population-fitted upstream preprocessing makes this curve unavailable. Bounds repeated fold fitting and retained fold evidence.
target_names string_list false [] — — {"category": "internal"} —

Fit SVR (model.fitted_svr)

Ports

Direction Port Type URI Required Variadic Accepted data roles
input default spectrasherpa://types/SpectralDataset/1.0 true false []
input y spectrasherpa://types/TargetMatrix/1.0 false false []
output default spectrasherpa://types/TargetMatrix/1.0 true false []
output fitted_state spectrasherpa://types/RegressionModel/1.0 true false []

Parameters

Parameter Editor type Required Default Options / enum Bounds / step Visibility / category Description
kernel select true "rbf" ["rbf", "linear", "poly", "sigmoid"] — {"category": "basic"} Kernel type for SVR
C number true 1.0 — {"min_value": 0.01, "step": 0.1} {"category": "basic"} Regularization parameter
epsilon number false 0.1 — {"min_value": 0.0, "step": 0.01} {"category": "basic"} Epsilon-tube width
gamma select false "scale" ["scale", "auto"] — {"category": "advanced"} Kernel coefficient for RBF/poly/sigmoid
degree number false 3 — {"min_value": 1, "step": 1} {"category": "advanced"} Degree for polynomial kernel
coef0 number false 0.0 — {"min_value": -1.0, "step": 0.1} {"category": "advanced"} Independent term for poly/sigmoid kernels
target_index number true 1 — {"min_value": 1, "step": 1} {"category": "basic"} 1-based target/property column to model when the dataset contains multiple reference properties
scale boolean false true — — {"category": "basic"} Apply mean centering and scaling

Train Linear Regression (model.linear_regression)

Ports

Direction Port Type URI Required Variadic Accepted data roles
input X spectrasherpa://types/Array2D/1.0 true false ["X_spectra", "X_features"]
input y spectrasherpa://types/TargetMatrix/1.0 false false []
output population spectrasherpa://types/RegressionPopulation/1.0 true false []
output model spectrasherpa://types/RegressionModel/1.0 true false []
output predictions spectrasherpa://types/TargetMatrix/1.0 true false []
output residuals spectrasherpa://types/TargetMatrix/1.0 true false []
output effect_summary spectrasherpa://types/Visualization/1.0 false false []
output fitted_state spectrasherpa://types/RegressionModel/1.0 true false []

Parameters

Parameter Editor type Required Default Options / enum Bounds / step Visibility / category Description
fit_intercept boolean false true — — {"category": "basic"} Calculate intercept (if False, force through origin)

Apply Saved Model Artifact (model.load_apply)

Ports

Direction Port Type URI Required Variadic Accepted data roles
input X_new spectrasherpa://types/SpectralDataset/1.0 true false []
input model_ref spectrasherpa://types/ModelReference/1.0 false false []
output result spectrasherpa://types/Array2D/1.0 true false []
output labels spectrasherpa://types/Categorical/1.0 false false []
output model_id spectrasherpa://types/ModelReference/1.0 true false []

Parameters

Parameter Editor type Required Default Options / enum Bounds / step Visibility / category Description
model_id model_select false null — — {"category": "basic"} Saved model artifact to load and apply
acknowledge_legacy_input_uncertainty boolean false false — — {"category": "basic"} I acknowledge that a pre-0.6.2 model lacks fitted signal identity. Use only when the retained feature axis matches; refit for verified application.

Train PCR Regression (model.pcr)

Ports

Direction Port Type URI Required Variadic Accepted data roles
input X spectrasherpa://types/Array2D/1.0 true false ["X_spectra", "X_features"]
input y spectrasherpa://types/TargetMatrix/1.0 false false []
output population spectrasherpa://types/RegressionPopulation/1.0 true false []
output model spectrasherpa://types/RegressionModel/1.0 true false []
output scores spectrasherpa://types/ScoreMatrix/1.0 true false []
output loadings spectrasherpa://types/LoadingMatrix/1.0 true false []
output y_pred spectrasherpa://types/TargetMatrix/1.0 false false []
output y_true spectrasherpa://types/TargetMatrix/1.0 false false []
output fitted_state spectrasherpa://types/RegressionModel/1.0 true false []

Parameters

Parameter Editor type Required Default Options / enum Bounds / step Visibility / category Description
n_components number true 3 — {"min_value": 1, "step": 1} {"category": "basic"} Number of PCA components for regression
scale boolean false true — — {"category": "basic"} Scale each predictor to unit variance before the PCA centering step.

Predict Regression (model.predict_regression)

Ports

Direction Port Type URI Required Variadic Accepted data roles
input default spectrasherpa://types/SpectralDataset/1.0 true false []
input fitted_state spectrasherpa://types/RegressionModel/1.0 true false []
output default spectrasherpa://types/TargetMatrix/1.0 true false []
output prediction_identity spectrasherpa://types/PredictionIdentity/1.0 true false []

Parameters

No parameters.

Train SVR Regression (model.svr)

Ports

Direction Port Type URI Required Variadic Accepted data roles
input X spectrasherpa://types/Array2D/1.0 true false ["X_spectra", "X_features"]
input y spectrasherpa://types/TargetMatrix/1.0 false false []
output population spectrasherpa://types/RegressionPopulation/1.0 true false []
output model spectrasherpa://types/RegressionModel/1.0 true false []
output predictions spectrasherpa://types/TargetMatrix/1.0 true false []
output residuals spectrasherpa://types/TargetMatrix/1.0 true false []
output fitted_state spectrasherpa://types/RegressionModel/1.0 true false []

Parameters

Parameter Editor type Required Default Options / enum Bounds / step Visibility / category Description
kernel select true "rbf" ["rbf", "linear", "poly", "sigmoid"] — {"category": "basic"} Kernel type for SVR
C number true 1.0 — {"min_value": 0.01, "step": 0.1} {"category": "basic"} Regularization parameter
epsilon number false 0.1 — {"min_value": 0.0, "step": 0.01} {"category": "basic"} Epsilon-tube width
gamma select false "scale" ["scale", "auto"] — {"category": "advanced"} Kernel coefficient for RBF/poly/sigmoid
degree number false 3 — {"min_value": 1, "step": 1} {"category": "advanced"} Degree for polynomial kernel
coef0 number false 0.0 — {"min_value": -1.0, "step": 0.1} {"category": "advanced"} Independent term for poly/sigmoid kernels
target_index number true 1 — {"min_value": 1, "step": 1} {"category": "basic"} 1-based target/property column to model when the dataset contains multiple reference properties
scale boolean false true — — {"category": "basic"} Apply mean centering and scaling