src.evaluate_latent_classifier

Evaluate classifier performance on latent representations extracted from Transformer encoders.

This script: - Iterates over multiple cross-validation folds from a given model directory. - Loads test data and the corresponding encoder model per fold. - Extracts latent representations using the encoder. - Trains and evaluates a logistic regression classifier on the latent space. - Computes and saves classification metrics, including confusion matrices. - Stores all results in a CSV file for further analysis.

Usage:

python evaluate_latent_classifier.py –model_dir models_len150 –original_dataset data_balanced/dataset_balanced_len150_50Hz.hdf5 –output_csv results_latent_classifier.csv –output_dir evaluation/eval_len150 –save

Functions

evaluate_classifier(X_latent, y_true, ...[, ...])

Train and evaluate a classifier on the latent space for one fold.

extract_segment_length(path)

Extract the segment length string from a file or folder name.

main()

Main routine to evaluate all folds in a model directory.