training-validation-dataset-stratification
Summary
Split a labelled MS/MS spectral dataset into training and validation subsets to enable unbiased evaluation of binary classifiers that distinguish relevant compounds from other compounds. This skill ensures robust performance assessment by reserving held-out data for testing before model deployment.
When to use
When you have a complete labelled MS/MS spectral dataset annotated as 'relevant' (compounds of interest from reference standards) or 'other' (reference standards or non-target compounds from repositories), and you need to train and evaluate an AnnoMe binary classifier without data leakage. Apply this skill before training to prevent overfitting and obtain honest performance estimates.
When NOT to use
- Dataset is already split and balanced; this skill is redundant if train/validation partitions exist and class distribution is known.
- Unlabelled or partially labelled spectra; this skill requires complete annotation into 'relevant' or 'other' classes before splitting.
- Single-class dataset or severely imbalanced dataset (e.g., >95% one class); the README warns that 'most often the classification will not be successful, especially when the training dataset is highly imbalanced'.
Inputs
- Labelled MS/MS spectral dataset (MGF or equivalent format) with annotations: 'relevant' or 'other' class labels
- Reference standards MS/MS spectra (for 'relevant' class)
- Other compounds MS/MS spectra from reference standards or repositories (for 'other' class)
Outputs
- Training subset (70–80% of labelled spectra)
- Validation subset (20–30% of labelled spectra)
- Trained binary classifier model (serialized)
- Performance metrics (accuracy, precision, recall, F1-score on validation subset)
How to apply
Load your labelled MS/MS spectral dataset into AnnoMe, ensuring spectra are annotated into two classes: 'relevant' for compounds of interest and 'other' for reference standards or non-target compounds. Preprocess the full dataset using AnnoMe's built-in normalization and feature extraction to ensure consistent representation. Stratify the dataset by splitting into training and validation subsets (typical ratio 70–80% training, 20–30% validation) while preserving class distribution to avoid imbalance bias. Train the binary classifier on the training subset using AnnoMe's default hyperparameters with cross-validation. Reserve the validation subset entirely for post-training evaluation, computing accuracy, precision, recall, and F1-score to assess classifier performance on unseen data before serializing the trained model.
Related tools
- AnnoMe (Loads labelled MS/MS spectral dataset, preprocesses spectra via normalization and feature extraction, splits into training/validation subsets, trains binary classifier, evaluates on validation set, and serializes trained model) — https://github.com/chrboku/AnnoMe
Examples
uv run annome_classificationgui # Load labelled MGF, select 'Training/Validation Split' option, set ratio to 75/25, preprocess with normalization, train on training subset, evaluate on validation subset
Evaluation signals
- Training and validation subset sizes sum to 100% of original labelled dataset; no spectra are duplicated across subsets.
- Class distribution (ratio of 'relevant' to 'other') is preserved or similar between training and validation subsets, indicating stratified split.
- Validation subset performance metrics (accuracy, precision, recall, F1-score) are computed only on data withheld from training; no training samples appear in validation results.
- Serialized model file is created and can be reloaded without error, confirming successful training completion.
- Performance metrics are reasonable and interpretable (values in [0, 1] range); extreme imbalance (e.g., F1-score << 0.1) signals dataset quality issues per README.
Limitations
- Classification of MS/MS spectra into substance classes is non-trivial; the README notes 'most often the classification will not be successful, especially when the training dataset is highly imbalanced.' Users are warned to exercise caution with results.
- Validation subset size and class balance directly affect reliability of performance estimates; small or severely imbalanced validation sets may not reflect real-world classifier performance.
- Stratification alone does not address missing or mislabelled spectra in the source dataset; data quality issues upstream of this skill will propagate into both subsets.
Evidence
- [other] Split dataset into training and validation subsets: "Split dataset into training and validation subsets."
- [other] Labelled MS/MS spectra annotated as 'relevant' or 'other': "Load labelled MS/MS spectral dataset containing spectra annotated as 'relevant' (compounds of interest) or 'other' (reference standards or non-target compounds)"
- [readme] Training data from reference standards and repositories: "the classifiers first need to be trained on a large set of MS/MS spectra of compounds of interest (e.g., obtained from reference standards) and others (e.g., obtained from reference standards of"
- [other] Evaluation on validation subset with performance metrics: "Evaluate classifier performance on the validation subset and log accuracy, precision, recall, and F1-score."
- [readme] Imbalance warning in README: "most often the classification will not be successful, especially when the training dataset is highly imbalanced."
1---2name: training-validation-dataset-stratification3description: Use when when you have a complete labelled MS/MS spectral dataset annotated as 'relevant' (compounds of interest from reference standards) or 'other' (reference standards or non-target compounds from repositories), and you need to train and evaluate an AnnoMe binary classifier without data leakage.4license: CC-BY-4.05---67# training-validation-dataset-stratification89## Summary1011Split a labelled MS/MS spectral dataset into training and validation subsets to enable unbiased evaluation of binary classifiers that distinguish relevant compounds from other compounds. This skill ensures robust performance assessment by reserving held-out data for testing before model deployment.1213## When to use1415When you have a complete labelled MS/MS spectral dataset annotated as 'relevant' (compounds of interest from reference standards) or 'other' (reference standards or non-target compounds from repositories), and you need to train and evaluate an AnnoMe binary classifier without data leakage. Apply this skill before training to prevent overfitting and obtain honest performance estimates.1617## When NOT to use1819- Dataset is already split and balanced; this skill is redundant if train/validation partitions exist and class distribution is known.20- Unlabelled or partially labelled spectra; this skill requires complete annotation into 'relevant' or 'other' classes before splitting.21- Single-class dataset or severely imbalanced dataset (e.g., >95% one class); the README warns that 'most often the classification will not be successful, especially when the training dataset is highly imbalanced'.2223## Inputs2425- Labelled MS/MS spectral dataset (MGF or equivalent format) with annotations: 'relevant' or 'other' class labels26- Reference standards MS/MS spectra (for 'relevant' class)27- Other compounds MS/MS spectra from reference standards or repositories (for 'other' class)2829## Outputs3031- Training subset (70–80% of labelled spectra)32- Validation subset (20–30% of labelled spectra)33- Trained binary classifier model (serialized)34- Performance metrics (accuracy, precision, recall, F1-score on validation subset)3536## How to apply3738Load your labelled MS/MS spectral dataset into AnnoMe, ensuring spectra are annotated into two classes: 'relevant' for compounds of interest and 'other' for reference standards or non-target compounds. Preprocess the full dataset using AnnoMe's built-in normalization and feature extraction to ensure consistent representation. Stratify the dataset by splitting into training and validation subsets (typical ratio 70–80% training, 20–30% validation) while preserving class distribution to avoid imbalance bias. Train the binary classifier on the training subset using AnnoMe's default hyperparameters with cross-validation. Reserve the validation subset entirely for post-training evaluation, computing accuracy, precision, recall, and F1-score to assess classifier performance on unseen data before serializing the trained model.3940## Related tools4142- **AnnoMe** (Loads labelled MS/MS spectral dataset, preprocesses spectra via normalization and feature extraction, splits into training/validation subsets, trains binary classifier, evaluates on validation set, and serializes trained model) — https://github.com/chrboku/AnnoMe4344## Examples4546```47uv run annome_classificationgui # Load labelled MGF, select 'Training/Validation Split' option, set ratio to 75/25, preprocess with normalization, train on training subset, evaluate on validation subset48```4950## Evaluation signals5152- Training and validation subset sizes sum to 100% of original labelled dataset; no spectra are duplicated across subsets.53- Class distribution (ratio of 'relevant' to 'other') is preserved or similar between training and validation subsets, indicating stratified split.54- Validation subset performance metrics (accuracy, precision, recall, F1-score) are computed only on data withheld from training; no training samples appear in validation results.55- Serialized model file is created and can be reloaded without error, confirming successful training completion.56- Performance metrics are reasonable and interpretable (values in [0, 1] range); extreme imbalance (e.g., F1-score << 0.1) signals dataset quality issues per README.5758## Limitations5960- Classification of MS/MS spectra into substance classes is non-trivial; the README notes 'most often the classification will not be successful, especially when the training dataset is highly imbalanced.' Users are warned to exercise caution with results.61- Validation subset size and class balance directly affect reliability of performance estimates; small or severely imbalanced validation sets may not reflect real-world classifier performance.62- Stratification alone does not address missing or mislabelled spectra in the source dataset; data quality issues upstream of this skill will propagate into both subsets.6364## Evidence6566- [other] Split dataset into training and validation subsets: "Split dataset into training and validation subsets."67- [other] Labelled MS/MS spectra annotated as 'relevant' or 'other': "Load labelled MS/MS spectral dataset containing spectra annotated as 'relevant' (compounds of interest) or 'other' (reference standards or non-target compounds)"68- [readme] Training data from reference standards and repositories: "the classifiers first need to be trained on a large set of MS/MS spectra of compounds of interest (e.g., obtained from reference standards) and others (e.g., obtained from reference standards of"69- [other] Evaluation on validation subset with performance metrics: "Evaluate classifier performance on the validation subset and log accuracy, precision, recall, and F1-score."70- [readme] Imbalance warning in README: "most often the classification will not be successful, especially when the training dataset is highly imbalanced."