Skip to main content
Once you have a trained model, generating predictions is a single method call. Both Model and ReasoningModel expose a predict() method that accepts a dataset, validates it against the training-time schema, and returns a numpy.ndarray. If you’re working with a ReasoningModel and need both predictions and explanations, you can get both in a single round-trip.

Wrap your data in a Dataset

predict() requires an op.Dataset. You cannot pass a raw DataFrame or array directly. Build one from your inference rows with op.LocalDataset.from_*(...).upload() before calling the model.
import outerproduct as op

test_dataset = op.LocalDataset.from_pandas(X_new).upload()
predictions = model.predict(test_dataset)  # numpy.ndarray
The SDK validates the dataset’s columns against the model’s training-time schema before the call goes out. Missing or mismatched features raise a clear local error rather than a server-side 400, so you catch schema mismatches fast.
You can construct the inference dataset in any of the same ways you built the training dataset:
# From a DataFrame
test_dataset = op.LocalDataset.from_pandas(df).upload()

# From a CSV
test_dataset = op.LocalDataset.from_csv("new_customers.csv").upload()

# From NumPy
test_dataset = op.LocalDataset.from_numpy(X_new).upload()

Predict and explain in one call

If you have a ReasoningModel, use predict_and_explain() to avoid two separate round-trips. You get both the prediction array and a Reasoning object with per-sample feature attributions.
test_dataset = op.LocalDataset.from_pandas(X_new).upload()
predictions, reasoning = model.predict_and_explain(test_dataset)
Prefer predict_and_explain() over calling predict() and explain() separately. It halves your network overhead and guarantees the predictions and attributions correspond to exactly the same forward pass.

What predict() returns

predict() returns a numpy.ndarray. For binary classification, values are class probabilities. For regression, values are the predicted targets.
import numpy as np

test_dataset = op.LocalDataset.from_pandas(X_new).upload()
predictions = model.predict(test_dataset)

print(type(predictions))        # <class 'numpy.ndarray'>
print(predictions.shape)        # (n_samples,)
print(predictions[:5])          # e.g. [0.82, 0.14, 0.91, 0.37, 0.66]

Next steps

Explanations

Understand which features drive each prediction using model.explain() and model.get_global_drivers().

Training

Learn how to train a Model or ReasoningModel from your dataset.