NumPy allowed · plain Python earns 10 bonus points
Computed matrix × vector transformation
Partition dataset indices into train and test sets while preserving class label proportions.
Implement stratified_split_indices(labels, test_size). Group indices by label (processed in alphabetical order of labels). For each label with indices C, calculate n_test = round(len(C) * test_size) and n_train = len(C) - n_test. Put the first n_train indices into train and the remaining n_test into test. Return (sorted(train_indices), sorted(test_indices)).
stratified_split_indices(labels: list[str], test_size: float) -> tuple[list[int], list[int]]