Child Mind Institute - Detect Sleep States(2023年第一次Kaggle拿到了銀牌總結)

感謝

感謝艾兄(大佬帶隊)、rich師弟(師弟通過這次比賽機械轉碼成功、耐心學習)、張同學(也很有耐心的在學習),感謝開源方案(開源就是銀牌),在此基礎上一個月不到收獲到了很多,運氣很好。這個是我們比賽的總結:?

我們隊Kaggle CMI銀牌方案,歡迎感興趣的伙伴upvote:https://www.kaggle.com/competitions/child-mind-institute-detect-sleep-states/discussion/459610


計劃 (系統>結果,穩健>取巧)

團隊計劃表,每個人做的那部分工作,避免重復,方便交流,提高效率,這個工作表起了很大的作用。


具體方案?

75th Place Detailed Solution - Spec2DCNN + CenterNet + Transformer + NMS

First of all, I would like to thank?@tubotubo?for sharing your high-quality code, and also thank my teammates?@liruiqi577?@brickcoder?@xtzhou?for their contributions in the competition. Here, I am going to share our team’s “snore like thunder” solution from the following aspects:

  1. Data preprocessing
  2. Feature Engineering
  3. Model
  4. Post Processing
  5. Model Ensemble

1. Data preprocessing

We made EDA and readed open discussions found that there are 4 types of data anomalies:

  • Some series have a high missing rate and some of them do not even have any event labels;
  • In some series , there are no event annotations in the middle and tail (possibly because the collection activity has stopped);
  • The sleep record is incomplete (a period of sleep is only marked with onset or wakeup).
  • There are outliers in the enmo value.

To this end, we have some attempts, such as:

  • Eliminate series with high missing rates;
  • Cut the tail of the series without event labels;
  • Upper clip enmo to 1.

But the above methods didn't completely work. In the end, our preprocessing method was:

We split the dataset group by series into 5 folds. For each fold, we eliminate series with a label missing rate of 100% in the training dataset while without performing any data preprocessing on the validation set. This is done to avoid introducing noise to the training set, and to ensure that the evaluation results of the validation set are more biased towards the real data distribution, which improve our LB score + 0.006.

Part of our experiments as below:

ExperimentFold0Public (single fold)Private (5-fold)
No preprocess missing data0.7510.7180.744
Eliminate unlabeled data at the end of train_series & series with missing rate >80%0.7390.7090.741
Drop train series which don’t have any event labels0.7520.7240.749

2. Feature Engineering

  • Sensor features: After smoothing the enmo and anglez features, a first-order difference is made to obtain the absolute value. Then replace the original enmo and anglez features with these features, which improve our LB score + 0.01.
train_series['enmo_abs_diff'] = train_series['enmo'].diff().abs()
train_series['enmo'] = train_series['enmo_abs_diff'].rolling(window=5, center=True, min_periods=1).mean()
train_series['anglez_abs_diff'] = train_series['anglez'].diff().abs()
train_series['anglez'] = train_series['anglez_abs_diff'].rolling(window=5, center=True, min_periods=1).mean()
  • Time features: sin and cos hour.

