Batch construction parameter optimization
Curated, evidence-grounded skill and software-tool collections for scientific AI agents, generated by the AgenticScienceBuilder
npx -y skills add HolobiomicsLab/asb-skill-collections --skill batch-construction-parameter-optimizationAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 14 stars14 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Use when preparing labeled LC-MS peak data for neural network training and you need to decide whether class imbalance in your dataset should be preserved or corrected in batch construction. Use it particularly when your annotated peak dataset has unequal class distributions (e.
The file declares its own license as CC-BY-4.0. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
8.0 KB, ~1.3k tokens by cl100k_base, as published. Nobody here has run it
Batch Construction Parameter Optimization
Summary
Optimize the creation of training, validation, and test batches for neural network training by systematically comparing class-normalized versus unnormalized batch creation strategies. This skill determines whether to balance class distributions within batches based on dataset characteristics and model training objectives.
When to use
Apply this skill when preparing labeled LC-MS peak data for neural network training and you need to decide whether class imbalance in your dataset should be preserved or corrected in batch construction. Use it particularly when your annotated peak dataset has unequal class distributions (e.g., true peaks vs. false positives) and you must evaluate the trade-off between training on natural class proportions versus ensuring equal representation per class.
When NOT to use
- Your annotated dataset already has balanced class counts — batch normalization will discard data unnecessarily
- You are using transfer learning with a pre-trained model rather than full model training — the pre-trained weights may already encode class-balanced assumptions
- Your dataset has fewer than 500 peaks in the smallest class and you intend full model training — normalization will further reduce per-class sample counts below recommended minimums
Inputs
- Labeled NeatMS Experiment object (instantiated with raw_data_folder_path, feature_table_path, and input_data containing 10–20 pooled representative samples)
- NN_handler object (initialized with experiment, matrice_size, margin, and min_scan_num parameters)
Outputs
- Training batch set (80% of normalized or unnormalized data)
- Validation batch set (10% of normalized or unnormalized data)
- Test batch set (10% of normalized or unnormalized data)
- Batch metadata (peak counts per class per batch for comparison)
How to apply
Instantiate an NN_handler object with your labeled Experiment object and fixed parameters (matrice_size=120, margin=1, min_scan_num=5). Generate two parallel batch sets by calling nn_handler.create_batches(validation_split=0.1, normalise_class=False) and nn_handler.create_batches(validation_split=0.1, normalise_class=True). The first call preserves the original class distribution across 80% training, 10% test, and 10% validation splits; the second rebalances all three batches so each class contributes exactly N peaks, where N equals the smallest class count in the dataset. Compare the resulting peak count distributions per class per batch to assess which normalization strategy better suits your downstream model training and evaluation goals. When normalise_class=True is selected, verify that the constraint 'number of peaks for each class will be equal to the smallest class' is satisfied in all batches.
Related tools
- NeatMS (Provides NN_handler class and create_batches() method to partition and optionally balance labeled LC-MS peak data into training, validation, and test cohorts) — https://github.com/bihealth/NeatMS
- Python (Language for scripting batch creation and comparison workflow)
- Keras (Neural network training framework that consumes the generated batches for model training)
Examples
nn_handler.create_batches(validation_split=0.1, normalise_class=False)
nn_handler.create_batches(validation_split=0.1, normalise_class=True)
Evaluation signals
- Verify that unnormalized batches reflect the original class distribution from the full labeled dataset (calculated as percentage of peaks per class in training, validation, and test sets)
- Confirm that normalized batches satisfy the invariant: all classes have identical peak counts within each batch, and that count equals min(class_counts) from the full dataset
- Compare total peak counts across both batch sets; unnormalized should preserve all peaks, while normalized should discard peaks from larger classes such that all classes are downsampled to the smallest class size
- Inspect batch metadata to verify validation_split=0.1 is honored (test + validation = 20% of total, validation = 10% of original data) in both normalization modes
- Run a preliminary model training step with both batch sets and track convergence speed and final validation accuracy to empirically assess which normalization choice improves generalization on held-out peaks
Limitations
- Normalizing class distributions discards peaks from overrepresented classes, potentially losing information about natural class prevalence in real LC-MS data
- The method assumes you have labeled at least enough peaks to form meaningful batches after normalization; if the smallest class is very small, normalized batches may be too sparse for effective training
- Class normalization is applied uniformly across all three batches (training, validation, test); there is no option to normalize only training while preserving test/validation class distributions
- The choice between normalization modes must be made before training; switching strategies mid-training requires complete batch regeneration and model retraining
Evidence
- [other] When normalise_class is set to True, the create_batches() method ensures that every class has an equal number of peaks in the resulting training batches, with the total number of peaks per class equal to the smallest class count: "When normalise_class is set to True, the create_batches() method ensures that every class has an equal number of peaks in the resulting training batches, with the total number of peaks per class"
- [methods] The
normalise_classargument allows you to make sure every class has the same number of peaks for the training, when set toTrue, the number of peaks for each class will be equal to the smallest: "Thenormalise_classargument allows you to make sure every class has the same number of peaks for the training, when set toTrue, the number of peaks for each class will be equal to the smallest" - [methods] NeatMS provides the necessary functions to do that, all we will have to do is create a
Neural network handlerobject and call the batch creation method.: "NeatMS provides the necessary functions to do that, all we will have to do is create aNeural network handlerobject and call the batch creation method" - [methods] For optimal training, we recommend to use a representative subset of the dataset that your are planning to analyse, or as similar as possible.: "For optimal training, we recommend to use a representative subset of the dataset that your are planning to analyse, or as similar as possible"
- [methods] When choosing this option, we recommend that you have at the very least 500 peaks for each class (or 500 peaks in the smallest class).: "When choosing this option, we recommend that you have at the very least 500 peaks for each class (or 500 peaks in the smallest class)"
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.