Fix: Stratified Splitting to Prevent Calibration Crash#58
Open
thechillbasu wants to merge 2 commits intoruxailab:mainfrom
Open
Fix: Stratified Splitting to Prevent Calibration Crash#58thechillbasu wants to merge 2 commits intoruxailab:mainfrom
thechillbasu wants to merge 2 commits intoruxailab:mainfrom
Conversation
|
Hii @thechillbasu , is there any specific reason why you changed the variable name or am i considering anything wrong ? PS :- X_train_x is changed to X_X_train |
Author
|
Hey @Nirvanjha2004 ! There wasn't any specific reason. To be honest, it was more of an oversight and a mistake from my end. Thank you so much for pointing it out. I will change it back to the original naming convention. Would you like to give some more feedback which I could learn from? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The calibration system was crashing for specific configurations with low sample counts (e.g., 5 points × 10 samples).
Technical Analysis:
The issue was triggered when clicking the "FINISH" button. The console showed:
TypeError: Cannot read property 'PrecisionSD' of undefined.This occurred because the backend's data splitting logic was random and non-stratified:
Note: Be aware that configurations with < 4 points may also face the Frontend Rendering Bug (points not showing up). See the corresponding Frontend Issue and PR (Issue #110 and PR #111).
For these specific combinations, the random split over the pooled dataset deterministically excludes entire points from the test set. Verified failures with
random_state=42:Reasoning: The fixed random seed (42) causes the random sampler to pick a set of indices that, for these total sample sizes, happens to completely bypass the index range of the missing point. This leaves the test set empty for that specific class. Consequently, the backend returns predictions missing keys, crashing the frontend.
Solution and Reasoning
I implemented stratified splitting in
gaze_tracker.py.Why this fixes it:
By stratifying the split based on the target class (Point IDs), we ensure that every calibration point is represented in both the Training and Test sets, even for small sample sizes.
This guarantees that the backend always returns complete metrics for all points, preventing the frontend crash.
Before and After
Before (Bug)
The application crashes on "FINISH".
before-fix-stratified.mov
After (Fix)
The application successfully processes data and redirects.
after-fix-stratified.mov
Closes #57