In addition, we also made the following features based on open notebooks and our EDA, such as: differential features with different orders, rolling window statistical features, interactive features of enmo and anglez (such as anglez's differential abs * enmo, etc.), anglez_rad_sin/cos, dayofweek/is_weekend (I find that children have different sleeping habits on weekdays and weekends). But strangely enough, too much feature engineering didn’t bring us much benefit.

ExperimentFold0Public (5-fold)Private (5-fold)
anglez + enmo + hour_sin + hour_cos0.7630.7310.768
anglez_abs_diff + enmo_abs_diff + hour_sin + hour_cos0.7710.7410.781

3. Model

We used 4 models:

  • CNNSpectrogram + Spec2DCNN + UNet1DDecoder;
  • PANNsFeatureExtractor + Spec2DCNN + UNet1DDecoder.
  • PANNsFeatureExtractor + CenterNet + UNet1DDecoder.
  • TransformerAutoModel (xsmall, downsample_rate=8).

Parameter Tunning: Add more kernel_size 8 for CNNSpectrogram can gain +0.002 online.

Multi-Task Learning Objectives: sleep status, onset, wake.

Loss Function: For Spec2DCNN and TransformerAutoModel, we use BCE, but with multi-task target weighting, sleep:onset:wake = 0.5:1:1. The purpose of this is to allow the model to focus on learning the last two columns. We tried to train only for the onset and wake columns, but the score was not good. The reason is speculated that?the positive samples in these two columns are sparse, and MTL needs to be used to transfer the information from positive samples in the sleep status to the prediction of sleep activity events.?Also, I tried KL Loss but it didn't work that well.

self.loss_fn = nn.BCEWithLogitsLoss(pos_weight=torch.tensor([0.5,1.,1.]))

At the same time, we adjusted epoch to 70 and added early stopping with patience=15. The early stopping criterion is the AP of the validation dataset, not the loss of the validation set. batch_size=32.

ExperimentFold0Public (single fold)Private (5-fold)
earlystop by val_loss0.7500.6970.742
earlystop by val_score0.7510.7180.744
loss_wgt = 1:1:10.7520.7240.749
loss_wgt = 0.5:1:10.7550.7230.753

Note: we used the model_weight.pth with the best offline val_score to submit our LB instead of using the best_model.pth with the best offline val_loss。

4. Post Processing

Our post-processing mainly includes:

  • find_peaks(): scipy.signal.find_peaks;
  • NMS: This task can be treated as object detection. [onset, wakeup] is regarded as a bounding boxes, and score is the confident of the box. Therefore, I used a time-series NMS. Using NMS can eliminate redundant boxes with high IOU, which increase our AP.
def apply_nms(dets_arr, thresh):x1 = dets_arr[:, 0]x2 = dets_arr[:, 1]scores = dets_arr[:, 2]areas = x2 - x1order = scores.argsort()[::-1]keep = []while order.size > 0:i = order[0]keep.append(i)xx1 = np.maximum(x1[i], x1[order[1:]])xx2 = np.minimum(x2[i], x2[order[1:]])inter = np.maximum(0.0, xx2 - xx1 + 1)ovr = inter / (areas[i] + areas[order[1:]] - inter)inds = np.where(ovr <= thresh)[0]order = order[inds + 1]dets_nms_arr = dets_arr[keep,:]onset_steps = dets_nms_arr[:, 0].tolist()wakeup_steps = dets_nms_arr[:, 1].tolist()nms_save_steps = np.unique(onset_steps + wakeup_steps).tolist()return nms_save_steps

In addition, we set score_th=0.005 (If it is set too low, a large number of events will be detected and cause online scoring errors, so it is fixed at 0.005 here), and use optuna to simultaneously search the parameter distance in find_peaks and the parameter iou_threshold of NMS. Finally, when distance=72 and iou_threshold=0.995, the best performance is achieved.

import optunadef objective(trial):score_th = 0.005 # trial.suggest_float('score_th', 0.003, 0.006)distance = trial.suggest_int('distance', 20, 80)thresh = trial.suggest_float('thresh', 0.75, 1.)# find peakval_pred_df = post_process_for_seg(keys=keys,preds=preds[:, :, [1, 2]],score_th=score_th,distance=distance,)# nmsval_pred_df = val_pred_df.to_pandas()nms_pred_dfs = NMS_prediction(val_pred_df, thresh, verbose=False)score = event_detection_ap(valid_event_df.to_pandas(), nms_pred_dfs)return -scorestudy = optuna.create_study()
study.optimize(objective, n_trials=100)
print('Best hyperparameters: ', study.best_params)
print('Best score: ', study.best_value)
ExperimentFold0Pubic (5-fold)Private (5-fold)
find_peak-0.7450.787
find_peak+NMS+optuna-0.7460.789

5. Model Ensemble

Finally, we average the output probabilities of the following models and then feed into the post processing methods to detect events. By the way, I tried post-processing the detection events for each model and then concating them, but this resulted in too many detections. Even with NMS, I didn't get a better score.

The number of ensemble models: 4 (types of models) * 5 (fold number) = 20.

ExperimentFold0Pubic (5-fold)Private (5-fold)
model1: CNNSpectrogram + Spec2DCNN + UNet1DDecoder0.772090.7430.784
model2: PANNsFeatureExtractor + Spec2DCNN + UNet1DDecoder0.7770.7430.782
model3: PANNsFeatureExtractor + CenterNet + UNet1DDecoder0.759680.6340.68
model4: TransformerAutoModel0.74680--
model1 + model2(1:1)-0.7460.789
model1 + model2+model3(1:1:0.4)-0.750.786
model1 + model2+model3+model4(1:1:0.4:0.2)0.7520.787

Unfortunately, we only considered CenterNet and Transformer to model ensemble with a tentative attitude on the last day, but surprisingly found that?a low-CV-scoring model still has a probability of improving final performance as long as it is heterogeneous compared with your previous models. But we didn’t have more opportunities to submit more, which was a profound lesson for me.

Thoughts not done:

  • Data Augmentation: Shift the time within the batch to increase more time diversity and reduce dependence on hour features.

  • Model: Try more models. Although we try transformer and it didn’t work for us. I am veryyy looking forward to the solutions from top-ranking players.

Thanks again to Kaggle and all Kaggle players. This was a good competition and we learned a lot from it. If you think our solution is useful for you, welcome to upvote and discuss with us.

In addition, this is my first 🥈 silver medal. Thank you everyone for letting me learn a lot. I will continue to work hard. :)

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/209324.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/209324.shtml
英文地址,請注明出處:http://en.pswp.cn/news/209324.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

