Prediction and Model Reuse
Note
This page has been superseded by the consolidated Predictions documentation. Please refer to the new guides:
Making Predictions – How to predict on new data from a RunResult, exported bundle, or chain ID
Exporting Models – Export formats (.n4a, .n4a.py, .json), bundle anatomy, sharing models
Advanced Predictions – Transfer learning, retraining, SHAP explanations
Predictions Overview – Full navigation to all prediction documentation
Quick Reference
The primary prediction workflows are:
Predict from an Exported Bundle
import nirs4all
# Train and export
result = nirs4all.run(pipeline, dataset)
result.export("model.n4a")
# Predict on new data
preds = nirs4all.predict(model="model.n4a", data=X_new)
print(preds.values)
Predict from a Chain ID
preds = nirs4all.predict(chain_id="abc123", data=X_new, workspace_path="workspace")
Transfer Learning
retrained = nirs4all.retrain(
source="model.n4a",
data=new_data,
mode="transfer",
)
For the complete guide, see Predictions.
See also
Related Examples:
U01: Save, Load, Predict - Model persistence and prediction
U04: sklearn Integration - NIRSPipeline as sklearn estimator