# 685th Place Solution for the Child Mind Institute - Detect Sleep States Competition

I would like to express gratitude to Kaggle for hosting the competition and Child Mind Institute for providing a dataset.
I'm so grateful to 213TUBO for sharing the public notebook
[https://www.kaggle.com/code/tubotubo/cmi-submit?scriptVersionId=149255724](https://www.kaggle.com/code/tubotubo/cmi-submit?scriptVersionId=149255724)
.
I gained a lot of knowledge from github
[https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states](https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states)
.
Context
•    Business context:
[https://www.kaggle.com/competitions/child-mind-institute-detect-sleep-states/overview](https://www.kaggle.com/competitions/child-mind-institute-detect-sleep-states/overview)
•    Data context:
[https://www.kaggle.com/competitions/child-mind-institute-detect-sleep-states/data](https://www.kaggle.com/competitions/child-mind-institute-detect-sleep-states/data)
Overview of the approach
The models
The framework Torch, models UNet, and AutoModel were used.
Owner
Github
213TUBO
[https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/tree/main/src/models](https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/tree/main/src/models)
src.models.detr2D  DETR2DCNN
 src.models.spec1D  Spec1D
 src.models.spec2Dcnn  Spec2DCNN
 src.models.transformerautomodel  TransformerAutoModel
 src.models.centernet  CenterNet
Data preprocessing, feature engineering:
Name
Value
Score th
0.02
Distance
10
Add feature:
Field
Function
Anglez, enmo
diff
Anglez, enmo
mean, avg
Hour
sin, cos
Augmentations:
Type
Name
Value
Mixup
prob
0.0
Mixup
alpha
0.4
Cutmix
prob
0.0
Cutmix
alpha
0.4
Validation Strategy
Use a train_series_ids and a valid_series_ids.
The rate of downsample is 2.
Details of the submission
[https://www.kaggle.com/code/emmawilsonev/cmi-submit/edit/run/153313645](https://www.kaggle.com/code/emmawilsonev/cmi-submit/edit/run/153313645)
Private Score
Public Score
0.728
0.707
Code samples model training:
Training/Configuration
Code
Training
[https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/blob/main/src/modelmodule.py](https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/blob/main/src/modelmodule.py)
Configuration
[https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/blob/main/run/conf/train.yaml#L41](https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/blob/main/run/conf/train.yaml#L41)
Configuration:
Parameter
Value
epochs
50
gradient_clip_val
1.0
lr
0.0005
Code samples feature engineering:
num_frames = upsampled_num_frames  downsample_rate
onset, wakeup  this_event_df[[, ]].to_numpy():
        onset_pos = ((onset - start) / duration * num_frames)
        onset_offset = (onset - start) / duration * num_frames - onset_pos
        wakeup_pos = ((wakeup - start) / duration * num_frames)
        wakeup_offset = (wakeup - start) / duration * num_frames - wakeup_pos

        bbox_size = ((wakeup_pos, num_frames) - (onset_pos, )) / num_frames
Code samples model inference:
feature_extractor = get_feature_extractor(
            cfg.feature_extractor, feature_dim, num_timesteps
        )
        decoder = get_decoder(cfg.decoder, feature_extractor.height, n_classes, num_timesteps)
        model = Spec2DCNN(
            feature_extractor=feature_extractor,
            decoder=decoder,
            in_channels=feature_extractor.out_chans,
            mixup_alpha=cfg.aug.mixup_alpha,
            cutmix_alpha=cfg.aug.cutmix_alpha,
            **cfg.model.params,
        )
What was impactful about the submission.
Grait concept 213TUBO concerning sin and cos:
[https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/blob/main/run/prepare_data.py](https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/blob/main/run/prepare_data.py)
What was tried and didn’t work.
Skillet-learn gradient boosting.
Helpful notebooks:
Author
notebook/github
link
213TUBO
notebook
[https://www.kaggle.com/code/tubotubo/cmi-submit?scriptVersionId=149255724](https://www.kaggle.com/code/tubotubo/cmi-submit?scriptVersionId=149255724)
213TUBO
github
[https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states](https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states)
Thank you for reading.