基于Lucene的全文檢索系統的實現與應用

文章目錄 一、概念二、引入案例1、數據庫搜索2、數據分類3、非結構化數據查詢方法1&#xff09; 順序掃描法(Serial Scanning)2&#xff09;全文檢索(Full-text Search) 4、如何實現全文檢索 三、Lucene實現全文檢索的流程1、索引和搜索流程圖2、創建索引1&#xff09;獲取原始…

模板與泛型編程

函數模板 顯示實例化 區別定義與聲明 T是模板形參 int是模板實參 inpunt是函數形參 3是函數實參 顯示實例化 模板必須實例化可見 翻譯單元一處定義原則 與內聯函數異同 引入原因&#xff1a;函數模板是為了編譯器兩個階段的處理 內聯函數是為了能在編譯期展開 模板實參的類…

Android Kotlin語言下的文件存儲

目錄 將數據存儲到文件中 創建文件和保存數據 讀取文件 SharedPreferences存儲 存儲數據到SharedPreferences中 Context類中的getSharedPreferences()方法 Activity類中的getPreferences()方法 從SharedPreferences中讀取數據 SQLite數據庫存儲 創建數據庫 調用數據…

Java導出word

原文地址 傳入的值不能為null,否則會報錯&#xff0c;IXDocReport 有自己的判null規則&#xff0c;比較麻煩&#xff0c;建議代碼直接把null替換成"" public void exportWord1(WeeklyMeetDataDto dto, HttpServletResponse response) {ServletOutputStream downLoad…

Ignis - Interactive Fire System

Ignis - 點火、蔓延、熄滅、定制! 全方位火焰系統。 這個插件在21年的項目中使用過很好用值使用概述 想玩火嗎?如果想的話,那么Ignis就是你的最佳工具。有了Ignis,你可以把任何物體、植被或帶皮帶骨的網狀物轉換為可燃物體,它就會自動著火。然后,火焰可以蔓延,點燃其他物…

Java 一對多

前言 Internet 協議集支持一個無連接的傳輸協議&#xff0c;該協議稱為用戶數據報協議&#xff08;UDP&#xff0c;User Datagram Protocol&#xff09;。UDP 為應用程序提供了一種無需建立連接就可以發送封裝的 IP 數據包的方法。 此代碼就是基于UDP協議編寫。 通常把一對多的…

【docker 】centOS 安裝docker

官網 docker官網 github源碼 卸載舊版本 sudo yum remove docker \docker-client \docker-client-latest \docker-common \docker-latest \docker-latest-logrotate \docker-logrotate \docker-engine 安裝軟件包 yum install -y yum-utils \device-mapper-persistent-data…

【優選算法系列】【專題二滑動窗口】第四節.30. 串聯所有單詞的子串和76. 最小覆蓋子串

文章目錄 前言一、串聯所有單詞的子串 1.1 題目描述 1.2 題目解析 1.2.1 算法原理 1.2.2 代碼編寫 1.2.3 題目總結二、最小覆蓋子串 2.1 題目描述 2.2 題目解析 2.2.1 算法原理 2.2.2 代碼編寫 …

【Docker】進階之路:(四)操作容器

【Docker】進階之路&#xff1a;&#xff08;四&#xff09;Docker容器 容器的生命周期創建容器docker createdocker run 管理容器查看運行的容器&#xff1a;查看所有容器&#xff1a; 啟動與終止啟動容器終止容器 進入容器docker attachdocker exec 導出和導入導出導入 容器的…

淺談5G基站節能及數字化管理解決方案的設計與應用-安科瑞 蔣靜

截至2023年10月&#xff0c;我國5G基站總數達321.5萬個&#xff0c;占全國通信基站總數的28.1%。然而&#xff0c;隨著5G基站數量的快速增長&#xff0c;基站的能耗問題也逐漸日益凸顯&#xff0c;基站的用電給運營商帶來了巨大的電費開支壓力&#xff0c;降低5G基站的能耗成為…

