outerproduct.model module contains the objects you work with after training. A plain Model handles predictions; a ReasoningModel extends it with feature-level explanations, counterfactual scenarios, and global driver analysis. Both are produced asynchronously: you call .wait() on a job handle and receive the model object once training completes.
Model
Model is produced by Trainer.configure().run().wait(). Use it when you need predictions but do not require explanations.
model.predict()
dataset and returns a one-dimensional NumPy array of predictions. The SDK validates dataset’s column schema against the model’s training-time schema before the request leaves your machine, so mismatched or missing features raise a descriptive local error rather than a server-side 400.
An
op.Dataset. Build one with op.LocalDataset.from_pandas(df).upload(), op.LocalDataset.from_csv(...).upload(), or op.LocalDataset.from_numpy(...).upload(), or reference a connector. Column names must match the features seen during training.A 1-D array of shape
(n_samples,) containing the model’s prediction for each row. For binary classification, values are class-1 probabilities. For regression, values are the predicted target.ReasoningModel
ReasoningModel is produced by op.reasoning.fit().wait(). It is a superset of Model (all predict() behaviour is identical) and adds explanation, counterfactual, and global-driver methods.
You need a
ReasoningModel any time you want feature attributions or counterfactuals. Train one with op.reasoning.fit() instead of Trainer.model.predict()
Identical to Model.predict() above: accepts a Dataset and returns a numpy.ndarray of shape (n_samples,).
model.explain()
dataset. Each attribution value reflects how much that feature pushed the prediction up or down relative to the model’s baseline.
Inference rows wrapped in an
op.Dataset. Column schema must match the training data.A
Reasoning object with three attributes.model.predict_and_explain()
predict() and explain() separately when you need both.
Inference rows wrapped in an
op.Dataset.A two-element tuple. The first element is the predictions array (shape
(n_samples,)). The second is a Reasoning object identical in structure to the one returned by explain().model.get_global_drivers()
Reasoning summarising which features are most important across the entire training distribution, rather than for a specific set of input rows.
A
Reasoning object where attributions has shape (n_features,), one scalar importance value per feature. feature_names is aligned with attributions. rules is None for global results.model.scenario()
dataset, finding the minimal feature edits that would shift the prediction to target_class. Each row is treated independently; results are returned together in a ScenarioResult.
Query rows to analyse. Each row receives its own set of counterfactual candidates.
The class label you want the counterfactual to reach. Defaults to
1 (the positive class in binary classification).Number of independent search attempts per query row. More trials improve the chance of finding a shorter path but increase latency. Leave as
None to use the OuterProduct default.Maximum number of feature edits allowed per attempt. Constraining this produces more actionable (smaller) counterfactuals. Leave as
None to use the OuterProduct default.A
ScenarioResult containing one QueryResult per input row. See ScenarioResult below for the full object tree.ScenarioResult
ScenarioResult is returned by model.scenario(). It groups all counterfactual results for a batch of query rows.
One
QueryResult per row in the input dataset, in the same order as the input rows.QueryResult
A single row’s counterfactual analysis.Zero-based index of this row within the input dataset, matching the original row order.
The model’s prediction for this row before any edits are applied.
True if the baseline prediction already belongs to target_class, meaning no change is required. When True, counterfactuals will be empty.Candidate counterfactual edits that would shift this row’s prediction to
target_class, ordered by fewest changes first. May be empty if the search found no valid path within the configured max_steps and n_trials.Counterfactual
One candidate set of edits for a single query row.Number of features modified in this counterfactual. Smaller is generally more actionable.
Mapping from feature name to a
Change object describing what value it held before and what it would need to become.Change
Describes a single feature edit within aCounterfactual.
The feature’s value in the original query row.
The value the feature would need to take for the counterfactual to reach
target_class.Predictor
Predictor wraps an arbitrary HTTP scoring endpoint so you can use an existing model as a teacher in OuterProduct’s distillation flow. Pass a Predictor as the teacher argument to op.reasoning.fit() to distil a ReasoningModel that mimics the teacher’s predictions while adding full reasoning.
The HTTP endpoint that accepts inference requests and returns predictions. OuterProduct will POST batches of rows to this URL during training.
Optional dictionary of HTTP request headers, such as
{"Authorization": "Bearer <token>"}. Use this to authenticate against a secured scoring endpoint.When a
teacher is provided, task is optional: OuterProduct queries the teacher to generate training labels. You can still supply a task with a label_column if you want to blend ground-truth labels with teacher predictions.