sktime icon indicating copy to clipboard operation
sktime copied to clipboard

[ENH] in TSC, add single labeled dataset warning

Open Faakhir30 opened this issue 9 months ago • 3 comments

Is your feature request related to a problem? Please describe.

Classification tasks are generally supposed to have atleast 2 class labels. Adding a check for this to all tensorflow and torch models in classification/deep_learning module is a good first enhancement.

Describe the solution you'd like

In classification/deep_learning module, raising a userwarning at _fit in tensorflow models and build_network in torch models is suggested.


        self.num_classes = len(np.unique(y))

        if self.num_classes == 1:
            warnings.warn(
                "The provided data passed to XXClassifierTorch contains " # replace XXClassifierTorch with class name
                "a single label. If this is not intentional, please check.",
                UserWarning,
            )

Additional context

Originally posted by @RecreationalMath in https://github.com/sktime/sktime/pull/9298#discussion_r2779468790

Faakhir30 avatar Feb 09 '26 05:02 Faakhir30

@Faakhir30 This issue description is not descriptive enough. I'd suggest sticking to the Issue template.

RecreationalMath avatar Feb 19 '26 08:02 RecreationalMath

@Faakhir30 are you working on this? If not, can I work on it?

srupat avatar Feb 21 '26 17:02 srupat

@srupat Yes, I'm taking care of this soon. Issue description is not pointing to optimal solution.

This can be moved to base layer _base_torch.py with other base enhancements I'm working on.

Faakhir30 avatar Feb 21 '26 17:02 Faakhir30