actitivi自定義屬性(二)

聲明&#xff1a;此處activiti版本為6.0 此文章介紹后端自定義屬性解析&#xff0c;前端添加自定義屬性方法連接&#xff1a;activiti自定義屬性&#xff08;一&#xff09;_ruoyi activiti自定義標題-CSDN博客 1、涉及到的類如下&#xff1a; 簡介&#xff1a;DefaultXmlPar…

在 JavaScript 中導入和導出 Excel XLSX 文件:SpreadJS

在 JavaScript 中導入和導出 Excel XLSX 文件 2023 年 12 月 5 日 使用 MESCIUS 的 SpreadJS 將完整的 JavaScript 電子表格添加到您的企業應用程序中。 SpreadJS 是一個完整的企業 JavaScript 電子表格解決方案&#xff0c;用于創建財務報告和儀表板、預算和預測模型、科學、工…

【華為OD】給定一個只包括 ‘(‘,‘)‘,‘{‘,‘}‘,‘[‘,‘]‘ 的字符串

給定一個只包括 (,),{,},[,] 的字符串 s , 判斷字符串是否有效。 有效字符串需滿足: 左括號必須用相同類型的右括號閉合。 左括號必須以正確的順序閉合。 示例 1 : 輸入:s="()" 輸出 : true 示例 2 :

圖的搜索(一):廣度優先搜索算法和深度優先搜索算法

圖的搜索&#xff08;一&#xff09;&#xff1a;廣度優先搜索算法和深度優先搜索算法 本章主要記錄了圖的搜索算法&#xff0c;和可以解決圖的基本問題——最短路徑問題的算法。本章主要對圖搜索的相關算法進行了介紹&#xff1a;廣度優先搜索算法、深度優先搜索算法。 下一…

公網域名如何解析到內網IP服務器——快解析域名映射外網訪問

在本地搭建主機應用后&#xff0c;由于沒有公網IP或沒有公網路由權限&#xff0c;在需要發布互聯網時&#xff0c;就需要用到外網訪問內網的一些方案。由于內網IP在外網不能直接訪問&#xff0c;通常就用通過外網域名來訪問內網的方法。那么&#xff0c;公網域名如何解析到內網…

Tmux中使用Docker報錯 - 解決方案

問題 進入Tmux會話后&#xff0c;在其中使用Docker可能會出現如下報錯&#xff1a; Got permission denied while trying to connect to the Docker ……解決方案 退出tmux會話: tmux detach在tmux會話外部殺掉tmux進程&#xff1a; pkill -f tmux重新進入tmux&#xff1a…

權威認證!景聯文科技入選杭州市2023年第二批省級“專精特新”中小企業認定名單

為深入貫徹黨中央國務院和省委省政府培育專精特新的決策部署&#xff0c;10月7日&#xff0c;杭州市經濟和信息化委員會公示了2023年杭州“專精特新”企業名單&#xff08;第二批&#xff09;。 根據工業和信息化部《優質中小企業梯度培育管理暫行辦法》&#xff08;工信部企業…

【Vue3+Ts項目】硅谷甄選 — 路由配置+登錄模塊+layout組件+路由鑒權

一、路由配置 項目一共需要4個一級路由&#xff1a;登錄&#xff08;login&#xff09;、主頁&#xff08;home&#xff09;、404、任意路由&#xff08;重定向到404&#xff09;。 1.1 安裝路由插件 pnpm install vue-router 1.2 創建路由組件 在src目錄下新建views文件…

Graphpad Prism10.1.0 安裝教程 (含Win/Mac版)

GraphPad Prism GraphPad Prism是一款非常專業強大的科研醫學生物數據處理繪圖軟件&#xff0c;它可以將科學圖形、綜合曲線擬合&#xff08;非線性回歸&#xff09;、可理解的統計數據、數據組織結合在一起&#xff0c;除了最基本的數據統計分析外&#xff0c;還能自動生成統…

Python:核心知識點整理大全8-筆記

目錄 ?編輯 4.5 元組 4.5.1 定義元組 dimensions.py 4.5.2 遍歷元組中的所有值 4.5.3 修改元組變量 4.6 設置代碼格式 4.6.1 格式設置指南 4.6.2 縮進 4.6.3 行長 4.6.4 空行 4.6.5 其他格式設置指南 4.7 小結 第5章 if語句 5.1 一個簡單示例 cars.py 5.2 條…