src.train_logistic_classifier
train_logistic_classifier.py
This script trains a logistic regression classifier on latent representations obtained from an encoder model. It loads latent vectors and their corresponding binary labels, splits them into training and testing subsets, trains a LogisticRegression model using scikit-learn, evaluates its performance (accuracy, classification report, and optionally confusion matrix), and saves the trained model to disk in .pkl format.
- Usage:
python train_logistic_classifier.py –latents X_latents.npy –labels y_labels.npy –output model.pkl [–plot]
Example
python train_logistic_classifier.py –latents data/X_latents.npy –labels data/y_labels.npy –output output/logistic_model.pkl –test_size 0.25 –max_iter 500 –seed 123 –plot
Functions
|
Train and evaluate a logistic regression classifier on latent representations. |