New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] InceptionTime does not support validation data with fewer classes than in the training data #5864
[BUG] InceptionTime does not support validation data with fewer classes than in the training data #5864
Comments
I just had a brief glance at the former sktime-dl classifiers migrated to the sktime repository. It seems like the issue is fixed, but there is a potential footgun. I would be interested in a maintainers opinion on how to proceed. Or is my interpretation incorrect? Potential problemOne one hand, it seems like sktime/sktime/classification/deep_learning/base.py Lines 106 to 123 in d86114f
In turn, convert_y_to_keras is referenced by all classifiers in the _fit but not in the _predict functions.sktime/sktime/classification/deep_learning/inceptiontime.py Lines 138 to 152 in d86114f
Thus, predicting will not implicitly (and wrongly) re-fit the label-encoder. On the other hand, X_train, y_train = load_training_data(...) # y is encoded as categorical class labels.
X_test, y_test = load_training_data(...) # y is encoded as categorical class labels.
clf = InceptionTimeClassifier() # Or many other deep classifiers
clf.fit(X_train, y_train)
score = clf.score(X_test, clf.convert_y_to_keras(y_test)) # Because clf.score(X_test, y_test) will fail. Possible solutions
[1] https://keras.io/api/layers/core_layers/dense/, see "Output shape" section:
|
PS: I initially observed this problem when training InceptionTime https://github.com/cedricdonie/tsc-for-wrist-motion-pd-detection/blob/main/src/models/train_model.py and fixed it for myself via sktime/sktime-dl#132. The dataset is quite large however, so it won't be trivial to reproduce. |
Welcome back, @cedricdonie! Sorry for the long silence, we migrated We've pinged you here If it is still relevant, it would be greta if you could move it to
The tests are currently skipped in |
Hi @fkiraly, after migration to sktime proper, sktime/sktime-dl#132 is definitely not a valid fix anymore. Thus, I tried to understand whether this issue still remains in |
Hm, interesting. I think your observation - that the output of I would prefer Besides that, I would combine with your suggestion to not refit the encoder in FYI,
|
@fkiraly I agree with your proposal. Let's simply make it private to prevent potentially causing bugs for users.
I think that this is already the case, as per my above comment: In fact, it could be beneficial to implement a test case that ensures that |
Excellent! Would you then like to make a PR to Recarding your comments:
|
Yes, I created PR #6373.
Great! I have no reason to believe that this is not working. And the present issue is a bug only if the user calls However, we might have an issue with |
Describe the bug
When I input a validation dataset that contains fewer categories than the training dataset, I get the following error.
To Reproduce
I'm having trouble producing a MWE. The following code works unexpectedly.
Expected behavior
The label encoder will pad with zeros, allowing training with validation data with fewer classes.
Additional context
The onehot encoder is refitted to validation data. Maybe that is the issue?
Versions
The text was updated successfully, but these errors were encountered: