Skip to content

Feature/multiclass cli classify#377

Open
gbeane wants to merge 7 commits into
feature/multiclassfrom
feature/multiclass-cli-classify
Open

Feature/multiclass cli classify#377
gbeane wants to merge 7 commits into
feature/multiclassfrom
feature/multiclass-cli-classify

Conversation

@gbeane
Copy link
Copy Markdown
Collaborator

@gbeane gbeane commented May 12, 2026

This pull request significantly refactors and extends the src/jabs/scripts/classify.py script to add robust support for multi-class classification in addition to binary classification. It introduces new helper functions for classifier loading and training, updates the main classification logic to handle both classifier types, and improves code clarity and type safety throughout. The changes also enhance user feedback and error handling, and update command-line argument parsing and documentation.

Key changes include:

Multi-class Classification Support:

  • Added support for multi-class classifiers throughout the script, including new helper functions (_is_multiclass_training_file, train_multiclass, _load_classifier_from_pickle) and updates to the main classification and training logic to handle both binary and multi-class cases. [1] [2] [3]

Refactoring and Type Improvements:

  • Updated function signatures and variable types for better type safety and clarity, including explicit return types and clearer argument documentation. [1] [2] [3] [4] [5] [6]

Enhanced Classifier Loading and Error Handling:

  • Improved classifier loading logic to auto-detect classifier type from pickle files, with robust error handling for version mismatches and unrecognized types. [1] [2]

Command-line Interface and Documentation:

  • Updated command-line argument help messages, improved docstrings, and clarified usage instructions for both binary and multi-class workflows. [1] [2] [3] [4]

Prediction Output and File Handling:

  • Modified prediction output logic to handle multi-class probability matrices and updated output file naming and directory creation for consistency. [1] [2]

These changes collectively make the script more robust, extensible, and user-friendly for both binary and multi-class behavior classification tasks.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors src/jabs/scripts/classify.py to support both binary and multi-class behavior classification from the CLI, including training from exported HDF5 and classification using either training exports or serialized classifier pickles.

Changes:

  • Added multi-class training detection and training path (_is_multiclass_training_file, train_multiclass), and updated classification flow to accept Classifier | MultiClassClassifier.
  • Updated prediction writing to support multi-class probability tensors and to use a dedicated multi-class prediction key.
  • Improved CLI help text and type annotations across the script, plus added a new classifier pickle loading helper.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/jabs/scripts/classify.py Outdated
Comment thread src/jabs/scripts/classify.py
Comment thread src/jabs/scripts/classify.py Outdated
Comment thread src/jabs/scripts/classify.py
@gbeane gbeane marked this pull request as ready for review May 12, 2026 13:46
@gbeane gbeane self-assigned this May 12, 2026
@gbeane gbeane requested review from bergsalex and keithshep May 12, 2026 13:47
Base automatically changed from feature/t13-multiclass-export to feature/multiclass May 15, 2026 01:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants