personalitylinmult.inference.predictor

Load a trained FI checkpoint and predict Big Five scores from features.

A checkpoint is self-describing: FiLightningModule.load_from_checkpoint() rebuilds the exact model from the feature_names / input_feature_dim / configs stored in its hyperparameters, so FiPredictor needs no external metadata — the path alone is enough.

The predictor is deliberately model-agnostic (the checkpoint decides which features it consumes and which traits it emits), so the same class serves the audio-only (A) and full multimodal (AVT) models without a code change.

Attributes

logger

Module-level logger.

Exceptions

InferenceError

Raised when features do not match what the checkpoint expects.

Classes

FiPredictor

Predicts Big Five trait scores from per-modality features.

Module Contents

personalitylinmult.inference.predictor.logger

Module-level logger.

exception personalitylinmult.inference.predictor.InferenceError[source]

Bases: Exception

Raised when features do not match what the checkpoint expects.

Initialize self. See help(type(self)) for accurate signature.

class personalitylinmult.inference.predictor.FiPredictor(module: personalitylinmult.train.module.FiLightningModule)[source]

Predicts Big Five trait scores from per-modality features.

Parameters:

module (FiLightningModule) – A loaded, eval-mode Lightning module.

feature_names

Features this model consumes, in input order.

Type:

list[str]

traits

Trait names, in output-column order.

Type:

list[str]

classmethod from_checkpoint(path: str | pathlib.Path, map_location: str = 'cpu') → FiPredictor[source]

Load a predictor from a training checkpoint.

Parameters:
  • path (str | Path) – Path to a .ckpt written by training.

  • map_location (str) – Device to map tensors onto. "cpu" keeps inference portable (a demo host rarely has the training GPU).

Returns:

Ready to predict.

Return type:

FiPredictor

Raises:

FileNotFoundError – If the checkpoint does not exist.

predict(features: dict[str, numpy.ndarray]) → dict[str, float][source]

Predict Big Five scores for one sample.

Parameters:

features (dict[str, np.ndarray]) – One (T, F) array per feature the model expects (see feature_names).

Returns:

{trait: score} with scores clamped to [0, 1], in the model’s trait order.

Return type:

dict[str, float]

Raises:

InferenceError – If the features do not match the model.