Key takeaway

A probability belongs to a named class on a defined output axis. Numeric equality and a sum of one cannot establish that the class mapping survived.

A well-formed vector can carry the wrong meaning

A model export contains two probabilities that sum to one. The receiving integration preserves both numbers, checks their range and obtains a plausible label. It can still be wrong if the receiving code attaches the columns to classes in a different order. A successful numeric round trip has preserved the values while changing what each value describes.

Scikit-learn’s LogisticRegression documentation states that predict_proba columns follow self.classes_. The ONNX ZipMap operator likewise associates each input tensor column one-for-one with keys supplied in its class-label attributes. Those are explicit mapping contracts. Neither permits a receiver to infer class order from a preferred positive label or a human-facing display order.

Two invented cases reveal a reversed axis

In this hypothetical fixture, the fitted output axis is [fault, normal]. Case X has vector [0.8,0.2]; case Y has [0.1,0.9]. Under the stated axis, the probability attached to fault is 0.8 for X and 0.1 for Y. The table uses the largest value only as an illustrative class readout; it supplies no authority to automate any operational action.

Suppose a receiving view silently uses [normal, fault] without also reordering the values. It reads X as 0.8 normal and Y as 0.9 fault, reversing both labels in this fixture. Every probability is still between zero and one and each row still totals one. A schema check limited to shape, range and row sum therefore misses the defect.

Hypothetical caseUnchanged vectorCorrect fitted axis [fault, normal]Wrong receiving axis [normal, fault]
X[0.8, 0.2]fault 0.8; largest class faultfault 0.2; largest class normal
Y[0.1, 0.9]fault 0.1; largest class normalfault 0.9; largest class fault

Reorder values and labels together, or use explicit keys

If the receiving display requires normal before fault, a legitimate reordered representation for X is [0.2,0.8] with axis [normal,fault]. Both the label list and corresponding values move together. Alternatively, a keyed representation can retain fault:0.8 and normal:0.2 without asking a consumer to guess which unnamed position represents fault. The author checked these mappings directly on the synthetic pairs.

ONNX ZipMap requires as many class keys as tensor columns and exactly one of its string-key or integer-key attribute types. A matching count is necessary for that operator contract but does not prove that someone supplied the correct business labels. Inspect the actual exported keys and compare them with the fitted model’s class metadata. A mislabeled map can be structurally valid.

Do not use an incidental iteration order over a resulting map as a new class-axis contract. Resolve probabilities by their declared keys, or retain a separately versioned axis when the receiving interface must use a matrix. An integer class code also needs its vocabulary mapping; preserving the number 1 does not establish what outcome 1 means in a later model version.

Identify output kind before applying a probability rule

The cited scikit-learn interface separately documents predict_log_proba and predict_proba. They have related class ordering but different numeric meanings. Keep output kind, class vocabulary, axis order, model identity and transformation history in the receiving contract. An unlabeled matrix called scores is too ambiguous for an acceptance claim that refers to a class probability.

For a binary task, identify the positive class by its fitted metadata and declared task meaning before extracting a column. Hard-coding the second column may happen to work in one fitted model and fail after a vocabulary or ordering change. This article does not decide the action threshold or establish calibration; both require the correctly identified score first.

Also preserve case alignment. Correct class columns attached to the wrong input rows create another semantic failure. The synthetic contract should bind an input case identifier to its expected keyed output and explicit axis. Use test identities rather than real personal or confidential identifiers when examining the integration structure.

Accept class meaning as well as numeric preservation

The completed fixture rejects the unchanged vectors under the reversed label list and accepts either the original fitted order or a jointly reordered values-and-labels view. The acceptance artifact records model/version, output kind, class codes and meanings, exact axis or key attributes, receiving transformation and expected case-level mappings. A model update that changes the vocabulary requires a new comparison.

An actual receiving test should compare keyed probabilities across the source model, exported representation and consumer, including a non-symmetric case that reveals a swap. Equal 0.5/0.5 values would hide this particular error. The useful conclusion is that class identity survived the specified path; accuracy, calibration, threshold suitability and permission to use real evaluation records remain separate evidence questions.

Tools for this decision

Data inventory builder →Diligence question builder →