artefactual.scoring.TokenProbaMixin#

class artefactual.scoring.TokenProbaMixin[source]#

Bases: object

predict_token_proba for a classifier that builds a fitted pipeline_.

The class sets pipeline_, a fitted Pipeline, in fit. predict_token_proba scores through token_proba(self.pipeline_.steps, X).

X is a logprob array, as predict_proba takes it. A completion response raises TypeError naming is_logprob_array. Responses are scored through make_detector or DetectorPipeline, which parse them into logprob arrays first.

Methods

predict_token_proba

Per-token probabilities of class 1, for locating where a response drifts.

predict_token_proba(X)[source]#

Per-token probabilities of class 1, for locating where a response drifts.

Parameters:

X (array-like) – The same input predict_proba accepts: a logprob array of shape (n_sequences, n_tokens, width) or (n_sequences, width).

Returns:

Probability of class 1 per token, NaN at padded positions; (0, 0, 1) for an empty batch.

Return type:

ndarray of shape (n_sequences, max_tokens, 1)

Raises:
  • NotFittedError – If the estimator is not fitted.

  • TypeError – If X holds completion responses, if the class has no pipeline_, or from token_proba if the pipeline cannot score tokens or its last step is not a fitted classifier of two classes.