Title of Competition
stringclasses
168 values
Title of Writeup
stringlengths
9
139
User
stringclasses
1 value
Writeup
stringlengths
419
61.5k
SIIM-ISIC Melanoma Classification
27th overview - I Survived the massive shakedown and be in the top 1%
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: SIIM-ISIC Melanoma Classification <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Since I had been so much afraid of shakedown, I tried to make an <strong>extremely low variance ensemble and it turned out to be a not so bad approach.</strong></p> <p><strong>With efficient net B0 ~ B7 imagenet + B0 ~ B7 noisy-student</strong><br> <strong>Size 256 , 384, 512, 768, 1024, it amounts to total 95 MODEL!</strong></p> <p>I ensembled all!</p> <p>For making networks from B0-B7, 256~1024, I used Chris's stratified notebook and I left the network original that Chris had made<br> (Efficient net -&gt; GAP -&gt; dense(1, smoothing = 0.05))<br> All the same network (From B0-B7, SIZE 256 to 1024)<br> All 2019 ext data and coarse dropout was applied</p> <p>as I had noticed so many strong competitors reported that their CV was around 0.95,<br> I guessed that if I could make my cv converge to around 0.95, and if my cv score &gt; 0.95 then I thought that I supposedly could be good at this competition</p> <p><strong>This is how I ensembled 95 deep learning models</strong></p> <p><strong>NET BASED ENSEMBLE(EFFICIENT NET 0 ~ EFFICIENT NET 7)</strong><br> MODEL 0 : EffcientNet B0 from 256 to 1024, noisy + imagenet CV 0.941 PB 0.9441 PV 0.9350<br> MODEL 1 : EffcientNet B1 from 256 to 1024, noisy + imagenet CV 0.943 PB 0.9491 PV 0.9355<br> MODEL 2 : EffcientNet B2 from 256 to 1024, noisy + imagenet CV 0.946 PB 0.9516 PV 0.9406<br> MODEL 3 : EffcientNet B3 from 256 to 1024, noisy + imagenet CV 0.950 PB 0.9515 PV 0.9411<br> MODEL 4 : EffcientNet B4 from 256 to 1024, noisy + imagenet CV 0.953 PB 0.9543 PV 0.9422<br> MODEL 5 : EffcientNet B5 from 256 to 1024, noisy + imagenet CV 0.953 PB 0.9540 PV 0.9451<br> MODEL 6 : EffcientNet B6 from 256 to 1024, noisy + imagenet CV 0.953 PB 0.9536 PV 0.9472<br> MODEL 7 : EffcientNet B7 from 256 to 1024, noisy + imagenet CV 0.951 PB 0.9549 PV 0.9434<br> <strong>-&gt; It was CV 0.9551, PUBLIC LB : 9555 PRIVATE LB 0.9461</strong></p> <p><strong>SIZE BASED ENSEMBLE(256 to 1024)</strong><br> MODEL 8 : ALL 256 SIZE, EffcientNet 0 ~ 7 CV : 0.939<br> MODEL 9 : ALL 384 SIZE, EffcientNet 0 ~ 7 CV : 0.953<br> MODEL 10 : ALL 512 SIZE, EffcientNet 0 ~ 7 CV : 0.954<br> MODEL 11 : ALL 768 SIZE, EffcientNet 0 ~ 7 CV : 0.949<br> MODEL 12 : ALL 1024 SIZE, EffcientNet 0 ~ 7 CV : 0.938</p> <p>and I adopted Power ensemble (square 2) that's because AUC is summarized to draw a line between malignant ones and benign ones.<br> If my model is robust, then the resultant power ensemble can be not much different from original ones as AUC is intrinsically just orders</p> <p><strong>SIZE BASED ENSEMBLE (with square 2, prediction^2)</strong><br> MODEL 13 : ALL 256 SIZE, EffcientNet 0 ~ 7 CV : 0.938<br> MODEL 14 : ALL 384 SIZE, EffcientNet 0 ~ 7 CV : 0.947<br> MODEL 15 : ALL 512 SIZE, EffcientNet 0 ~ 7 CV : 0.952<br> MODEL 16 : ALL 768 SIZE, EffcientNet 0 ~ 7 CV : 0.952<br> MODEL 17 : ALL 1024 SIZE, EffcientNet 0 ~ 7 CV : 0.947</p> <p><strong>FINAL MODEL = NET BASED MODEL + SIZE BASED MODEL + Square 2 SIZE BASED MODEL</strong></p> <p>FINAL MODEL :<strong>TOTAL SIMPLE AVERAGE (MODEL 0 TO 17) CV -&gt; 0.9538</strong><br> To find appropriate weights, I adopted a differential evolution strategy</p> <h1><img src="https://i.imgur.com/xRrTIGE.png" alt="https://i.imgur.com/xRrTIGE.png"></h1> <p>FINAL MODEL : OPTIMIZE WEIGHTS WITH SCIPY DIFFERENTIAL_EVOLUTION MODULE -&gt; <strong>CV 0.9562</strong></p> <p>0.8 * FINAL_MODEL + 0.2 * Tabular Meta(FROM XGBOOST) -&gt; <strong>current LB 0.9446</strong><br> (If I didn't add meta info to the final model, I could have nearly reached the gold medal)<br> but at Public LB, adding meta info helped improve PUBLIC LB SCORE as much as 0.002, so I guessed that tabular data regularizes overfitting to CV(Cv dropped when added meta), that's why I couldn't abandon it</p> <p>By implementing things above described, I found out that my cv is proportional to LB</p> <p><strong>When I ensembled all, the resultant CV was around 95.62 and public LB was 95.80 and Private LB is now 94.46</strong></p> <p>I am a Kaggle novice and I am satisfied with the current result!</p> <p><strong>Some of you might be curious about scipy.optimize.differential_evolution model</strong></p> <p>This is not a special thing.</p> <p><a href="https://machinelearningmastery.com/weighted-average-ensemble-for-deep-learning-neural-networks/?fbclid=IwAR3GYgj0Fu4Mp3RhTeyacb99H2QyP5uuWJizR7ei6DOOC-NbERKQIGyBB4o" target="_blank">https://machinelearningmastery.com/weighted-average-ensemble-for-deep-learning-neural-networks/?fbclid=IwAR3GYgj0Fu4Mp3RhTeyacb99H2QyP5uuWJizR7ei6DOOC-NbERKQIGyBB4o</a></p> <p>I found the method here</p> <p>Actually, To optimize AUC ensemble, I tested the Bayesian method, the Powell optimization method(CV 9614, Public LB:9493 it turned out to be not good), and a lot of things. but CV from evolution differential method was so much proportional to Public LB since I guess it produced the optimized sum of weights = 1 and it is scaled to well for probability while bayesian and powell was not scaled to probability</p> <p><strong>What worked:</strong><br> trained model solely with 2019 data<br> Coarse dropout<br> Label smoothing<br> malignant upsampling<br> noisy student</p> <p><strong>What didn't work:</strong><br> Focal loss<br> Dual input with META + CNN(but it dramatically boosted CV)<br> Custom head<br> Meta tabular info(but it improved Public LB)<br> KNN feature bridging from train to test, from test to train</p>
SIIM-ISIC Melanoma Classification
85th description - random label smoothing
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: SIIM-ISIC Melanoma Classification <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>My approach was to build an ensemble of EfficientNets, I settled on this because it won last year and it did not seem that there were any new approaches performing better. I ran a lot of experiments using <a href="https://www.kaggle.com/cdeottes" target="_blank">@cdeottes</a> notebook with image size 128 and EfficientNet-B6 to find hyperparameters that increased my CV, then I made the assumption that these parameters would also work for larger image sizes and different EfficientNets. </p> <p>I included the meta data into the classifier by concatenating it with the output of an MLP on the EfficientNet output. I also experimented with different amounts of label smoothing and class weights, finding that a class weight of 5 and label smoothing of 0.05 worked best. I also experimented with assigning random label smoothing to the data as described at the end of this discussion. My final ensemble also included models trained on meta data only and on image embeddings combined with meta data, the ensembling was done using and explicit grid search on the out of fold scores for all models.</p> <p>For ensembling my models the best method I found was to find groups of predictions that were highly correlated (typically different EfficientNets trained on the same image size were highly correlated) and take a non-linear average that increased the out of fold cross validation score for each group. I then performed a grid search for the best weights to ensemble these averaged predictions. I found this approach to be superior to performing an explicit grid search without first averaging.</p> <p>To give an explicit example of this ensembling. Take all of the models trained on image size NxN, take the geometric mean (and/or median) and check that this has a better cross validation score than the best single model. Repeat this process for all image sizes that have models trained on them, taking either the geometric mean or the best single model in each case. Blend the averaged predictions for all image sizes. This can be applied to any type of grouping where correlations between predictions are found.</p> <p>The rationale behind this is that highly correlated models can still be included in the final ensemble, instead of ignoring models that took a long time to train.</p> <p>The only part of my final submission that is significantly different from what I have seen posted elsewhere is that I trained some models where the amount of label smoothing for each example was drawn randomly from a distribution. So each time the model saw an example, the label was different. As far as I am aware this is the first time this method has been employed.</p> <p>I trained multiple models with this strategy, experimenting with different distributions (for sampling the label smoothing), and then I ensembled all of these experiments (geometric mean and median both increased CV). This ensemble had a weight of 0.25 in my final submission.</p> <p>This approach produced the lowest difference between CV, private LB and public LB for a single model that I have trained. The scores for a single model trained in this way, with labels drawn from a gaussian with mean 0.05 and std 0.025, are:</p> <p>CV (2020 data only) 0.927<br> private LB 0.9319<br> public LB 0.9389.</p> <p>Which can be compared with the original <a href="https://www.kaggle.com/cdeotte/triple-stratified-kfold-with-tfrecords" target="_blank">notebook</a> scores of:</p> <p>CV (2020 data only) 0.904<br> private LB 0.9262<br> public LB 0.9454.</p> <p>To be completely clear on what this entails I used the following loss:</p> <pre><code>class sls_loss(tf.keras.losses.Loss): def call(self, y_true, y_pred): ls = tf.abs(tf.random.normal([1], 0, 0.025, tf.float32)) y_true = y_true * (1.0 - ls) + 0.5 * ls bce = tf.keras.losses.BinaryCrossentropy(label_smoothing=0, reduction=tf.keras.losses.Reduction.NONE) per_example_loss = bce(y_true,y_pred) return tf.nn.compute_average_loss(per_example_loss, global_batch_size=GLOBAL_BATCH_SIZE) </code></pre> <p>Note this is slightly different to what I described as it is per batch.</p>
TReNDS Neuroimaging
5th place solution, 3D fMRI part
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: TReNDS Neuroimaging <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Fisrst of all, many thanks to Kaggle and the hosts for hosting such an interesting competition, and congratulations to all the winners. And a special thanks to all my teammates for teaming up with me!! I arrived at this solution with a lot of advice from my teammates @masatomatsui @kurupical @takoihiraokazu .</p> <p>(Let me apologize for my poor English. )</p> <h1>Summary of models.</h1> <p><img src="https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1057275%2Fa3c45d38674d125c37bdb111ec64bf51%2F3D_fMRI_summary%20(1" alt="">.png?generation=1593476631685161&amp;alt=media)</p> <p>ResNet, SEResNet based on: <a href="https://github.com/kenshohara/3D-ResNets-PyTorch/tree/540a0ea1abaee379fa3651d4d5afbd2d667a1f49">https://github.com/kenshohara/3D-ResNets-PyTorch/tree/540a0ea1abaee379fa3651d4d5afbd2d667a1f49</a> DenseNet: <a href="https://github.com/Project-MONAI/MONAI">https://github.com/Project-MONAI/MONAI</a> Other tips: <a href="https://www.kaggle.com/c/trends-assessment-prediction/discussion/147797">https://www.kaggle.com/c/trends-assessment-prediction/discussion/147797</a> (Thanks, @shentao !!)</p> <h1>About Scores</h1> <p>All of 3D models are not so good about CV/LB score. Most of the models are around 0.171 ~ 0.175 CV scores, even the best model can only gets CV 0.17074 (SEResNet18 with resize, float 32). However, ensembling these models greatly improved the scores. In fact, weighted average of single 3D CNN model(ResNet18, float 32, no normalization) (LB 0.1675) and kernel prediction of <a href="https://www.kaggle.com/tunguz/rapids-ensemble-for-trends-neuroimaging">“RAPIDS Ensemble for TReNDS Neuroimaging”</a> (LB 0.1595) at 0.2 : 0.8 gots LB 0.1582. In the end, stacking our various models greatly improved the LB score. </p> <h1>About 3D Data</h1> <p>In the early part of the competition, I saved 3D data in float 16 format (light blue model). This is because it made the learning process so much faster and allowed me to train a lot of models. Training one model (5 folds, 10 epochs each) took about 5 ~ 10 hours to complete. In case of float 32, it took 2 ~ 3 times longer. However, it would be more accurate to train in float 32 format, so important red parts were trained with float 32 format.</p> <h1>About Resize</h1> <p>To create a variety of model prediction, I resized 3D data from (50, 63, 53) to (75, 94, 79). This contributed to improved CV scores and ensembles.</p> <h1>About Site Normalization</h1> <p>There were two types of data in the test dataset: site 2 and not revealed(site 1 or site 2). Teammates figured out that, by moving the distribution of site 2 closer to that of site 1 (this is “shift” in the figure), models using loading and fnc gots better LB scores (for example, best kernel 0.1590 -&gt; 0.1586). To achieve something similar in the 3D CNN models, I normalized 3D data by mean, std of each site. Site 1 data by mean, std of site 1, site 2 by those of site 2. One of my teammates made a model to predict whether the data is site 1 or 2 (Accuracy over 0.94), and I used his predictions to normalize the not reveal data in the same way. This “Site Normalization” did not boost CV, but improved LB scores.</p> <blockquote> <p>DenseNet, float 16, no resize No normalization: CV 0.1722 -&gt; LB 0.1684 Site normalization: CV 0.1742 -&gt; LB 0.1680</p> </blockquote>
M5 Forecasting - Uncertainty
1st student - 12th overall solution
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: M5 Forecasting - Uncertainty <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>After missing the gold medal zone by picking the wrong submission in the 2019 Data Science Bowl, here I missed it again by just one place, what a pity. Anyway, if this will be my 2nd first student prize after the DSB, I'm more than happy.</p> <p><strong>Here a short wrap up of my solution:</strong></p> <p>I focussed on the Accuracy part of the competition (where my final private LB rank isn't that good though (274/5558)) and decided to go for day-to-day LGBM models. The notebook to create my uncertainty forecasts for horizon h=8 can be found here: <a href="https://www.kaggle.com/tobiit/m5-uncertainty-lgbm-f8-eval/">https://www.kaggle.com/tobiit/m5-uncertainty-lgbm-f8-eval/</a> The notebooks for other forecast horizons look similar.</p> <p><strong>The following steps are carried out for each horizon:</strong></p> <p><strong>1. Preprocessing:</strong> - Process calendar dataframe to get some more features - Process selling prices dataframe: first, I built selling prices for aggregate time series by just taking the mean of the aggregated time series (e.g. for the Total aggregation, I put as sell_price the mean of all sell prices); second, I built some more features as sell_prices_std and so on - Process sales dataframe: first, I built the aggregate time series for all levels. For the state_id columns etc. I used the following strategy: If all aggregated time series had the same value, I used it, otherwise I put nan (e.g. for the CA_1 aggregate, all aggregated time series have state_id CA, so I left it; for the FOODS aggregate on the other hand, the aggregated time series have different state_ids, so I put state_id nan). Next, I removed some outliers (Christmas, Thanksgiving and something else), normalized each of the time series (details see below), and computed further features as rolling means, target encodings of calendar features etc. </p> <p><strong>2. Modelling:</strong> For each quantile q, I trained a LGBM model with objective 'quantile' and 'alpha'=q on all time series. The last 28 days were left out as validation set for early stopping. The WSPL weights were used during training passing them to the LGBM dataset as train = lgb.Dataset(train[features],train[['demand']],weight=train['weight'])</p> <p><strong>Normalization of sales time series</strong> Based on some CV tests in my work on the accuracy part, I came up with the following normalization for all sales time series (aggregated ones and normal ones): First, I divided each time series by their nonzero mean. Second, to remove the trend, I considered some form of differences and set a_trendRemoved[t]=a[t]+maxRollMean(28)-laggedRollMean(28,h) for each mean normalized time series a[t]. Here maxRollMean(28) is the maximum rolling mean over a 28 days period that the time series had anywhere during the 1941 provided days. The laggedRollMean(28,h) is the mean of a[t-28-h+1],...,a[t-h]. So how did I come to this? Actually I wanted to use something like a_trendRemoved[t]=a[t]-rollMean(28) meaning how the sales at time t differ from the mean of the last 28 days. However, undoing this preprocessing after the predictions requires to use the predictions for the days F1,...,F(h-1) to build the rollMean(28) and I wanted the forecasts for each time horizon to be independent from all other forecasts to prevent error propagation. Therefore, I decided to replace the rollMean(28) by the laggedRollMean(28,h). Adding further the maxRollMean(28) term ensures that all values stay positive. I thought that this shouldn't matter, but in my CV experiments, it gave better results, so I used it. </p> <p><strong>Sidenotes:</strong> - As I used only kaggle kernels and no other ressources, it was quite a struggle to fit everything into RAM and into the 9 hours wallclock limit. Therefore, I used only days after dstart=1100 for training and only considered the forecast weekday and one similar weekday for training (e.g. F8 is a Monday, so for the horizon h=8 models, I used only Mondays and Fridays for training and discarded all other days). - Tuning LGBM parameters didn't work out for me at all, I simply used the parameters that I found in some public kernel in the Accuracy part (except from objective=quantile and alpha=q of course). - I tried feature selection for the accuracy part. Leaving always one feature out, retraining my model and checking whether my CV score improved. As I didn't observe any stable improvements, I simply used all features here. - I refer to some CV tests above which worked like this: I considered only the accuracy part and picked 2 horizons, namely 8 and 22 days for which I used the last 3 28 days periods for cross validation. All parameter, feature and normalization decisions that I made where based on the results obtained there. However, I'm not sure, if this was such a good idea, as the CV obtained in those experiments indicated way higher scores than I obtained in the end on the accuracy private LB. Therefore, I think that I might have overfitted to the 2 specific horizons. Setting up a CV using all 28 horizons with day-to-day models (-&gt; always training 28 models * 3 validation sets) doesn't seem feasible either though, so I don't know how I could have done better. - I said I use the WSPL weights for my LGBM model. Actually, I do not use the original weights, but normalize them s.t. they all weights have mean 1. Then I clip them s.t. all weights lie between 0.2 and 30. The first step ensures that everything still works fine with normal learning rates. The clipping was done to make it a bit more stable ensuring that there aren't time series with weights in the order of 100 and others with weights in the order of 0.001.</p> <p>Happy Kaggling Tobias</p> <p>Edit: Unfortunately, <a href="/david1352413524">@david1352413524</a> in front of me appended now as well _stu to his team name s.t. I guess this here is only the 2nd student place :( congrats to him though. Would you mind sharing your solution as well <a href="/david1352413524">@david1352413524</a> ?</p>
TReNDS Neuroimaging
Second silver in one week
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: TReNDS Neuroimaging <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Due to the metal distribution delay in Jigsaw, my 2 silvers come in 1 week.</p> <p>Many thanks to everyone and congrats to the winners ! Can't wait to see your solutions 😁 </p>
Cornell Birdcall Identification
5th place solution
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Cornell Birdcall Identification <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>A great journey, thanks for organizing it! Now every time I walk around I hear much more birds :) <br> I've started my machine learning journey with speech processing few years ago and that was a joy to play again with it. One more time to thank and mention <a href="https://www.kaggle.com/hidehisaarai1213" target="_blank">@hidehisaarai1213</a> who led us through the darkness here.</p> <p>From the very scratch I understood that the problem can be decomposed into two main problems:</p> <ul> <li>a domain shift (which is pretty tough us we don't have target test set)</li> <li>a clipwise to framewise classification transit (which also introduced us additional "nocall" class with huge influence on results, and labels noise)</li> </ul> <p>Tackling those two needed a validation/test set as close to target distribution as possible in terms of snr and nocall distributions. </p> <p><strong>Validation</strong></p> <p>Believe me or not but with 6 records from <a href="https://www.kaggle.com/c/birdsong-recognition/discussion/158877#911336" target="_blank">here</a> and 2 example audios I was able to get some correlation with LB even though it contained only 500-800 clips. But more important I was able to control % of "nocall"s and pick the right threshold based on them. Last two days I splitted those clips into 3 test sets with 50%, 60%, 80% "nocalls" to see possible scenarios on private leaderboard (thanks organizers private is almost equal to public) and to secure the score with my second submission. </p> <p>As a target metric I've used F1 by <code>average="samples"</code> pointed by <a href="https://www.kaggle.com/cpmp" target="_blank">@cpmp</a>. By the end I've also monitored validation (default CV split) primary+secondary F1 score as my another decision-making metric. Primary F1 or mAP was not enough.</p> <p><img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F805012%2Fa290c42c9808e69c800abb79f2889f22%2FScreenshot%20from%202020-09-16%2009-53-50.png?generation=1600239312223536&amp;alt=media" alt=""></p> <p>Adding separate nocall class didn't work for me for whatever reason.<br> And yeah, I trusted leaderboard too.</p> <p><strong>Domain shift</strong><br> Assuming we don't have the transit problem, this might be solved simply with augmentations. I've spent too much time on this and right now I understand that was not productive. My final models contain different augmentations configurations: </p> <ul> <li>backgrounds (all from external data thread)</li> <li>pink and brown noise</li> <li>pitch shift</li> <li>low pass filtering</li> <li>spec augments (time and frequency masking)</li> </ul> <p>As organizers informed that we can train on two test examples, I tried to collect batch norm statistics from those as a domain adaptation technique but it didn't work great. </p> <p><strong>Clipwise &gt; framewise transit p.1</strong></p> <p>That's my favorite part!<br> So what we have here - every time we crop 5 seconds clip we have a chance to crop a nocall clip. So labels become really noisy. Even more it's hard to crop secondary classes. Easy way to tackle this? Label smoothing 0.2. I don't remember when I became a fan of label smoothing but it works well with noisy labels on practice. But that's not serious.</p> <p>People here tackled this task having an energy based cuts. And it really worked. So I've tried both approaches: soft and hard. By soft I mean random sampling based on energy, by hard - removing everything below normalized energy threshold.</p> <p>But what if we can use our model to extract these labels? Having avg/map pooling head gives a chance to get a free segmentation:<br> <img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F805012%2Fb9938f7758cd413a47006ac98c5f62e0%2Fphoto5377374165436313567.jpg?generation=1600241278088906&amp;alt=media" alt=""><br> which you can use as soft labels or hard binarized labels. These methods showed really cool performance for primary labels. For secondary I kept label smoothing :)</p> <p><strong>Clipwise &gt; framewise transit p.2 (The most important part)</strong></p> <p>I found SED models comparably weak trained on 5 sec clips but as I trained them on longer clips (10-30 seconds) I noticed that due to labels noise reduction they show much better training loss/mAP. Moreover, it was possible to run inference on 5 sec clips with nice performance. So I took B4 EffNet, added the same Attention decision making head and … failed!</p> <p>I've spent a lot on this one. So why did Cnn14_DecisionLevelAtt trained on 30 sec clips work well on 5 sec clips? Playing with EffNet I found that problem was in receptive field - it's too big (630 compared to 200 or so). With wide receptive field attention head was not able to build a meaningful framewise feature maps. As I've changed EffNet kernels from 5x5 to 3x3 or reduced number of blocks - it solved problem but price was too big - pretrained weights. </p> <p>So what we have: </p> <ul> <li>longer input</li> <li>clipping based on some weakly labeled probabilities</li> <li>label smoothing for secondary</li> </ul> <p>Having these I've decided to simply run 5sec classification inference with no sophisticated postprocessing that might fail on private LB. As it always happens, I've found this too late so trained only two PANNs models (resnet38 and cnn14 mentioned above) on 12 and 15 second clips (128 mels) with mixup and didn't have time to configure them properly.</p> <p><strong>Finally</strong></p> <p>I've optimized inference to run all my models (cnn14, resnet38 and few effnets) in 20 mins with <code>kaiser_fast</code> resampling and around one hour with <code>kaiser_best</code>. I've picked thresholds based on my test set (0.3) and some skepticism about it (0.4). I found I have 670+ private score submissions from two weeks ago, which I can't explain. Probably, Kaggle leaderboard is another stochastic process.</p> <p>This has been a long journey in which I not only solved many competitions and learned just hundreds of tools and tricks, but also met wonderful minds from all over the world and found job of my dreams. I wish to meet you in person at Kaggle Days once covid is over. See you!</p>
Cornell Birdcall Identification
18th place solution: efficientnet b3
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Cornell Birdcall Identification <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>First of all I want to thank the host and Kaggle for this very challenging competition, with a truly hidden test set. A bit too hidden maybe, but thanks to the community latecomers like us could get a submission template up and running in a couple of days. I also want to thank my team mate Kazuki, without whom I would probably have given up after many failed attempts to beat the public notebook baseline…</p> <p><strong>Overview</strong></p> <p>Our best subs are single efficientnet models trained on log mel spectrograms. For our baseline I started from scratch rather than reusing the excellent baselines that were available. Reason is that I enter Kaggle competition to learn, and I learn more when I try from scratch than when I modify someone else' code. We then evolved that baseline as we could in the two weeks we had before the end of competition.</p> <p>Given the overall approach is well known and probably used by most participants here I will only discuss the items that may be a bit different from what others did.</p> <p><strong>Training data clips</strong></p> <p>It was clear from host that training on random 5 second clips had a drawback: some of the clips may not contain the target bird. We then used a simple hypothesis: clips were stripped, i.e. periods without a song at the beginning or at the end were removed for the sake of reducing storage needs. We therefore trained on first 5 seconds or last 5 seconds of clips, assuming these would contain the target bird. We preprocessed all data to be sampled at 32 kHz.</p> <p><strong>Noise</strong><br> We added noise extracted from the two test sequences made available, a bit like what Theo Viel did. But we used the meta data to extract sub sequences without bird call, then we merged these sequence with a smooth transition between them. We then added a random clip of the merges sequences to our training clips</p> <p><strong>No Call</strong><br> We added the freefield1010 clips that were labelled as nocall to our training data. We added a 265th class to represent the no call. As a result our model could predict both one or more birds, and a nocall. Adding this data and the nocall class was probably the most important single improvement we saw in CvV and LB scores. It is what led us to pass the public notebook baseline.</p> <p><strong>Multi Bird Clips</strong><br> The main documented difference between train and test data is that train is a multi class data while test is a multi label data. Therefore we implemented a mixup variant were up to 3 clips could be merged. This is not really mixup as the target for the merged clip is the maximum of the targets of each merged clip.</p> <p><strong>Secondary labels</strong><br> Primary labels were noisy, but secondary labels were even noisier. As a result we masked the loss for secondary labels as we didn't want to force the model to learn a presence or an absence when we don't know. We therefore defined a secondary mask that nullifies the BCE loss for secondary labels. For instance, assuming only 3 ebird_code b0, b1, and b2, and a clip with primary label b0 and secondary label b1, then these two target values are possible:</p> <p>[1, 0, 0]</p> <p>[1, 1, 0]</p> <p>The secondary mask is therefore:</p> <p>[1, 0, 1]</p> <p>For merged clips, a target is masked if it it not one of the primary labels and if it is one of the secondary labels.</p> <p><strong>Loss Function</strong></p> <p>We use binary cross entropy on one hot encoding of ebird codes. Using bce rather than softmax makes sense as bce extends to multi label seamlessly. We tried dice loss to directly optimize F! score, but for some reason this led to very strong overfitting.</p> <p><strong>Class Weights</strong></p> <p>The number of record per species is not always 100. In order to not penalize the less frequent one we use class weights inversely proportional to class frequencies. And for the nocall class we set it to 1 even though it was way more frequent than each bird classes to make sure the model learns about nocall correctly.</p> <p><strong>Model</strong></p> <p>Our best model was efficientnet on log mel spectrograms. We resized images to be twice the size of effnet images: 240x480 for effnet b1, 260x520 for effnet b2, and 300x600 for effnet b3. We started from efficientnet_pytorch pretrained models. We tried the attention head from PANNs models but it led to severe overfitting. I am not sure why to be honest, maybe we did something wrong.</p> <p><strong>Training</strong><br> Nothings fancy, adam optimizer and cosine scheduler with 60 epochs. In general last epoch was the one with best score and we used last epoch weights for scoring.</p> <p><strong>Log Mel Spectrogram</strong></p> <p>Nothing fancy, except that we saw a lot of power in low frequencies of the first spectrograms we created. As a result we clipped frequency to be at least 300 Hz. We also clipped them to be below 16 kHz given test data was sampled at twice that frequency. </p> <p><strong>Augmentations</strong></p> <p>Time and pitch variations were implements in a very simple way: modify the length of the clipped sequence, and modify the sampling rate, without modifying the data itself. For instance, we would read 5.2 seconds of a clip instead of 5 seconds, and we could tell librosa that the sampling rate was 0.9*32 kHz. We then compute the hop so that the number of stft is equal to the image width for the effnet model we are training. We also computed the number of mel bins to be equal to the height of the image. As a result we never had to resample data nor resize images, which speed up training and inferencing quite a bit. There was an issue with that still: this led us to use a high nftt value of 2048 which lead to poor time resolution. We ended up with nfft of 1048 and a resize of the images in the height dimension.</p> <p><strong>Cross Validation</strong></p> <p>We started with cross validating on our training data (first or last 5 seconds of clips) but it was rapidly clear that it was not representative of the LB score. And given we had very few submissions, we could not perform LB probing. We therefore spent some time during last week to create a CV score that was correlated with the public LB. Our CV score is computed using multi bird clips for 46% of the score, and nocall clips for 54% of the score. We added warblrb and birdvox nocall clips to the freefield1010 for valuating no call performance. We tuned the proportion of each possible number of clips in multi bird clips, and the amount of noise until we could find a relatively good CV LB relationship, see the picture below: x is cv, y is public lb.</p> <p><img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F75976%2F39f916bec9be955cfa2a8fd5e8384b3b%2Fcv_lb.png?generation=1600261413279842&amp;alt=media" alt=""></p> <p>The correlation with private LB is also quite good:</p> <p><img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F75976%2F02c89402f0dfd6e9069f36e67fc32e85%2Fcv_private.png?generation=1600261852596913&amp;alt=media" alt=""></p> <p>We then used it to guide our last few submissions training and thresholding. Our CV said 0.7 was best, and late submissions proved it was right. We ended up selecting our 2 best CV submissions, which were also the 2 best public LB submissions, and also the two best private Lb submissions.</p> <p><strong>Conclusion</strong></p> <p>These were probably the most intensive two weeks I had on Kaggle since a long time. My first two subs 14 days ago were a failure, then a LB score of 0. Kazuki had started a bit earlier, but not much. I am very happy about where we landed, and I am not sure we would have done much better with few more days. Maybe using effnet b4 or b5 wold have moved us higher but I am not sure. I am looking for gold medalist solutions to see what we missed. I'm sure I'll learn quite a bit.</p>
Cornell Birdcall Identification
4-th place solution
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Cornell Birdcall Identification <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Hi ,Kagglers!</p> <p>It was an amazing competition! And I am happy to share training tips that helped us reach 4-th LB position</p> <h1>Data Preparation</h1> <p>We used resampled into 32 000 sample rate and normalized audio</p> <p>As most competitors, we used spectral features - Logmels</p> <p>For most of my models we have added external xeno-canto datasets:<br> <a href="https://www.kaggle.com/rohanrao/xeno-canto-bird-recordings-extended-a-m" target="_blank">https://www.kaggle.com/rohanrao/xeno-canto-bird-recordings-extended-a-m</a> <br> <a href="https://www.kaggle.com/rohanrao/xeno-canto-bird-recordings-extended-n-z" target="_blank">https://www.kaggle.com/rohanrao/xeno-canto-bird-recordings-extended-n-z</a><br> Great thanks to <a href="https://www.kaggle.com/rohanrao" target="_blank">@rohanrao</a> </p> <p>Also we used RMS trimming, in order to get clips with bird calls. More details you can find in <a href="https://www.kaggle.com/vladimirsydor/4-th-place-solution-inference-and-training-tips?scriptVersionId=42796948" target="_blank">our notebook</a></p> <h1>Feature Extraction</h1> <p>As we were using pretrained CNNs, we have to support it with 3-channel input (or inplace first Conv)</p> <p>Worked:</p> <ul> <li>Repeat of Logmel 3 times - good baseline option</li> <li>Use <a href="https://pytorch.org/audio/functional.html#compute-deltas" target="_blank">deltas</a> - We have used concatenation of Logmel, 1-st order delta and 2-nd order delta. It worked the best</li> <li>Adding <code>secondary_labels</code> for training</li> </ul> <p>Not Worked great:</p> <ul> <li>Time and Frequency encoding - originally used by <a href="https://www.kaggle.com/ddanevskyi" target="_blank">@ddanevskyi</a> in <a href="https://www.kaggle.com/c/freesound-audio-tagging-2019/discussion/97926" target="_blank">Freesound</a>. But it does not work well here</li> <li>Adding some more features, like Loudness and Spectral Centroid</li> </ul> <h1>Validation Scheme</h1> <p>All our models were trained in cross-validation mode. So we had one fold for validation. Also we used <code>example_audio</code> as one more validation set. All in all we tracked such metrics:</p> <ul> <li>loss</li> <li>MaP score by one validation fold - <code>map_score</code></li> <li>Original competition F1 metric with threshold 0.5 on test set - <code>f1_test_median</code></li> <li>Original competition F1 metric with best threshold on test set</li> <li>Original competition F1 metric with threshold 0.5 on validation fold (if we use <code>secondary_labels</code>)</li> <li>Original competition F1 metric with threshold best threshold on validation fold (if we use <code>secondary_labels</code>)</li> </ul> <p>We made early stopping and scheduling by MaP score, as it has converged the last one from all metrics</p> <p>Then we took 3 best checkpoints by <code>f1_test_median</code> and averaged weights matrices for each fold - some kind of SWA. Then blend 5 models (5 folds) and evaluate on test_set (example audio). This score correlates well with LB till 0.607 point. After this point test_set was nearly useless :)</p> <h1>Model</h1> <p>We used different EfficientNets (B3, B4, B5) pretrained on <a href="https://github.com/rwightman/gen-efficientnet-pytorch" target="_blank">noisy student</a>.</p> <p>We tried some classifier heads. But 2 Layer Dropout-&gt;Liner-&gt;Relu works the best. Also <br> <a href="https://arxiv.org/pdf/1905.09788.pdf" target="_blank">Multi-Sample Dropout</a> slightly boosts the performance and give some more stability</p> <p>We tried SeResnexts but they did not work at all for us. Also we tried model proposed by <a href="https://www.kaggle.com/ddanevskyi" target="_blank">@ddanevskyi</a> <a href="https://github.com/ex4sperans/freesound-classification" target="_blank">here</a> but it worked worse.</p> <h1>Training process</h1> <p>We used <code>Adam</code> optimizer and <code>ReduceLROnPlateau</code> scheduler and <code>BCEwithLogits</code> loss</p> <p>Augmentations really boosted performance (~2%). We listened to example audio and tried to choose such augmentations, that can shift our train set to example audio:</p> <ul> <li>Gain (to make bird call less loud)</li> <li>Background noise - very and less loud. We have taken some background from <a href="https://www.kaggle.com/mmoreaux/environmental-sound-classification-50" target="_blank">here</a> and some 5 second clips directly from example audio. Finally we created such <a href="https://www.kaggle.com/vladimirsydor/cornelli-background-noises" target="_blank">background dataset</a></li> <li>LowFrequancy CutOff - we found out, that example audio has no lower frequency</li> </ul> <p>Also we used MixUp - we add audios and take max from two one-hot targets. As it was done by <a href="https://www.kaggle.com/ddanevskyi" target="_blank">@ddanevskyi</a> in <a href="https://www.kaggle.com/c/freesound-audio-tagging-2019/discussion/97926" target="_blank">Freesound</a></p> <h1>Choose Final Blend</h1> <p>First we tried simply to Blend all our good models - 14 experiments (70 models) and it gave us 0.623 Public score and 0.669 Private score. But then we have taken 4 best experiments with external data and 3 best without external data, which gave us 0.624 Public and 0.67 Private scores</p> <p>All Training details and inference of best Blend you can find in our <a href="https://www.kaggle.com/vladimirsydor/4-th-place-solution-inference-and-training-tips?scriptVersionId=42796948" target="_blank">inference notebook</a> </p> <h1>Framework</h1> <p>For training and experiment monitoring was used <a href="https://pytorch.org/" target="_blank">Pytorch</a> and <a href="https://catalyst-team.github.io/catalyst/" target="_blank">Catalyst</a> frameworks. Great thanks to <a href="https://www.kaggle.com/scitator" target="_blank">@scitator</a> and catalyst team! </p> <h1>P.S</h1> <p>Great thanks to my teammate - <a href="https://www.kaggle.com/khapilins" target="_blank">@khapilins</a><br> Also thanks to all DS community, especially to <a href="https://www.kaggle.com/ddanevskyi" target="_blank">@ddanevskyi</a>, <a href="https://www.kaggle.com/yaroshevskiy" target="_blank">@yaroshevskiy</a> and <a href="https://www.kaggle.com/frednavruzov" target="_blank">@frednavruzov</a>. They have taught me a lot and give inspiration to take part in Kaggle competitions.<br> Also thanks to all Kaggle team and community.<br> And happy Kaggling! </p>
Cornell Birdcall Identification
10th Place Solution
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Cornell Birdcall Identification <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><h2>Acknowledgments</h2> <p>First of all thanks for the organizers for this challenging and fascinating competition.<br> I am grateful for the relatively quick answers in the discussions (external data, domain knowledge,<br> it was certainly helpful.</p> <p>Special thanks to</p> <ul> <li>Hidehisa Arai for showing how to use PANNS effectively</li> <li>Qiuqiang Kong et al for PANNS repo and pretrained models</li> <li>Vopani for scraping and maintaining the external XenoCanto dataset</li> <li>Jan Schlüter and Mario Lasseck for their previous BirdCLEF winning papers </li> </ul> <h2>The beginning</h2> <p>Seven years ago I already participated in bird song detection challenge at kaggle.<br> That time we had only a few hundred 10 seconds recordings to train on and similar multiclass multilabel problem but with only 19 species.<br> I was able to win that competition with Computer Vision template matching and Random Forests.<br> I thought it would be a quick &amp; easy experiment to beat that with the available 40K bird recordings and all the available pretrained image net models.<br> Well it was not.</p> <p>Possible reasons</p> <ul> <li>Different sample rate (16kHz vs 32kHz)</li> <li>Soundscape vs Xenocanto</li> <li>MLSP train-test split was random split across soundscapes it was possible to overfit to the same recording (e.g. crickets &amp; rain -&gt; Hermit Warbler))</li> <li>Different spectrogram/noise distribution</li> </ul> <h2>Ornithology and LB Probing</h2> <p>In the beginning of the competition I was not able to submit meaningful results so I tried to understand the North American bird population better.<br> Just by submitting individual birds one would expect ~0.001 LB score with equal bird distribution.<br> From ebird.org observation data I was able to rank the 264 species based on their unique observations during the last two years.<br> It does not necessary reflect the distribution in the Public/Private test set but I found it better than the number of XC recordings.</p> <p>E.g.</p> <ul> <li>Red Crossbill 1223 XC recordings 84K observations 0.000 LB Score</li> <li>White-crowned Sparrow 474 XC recordings 1.1M observations 0.1 LB Score (!)</li> </ul> <h2>Data Preparation</h2> <p>Resampling everything to 32kHz and splitting the first 2 minutes of each recording to 10 second duration chunks and saving them as .npy arrays.<br> I used the extended dataset a<br> 4 fold cross validation was used stratified on the author-created at to try to avoid same birds in different folds.<br> For early stopping I saved the best weights based on XC validation and BirdCLEF Validation as well.</p> <h2>Augmentation</h2> <p>I only used additive noises.</p> <ul> <li>freefield1010</li> <li>warblrb10k</li> <li>BirdVox-DCASE-20k</li> <li>Animal Sound Archive Published by Museum für Naturkunde Berlin ()</li> </ul> <p>Probably should have tried synthetic noise generation too.</p> <h2>Architecture</h2> <p>I ended up with slightly modified CNN14 (128 mel bins, mean/std standardised)<br> They were relatively quick to train on Nvidia Tesla T4, training a single model took 3-8 hours.<br> I tried PANN ResNet38, Cnn14_DecisionLevelAtt or ImageNet pretrained ResNet50 but without proper validation I got mixed results…</p> <p>The dataloader handled the additive augmentations for the waveforms</p> <ul> <li>Add multiple possible 1-2-3 birds with multi-class setting</li> <li>Add same class chunks</li> <li>Add noise</li> <li>Add animal sound</li> </ul> <p>the GPU created the spectrograms for the batches.</p> <h2>Blending</h2> <p>During the last weekend I fixed my whole training pipeline and rented V100 to retrain a few final models and create some additional experiments.<br> On Sunday evening I submitted my first blended model with quite disappointing 0.570 Public Leaderboard result.<br> Actually it would have been enough for my final 10th place with Private score 0.649 Private Score.</p> <p>In the las two days I made some desperate submissions with more models, varying thresholds<br> (e.g. increasing the thresholds of west coast birds, reducing the thresholds for common birds) <br> They did improve my public LB score and fortunately they did not improve nor hurt the private score.<br> Probably with a few more submissions I would start to overfit…</p> <h2>What did not work but I thought it would…</h2> <ul> <li>Using secondary labels to improve primary labels with oof predictions</li> <li>Using a separate nocall classifier</li> <li>Utilizing the apriori knowledge that some birds are more frequent than others</li> <li>Blending normalized and unnormalized models</li> <li>Mixup</li> <li>More than 128 Mel bins</li> </ul>
Cornell Birdcall Identification
36th place solution
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Cornell Birdcall Identification <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>At first, congratulations to the winners and all participants who finished this competition. And also thanks to <a href="https://www.kaggle.com/shonenkov" target="_blank">@shonenkov</a> for kindly posting the kernel for submission.</p> <p>In the early stage of this competition, I was worried about the shake in private LB. But I continued with this competition, changed my thought as it is a relatively stable. I think this task was relevant to real issues and very interesiting. I would like to thank <a href="https://www.kaggle.com/stefankahl" target="_blank">@stefankahl</a>, <a href="https://www.kaggle.com/tomdenton" target="_blank">@tomdenton</a>, <a href="https://www.kaggle.com/holgerklinck" target="_blank">@holgerklinck</a> and Kaggle.</p> <p>So let me shamelessly share a simple solution.<br> The figure below is the overview of my model pipeline. As I'm sure there are already some great solutions out there, and will be more to come, so I'd like to give just a few points of my own.</p> <p><img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F479538%2Fd51398618f29983e9f7c73c327f42112%2Fbirdcall_model-pipeline_01.png?generation=1600220214358611&amp;alt=media" alt=""></p> <p>1) Event aware extraction<br> As the participants noticed, not all the time of an audio had bird voices. Therefore, if we randomly extracted some parts of an audio (e.g. 5 sec or so), there would be no birdsong at all, resulting in a form of mislabeling for training. To mitigate that, I used a naive algorithm to extract the signal parts of the audio as shown below.</p> <p><img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F479538%2Ff84b1e09ab70cd92ce87b957d69b38f5%2Fbirdcall_model-pipeline_02.png?generation=1600220869680424&amp;alt=media" alt=""></p> <p>2) LogMel Mixup<br> When I mixed 2 LogMels, once I convert it back into the power domain and then did a logarithmic transformation again. This is because LogMels are logarithmic values, and just linear summing is not the sum of the powers.<br> a * log(X1) + b * log(X2) != log(a * X1 + b * X2)<br> And labels were not scaled with the mixup coefficients used in features, but an union of them.</p> <p>3) Binary Model<br> I made a binary model (ResNet18) to classify call/nocall audio chunks. This slightly improved my score in publicLB, but as a result, it was a big improvement in privateLB.</p> <p>4) Multi Label Model (Multi Task Learning)<br> Although the primary label was provided in the data for this competition, it was clear that there were actually other bird calls in the background that fell under the competition's predictive label. So, in training the model, I did multitasking learning by splitting the model top into two parts, one for the primary label and the other for the background. And I trained the models as the learning strategy below.</p> <p>Step1: primary only<br> Step2: primary + background<br> Step3: psuedo soft labeling using background predictions</p> <p>Last step3 improved my score by 0.004 in public and 0.006 in private, respectively.</p> <p>Now, that's what I'm going to share with you. I'll see you at the next competition somewhere else. <br> Until next time!</p>
Cornell Birdcall Identification
6th place solution and some thoughts
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Cornell Birdcall Identification <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>First of all, I would like to sincerely thank <a href="https://www.kaggle.com/stefankahl" target="_blank">@stefankahl</a>, <a href="https://www.kaggle.com/tomdenton" target="_blank">@tomdenton</a>, <a href="https://www.kaggle.com/holgerklinck" target="_blank">@holgerklinck</a>, and the members of kaggle team for hosting this competition. I had a lot of fun tackling on some of the challenging problems of machine learning thinking of the generative process of the data. Also many thanks to <a href="https://www.kaggle.com/hengck23" target="_blank">@hengck23</a> for actively sharing a lot of deep insights. It helped me a lot to come up with some good ideas and also made me convinced that I was in good direction.</p> <p>Following the recent two competitions: <a href="https://www.kaggle.com/c/prostate-cancer-grade-assessment" target="_blank">PANDA</a> challenge and <a href="https://www.kaggle.com/c/global-wheat-detection" target="_blank">GWD</a> challenge, this competition was also about <strong>domain shift</strong> and <strong>noisy labels</strong>.<br> Combination of these two challenging topics made this competition extremely difficult and we were troubled a lot how to make stable validation scheme. To be honest, contrary to <a href="https://www.kaggle.com/cpmpml" target="_blank">@cpmpml</a>'s <a href="https://www.kaggle.com/c/birdsong-recognition/discussion/181499#1010570" target="_blank">expectation</a>, I couldn't find any good local validation scheme as the labels of training dataset contains a lot of noise. <code>Trust LB</code> was also not a very good policy since public LB was only 27% and we didn't know how the test set was devided. Instead, I took the policy of <a href="https://www.kaggle.com/c/prostate-cancer-grade-assessment/discussion/169230" target="_blank">PANDA's competitors</a> - <strong>Ignore CV, care about public LB, and trust methodology</strong>.</p> <p>Although this competition was difficult as a data science competition, it was actually pretty close to a realistic setting and was full of problems that we often face in applying data science to real-world problem. Especially the combination of domain shift and noisy labels often happens (I think) when we are to use data from User Generated Contents(UGC) web service like Xeno Canto, YouTube, Twitter for training machine learning algorithms. Therefore, I think my solution is useful not only for this competition but also for those data science tasks related with UGC data, as it's basically focused on dealing with noisy labels and domain shift.</p> <h2>Solution in three lines</h2> <ul> <li>3 stages of training to gradually remove noise in labels</li> <li>SED style training and inference as I introduced <a href="https://www.kaggle.com/hidehisaarai1213/introduction-to-sound-event-detection" target="_blank">here</a></li> <li>Ensemble of 11 EMA models trained with the whole dataset / whole <a href="https://www.kaggle.com/c/birdsong-recognition/discussion/159970" target="_blank">extended dataset</a> to stabilize the result</li> </ul> <p>Code is available here: <a href="https://github.com/koukyo1994/kaggle-birdcall-6th-place" target="_blank">koukyo1994/kaggle-birdcall-6th-place</a>.<br> Note: I've re-implemented the code from original repository since it's quite messy. However, I haven't checked whether whole pipeline works; if you find something wrong with the code, please let me know :)</p> <h2>Motivation</h2> <p>It's quite obvious that there is a huge gap between training dataset and test dataset: it was described by the host and can also be seen through submission. However, <em>how</em> they are different is not obvious. Therefore, the first thing I did was to understand by observation what kind of domain shifts are seen between training and test datasets.</p> <p>Domain shift is an umbrella term and there are several problem classes of domain shift. The most famous one is <em>covariate shift</em>, where \( P_{train}(X)\neq P_{test}(X) \) and \( P_{train}(Y|X)=P_{test}(Y|X) \). This one is well-studied and several algorithms are proposed to deal with the situation, but is not the type of domain shift in this competition. Another problem class is <em>prior probability shift</em> or <em>target shift</em>, where \( P_{train}(Y)\neq P_{test}(Y) \) and \( P_{train}(X|Y)=P_{test}(X|Y) \), also not the type in this competition because \( P_{train}(X|Y) \) is not the same as \( P_{test}(X|Y) \). In fact, in this competition, multiple distribution shifts are present - shift in input space, shift in prior probability of labels, and shift in the function which connects \( X \) and \( Y \).</p> <p>How should we tackle a problem with various distribution shifts? The answer is simple - <em>divide the difficulty</em>. As I wrote above, shifts were three folds:</p> <p>1) shift in input space. For example, SNR difference or difference in sound collection environment (device/sampling rate/temperature/weather/…) between train and test. Occurence of non-target sound events is also a part of this shift.<br> 2) shift in prior probability of labels. Distribution difference of species or distribution difference of calltypes, or else.<br> 3) shift in the function which connects \( X \) and \( Y \). This has a very strong relation with label noise. Thinking of how the labels were created in train dataset and in test dataset, one could come up with the fact that Label Function(LF) of train dataset is completely different from that of test dataset. The former is annotations of the uploader (and can have large variation), whereas the latter is probably those of dedicated annotator(s) (and possibly have smaller variation).</p> <p>I decided to address these one by one and applied the following techniques.</p> <ul> <li>For 1), providing all the possible variation for train dataset may help. This is done by data augmentation.</li> <li>For 2), I just couldn't come up with smart ideas. I used ensemble of multiple models trained with datasets with different distributions of the labels to address this, but I think that is suboptimal.</li> <li>For 3), correcting the labels of train dataset to make train LF closer to test LF can help.</li> </ul> <p>On the other hand, label noise is also a term that contains multiple problem classes. First, in this competition, labels of train dataset are provided as <em>weak labels</em>. As <a href="https://www.kaggle.com/hengck23" target="_blank">@hengck23</a> pointed out <a href="https://www.kaggle.com/c/birdsong-recognition/discussion/174774#972122" target="_blank">here</a>, weak label can be treated as noisy label if we change the point of view. Also there are some missing labels, which I'll explain later.</p> <p>I also decided to address these one by one.</p> <ul> <li>For weak label as noisy label, I first train a model with long chunk and then use the prediction as corrected label. I at first tried to create strong labels but couldn't make the first stage model good enough, therefore I used the prediction to correct weak labels we have in train dataset.</li> <li>For missing label, I also used the prediction of a model to find those.</li> </ul> <h2>First stage - build a model useful enough for addressing missing labels</h2> <p>In this stage, I used PANNs model. I used some basic augmentations (<code>NoiseInjection</code>, <code>PitchShift</code>, <code>RandomVolume</code>) and used <code>secondary_labels</code>. The keys in this stage were two folds:</p> <ul> <li>train with long chunk(30s) so that it would include call events of the species in <code>primaly_label</code> and <code>secondary_labels</code></li> <li>use attention pooling and max pooling to get weak prediction from <code>framewise_output</code></li> </ul> <p>Here are the reason behind.</p> <h3>train with long chunk</h3> <p>Assume we have <code>primary_label</code> of <code>birdA</code> and <code>secondary_labels</code> of <code>birdB</code> and <code>birdC</code>. Melspectrogram of the corresponding audio clip is something like the figure below (sorry for my poor drawing). If we use small window size, it may not include any sound events or include some sound events but not enough for the given labels. To make the model learn correctly, we need to make each label correspond to call event(s) of each species. For this reason, I used long chunk. Maybe it is better to use longer chunk like 1 minutes or more but I compromised to use 30s chunk considering the time for computation.</p> <p><img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1489975%2Fcd841cb51b7b1fa4de6a6b2b7880e2d6%2FIMG_BBFA97950653-1.jpeg?generation=1600216062555033&amp;alt=media" alt=""></p> <h3>Combination of attention pooling and max pooling to get weak prediction</h3> <p>This is something I shared <a href="https://www.kaggle.com/c/birdsong-recognition/discussion/167611" target="_blank">here</a>.<br> In the comments in <a href="https://www.kaggle.com/hidehisaarai1213/introduction-to-sound-event-detection" target="_blank">my SED notebook</a>, some said there were lots of false positives. This comes from the following reason.</p> <p>Weak prediction from attention pooling is made by applying self-attention filter on <code>framewise_outputs</code>. Now, we only have weak labels, we calculate the loss with weak predictions and weak labels. The gradient will be distributed to self-attention layer and pointwise classifier, but for pointwise classifier, strong supervision comes when self-attention put high probability at that point. Therefore, pointwise classifier are more likely to produce high probability value and rely on the attention layer to reduce false positives. This is not good when we are interested in the output of pointwise classifier(<code>framewise_outputs</code>).</p> <p>On the contrary, max pooling suppresses high probability values come out from pointwise classifier but it also has a defect that it is weak to impulse noise. Therefore, combination of max pooling and attention pooling can make balanced prediction and we can expect that be good prediction. For this reason, I used both but not combining the weak prediction from each aggregation but use each output and calculate loss for each, and sum them up. Therefore, the loss function I used in this stage was like this</p> <pre><code>bce = BCELoss() loss_att = bce(weak_pred_with_attention, label) loss_max = bce(weak_pred_with_maxpooling, label) loss = 1.0 * loss_att + 0.5 * loss_max </code></pre> <h3>Summarize this stage</h3> <ul> <li>Single PANNs model</li> <li>BCE on <code>clipwise_output</code> and also on maxpooled output.</li> <li>Adam + CosineAnnealing, 55epochs training</li> <li>train with randomly cropped 30s chunk</li> <li>validate on randomly cropped 30s chunk</li> <li>Augmentations on raw waveform<ul> <li><code>NoiseInjection</code> (max noise amplitude 0.04)</li> <li><code>PitchShift</code> (max pitch level 3)</li> <li><code>RandomVolume</code> (max db level 4)</li></ul></li> </ul> <h3>Get oof prediction and use it to find missing labels</h3> <p>With training procedure above, the model would get around 0.575 - 0.578. In fact, this is the weight I used in the public notebook.<br> I trained 5folds and got oof prediction on the whole training set. Then I used this oof prediction to find missing labels.</p> <p>Missing labels are more likely to be found from samples that does not have <code>secondary_labels</code>. It is up to the uploader to fill in <code>secondary_labels</code> or <code>background</code>, so some uploaders may not feel like to fill in those. Therefore, I picked samples without <code>secondary_labels</code> and used oof prediction of those to get additional labels if the probability of species that are not in their <code>primary_label</code> is over 0.9.</p> <h2>Second stage - build a model with additional labels to get stronger labels</h2> <p>In this stage, I used SED model with ResNeSt encoder. The difference between first stage and second stage is not that big - only the model, the existence of found labels (the labels obtained from the oof prediction of the first stage), and the input. I started to use 3channel input. The first channel was normal log-melspectrogram and the second channel was PCEN. The third channel was also log-melspectrogram but instead of using <code>librosa.power_to_db(melspec)</code>, I used <code>librosa.power_to_db(melspec ** 1.5)</code>. The idea of using different input for each channel comes from <a href="https://www.kaggle.com/c/birdsong-recognition/discussion/170959" target="_blank">this post</a>. The chunk size is also reduced to 20s because of the GPU memory size limitation.</p> <p>I also changed the attention pooling slightly given the <a href="https://www.kaggle.com/hidehisaarai1213/introduction-to-sound-event-detection/comments" target="_blank">advice of </a><a href="https://www.kaggle.com/hengck23" target="_blank">@hengck23</a> to use <code>torch.tanh</code> instead of <code>torch.clamp</code>.</p> <p>The result of this stage got around 0.60. I also trained 5folds model and this time I got oof prediction of <code>framewise_outputs</code>.</p> <p>To summarize,</p> <ul> <li>SED model with ResNeSt50 encoder, attention pooling head of PANNs (<code>torch.clamp</code> -&gt; <code>torch.tanh</code>)</li> <li>BCE on <code>clipwise_output</code> and also on maxpooled output</li> <li>Adam + CosineAnnealing, 75epochs training</li> <li>Add additional <code>secondary_labels</code> found in stage1</li> <li>3channels input - [normal logmel, PCEN, <code>librosa.power_to_db(melspec ** 1.5)</code>]</li> <li>train with randomly cropped 20s chunk</li> <li>validate on randomly cropped 30s chunk</li> <li>Augmentations on raw waveform<ul> <li><code>NoiseInjection</code> (max noise amplitude 0.04)</li> <li><code>PitchShift</code> (max pitch level 3)</li> <li><code>RandomVolume</code> (max db level 4)</li></ul></li> </ul> <h2>Third stage - build a model with oof framewise_outputs</h2> <p>Despite the use of training with long chunk size and missing labels, label noise problem is far from solved. SNR level to decide whether a call event was present is different between training set and test set. In fact, that was also different between samples of training set because basically each annotator (uploader) had their own labeling criteria. For this reason, I used the oof prediction of <code>framewise_outputs</code> of the second stage to further correct the labels of the training dataset. </p> <p>In this stage, I also cropped 20s chunk randomly to get a batch. At this time I also cropped the corresponding part of the predicted <code>framewise_outputs</code> and apply threshold on them (threshold varies from 0.3 - 0.7). After thresholding, I get max pooling of the thresholded prediction in time axis to get chunk level prediction. Still, this prediction can be noisy and may contain false positives, I apply <code>logical_and</code> between predicted labels and provided labels. In this way, I got corrected chunk level label and use that for training.</p> <p>Here's the pseudo-code of the process above</p> <pre><code>y_batch = y[start_index:end_index] soft_label_batch = soft_label[start_index_for_label:end_index_for_label] # (n_frames, 264) thresholded = (soft_label_batch &gt;= threshold).astype(int) weak_pred = thresholded.max(axis=0) # (264,) corrected_label = np.logical_and(label, weak_pred) # (264,) </code></pre> <p>In this stage, I also tried EfficientNet-B0 encoder and FocalLoss. Combination of ResNeSt encoder and FocalLoss didn't work well, whereas EffNet-B0 and FocalLoss worked well on public LB.</p> <p>All the other settings were the same as that of second stage. After this, I got around 0.61x score on public LB.</p> <p>To summarize,</p> <ul> <li>SED model with ResNeSt50 encoder, attention pooling head of PANNs (<code>torch.clamp</code> -&gt; <code>torch.tanh</code>) / EfficientNet-B0 encoder</li> <li>BCE on <code>clipwise_output</code> and also on maxpooled output / FocalLoss on <code>clipwise_output</code> and also on maxpooled output for EfficientNet-B0</li> <li>Adam + CosineAnnealing, 75epochs training</li> <li>Add additional <code>secondary_labels</code> found in stage1</li> <li>Correct labels using the prediction of stage2 model.</li> <li>3channels input - [normal logmel, PCEN, <code>librosa.power_to_db(melspec ** 1.5)</code>]</li> <li>train with randomly cropped 20s chunk</li> <li>validate on randomly cropped 30s chunk</li> <li>Augmentations on raw waveform<ul> <li><code>NoiseInjection</code> (max noise amplitude 0.04)</li> <li><code>PitchShift</code> (max pitch level 3)</li> <li><code>RandomVolume</code> (max db level 4)</li></ul></li> </ul> <h2>Ensemble</h2> <p>With the corrected chunk level label, I trained the model with the whole dataset and use EMA model (using the implementation <a href="https://pytorch.org/docs/stable/optim.html#stochastic-weight-averaging" target="_blank">here</a>) for inference. This is a technique also used in <a href="https://www.kaggle.com/c/global-wheat-detection/discussion/172458" target="_blank">GWD competition</a>. </p> <p>I prepared models with different threshold (threshold on <code>framewise_outputs</code> of oof prediction) to make the model robust. Also important was the use of extended dataset. It doesn't get better result on public LB but when I used that for ensemble, it bumped up the score.</p> <h2>Things that didn't work for me</h2> <ul> <li>Mixup</li> <li>Calltype classification (781 class)</li> <li>noisy student training</li> <li>Larger models of efficientnet (b1, b2, b3…)</li> <li>etc…</li> </ul> <h2>Things that worked but doesn't make sense to me</h2> <p>When I change the PERIOD used for inference, the result greatly changed. Basically the larger value PERIOD is, the better the result. I just couldn't figure out why.</p> <h2>Things that I wanted to try but couldn't</h2> <p>There are lots of things I couldn't do due to the time limitation </p> <ul> <li>Use a variety of models</li> <li>Further refinement of the labels of train dataset/train extended dataset</li> <li>Use of auxiliary predictor to predict longitude/latitude/elevation and use the prediction to correct the main classifier</li> <li>Post-processing to refine prediction using species correlation information (I couldn't get the API key for ebird.org therefore I couldn't collect correlation information)</li> <li>Mixing background noise</li> <li>etc…</li> </ul> <h2>The thing that helped me a lot during competition</h2> <p>I created a simple streamlit app to check the audio data. I mainly used this to check the effect of augmentations or to check the quality of SED models prediction. This helped me a lot to figure out the major problems of this competition</p> <p><a href="https://github.com/koukyo1994/streamlit-audio" target="_blank">https://github.com/koukyo1994/streamlit-audio</a></p> <p>Later I learned <a href="https://www.kaggle.com/fkubota" target="_blank">@fkubota</a> also made an app with similar functionality. I didn't use this but it seems it's better than mine.</p> <p><a href="https://github.com/fkubota/spectrogram-tree" target="_blank">https://github.com/fkubota/spectrogram-tree</a></p>
Cornell Birdcall Identification
101st Place Solution (Top 8%)
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Cornell Birdcall Identification <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>This competition was a toughie. Special thanks to my team members for their support <a href="https://www.kaggle.com/doanquanvietnamca" target="_blank">@doanquanvietnamca</a> , <a href="https://www.kaggle.com/truonghoang" target="_blank">@truonghoang</a> throughout this competition.</p> <p>As this was my first audio competition, in the beginning, I tried effnetb3 using fastai as a baseline, with precomputed spectrograms. This was able to beat the public LB baseline, giving a score of 0.554. However, I was unable to improve this model. My team and I subsequently tried several other new models in the process</p> <p><strong>Models tried:</strong></p> <ol> <li>EfficientNetB1</li> <li>ResNest50 (best model)</li> <li>MobileNetV2</li> <li>SED model, with effnetb0 backbone</li> <li>EfficientNetB3 (with pretrained noisystudent weights)</li> </ol> <p>ResNest50 performed well for this task, with the same classifier head provided by <a href="https://www.kaggle.com/hidehisaarai1213" target="_blank">@hidehisaarai1213</a>. </p> <p>Augmentations also worked well for us, namely:</p> <ol> <li>Adding gaussian noise</li> <li>Adding pink noise</li> <li>Adding background noise </li> </ol> <p>We also tried a model with 265 classes, with nocall as a class but that didn't work better than a normal 264 classifier model.</p> <p>We tried incorporating secondary labels to perform the multilabel classification task, it gave decent CV (up to 0.7x validation micro score), faltered in public LB (0.569) but was the best performing model for private LB (0.616). </p> <p>We were unable to bridge the gap between CV and LB, the correlation between CV and LB was not strong so in the end we had to trust our methodology and public LB.</p> <p>We settled for an ensemble of models between ResNest50 and MobileNetV2 which landed us with the bronze solution.</p> <p><strong>Summary of things that did not work for us:</strong></p> <ol> <li>SED ( could not get it to work somehow, will have to learn from training solution by <a href="https://www.kaggle.com/hidehisaarai1213" target="_blank">@hidehisaarai1213</a> to understand more why)</li> <li>265 class classifier (including nocall class), decreased public and private LB</li> <li>Denoising on test set</li> <li>F1Loss (possibly due to batch size being too small)</li> <li>FocalLoss</li> </ol> <p>Special thanks to the organizers of this competition and fellow competitors whom I learn loads from (@hidehisaarai1213 , <a href="https://www.kaggle.com/radek1" target="_blank">@radek1</a>, <a href="https://www.kaggle.com/kneroma" target="_blank">@kneroma</a>, <a href="https://www.kaggle.com/ttahara" target="_blank">@ttahara</a>). Hope to join another audio competition to further my learning. Congrats to all winners in this competition.</p>
Cornell Birdcall Identification
My solution for my first medal (silver)
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Cornell Birdcall Identification <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Thanks to kaggle and competition host for bringing this competition and congrats to the winners and other competitors. this is my first time working with audio data and i sure learned a lot about DL due to the nature of this competition. The domain mismatch between the training and testing environment posted a good challenge to constantly question my understanding about Data and DL understanding .</p> <p><strong>My solution:</strong><br> this is my best solution which i did not select for final submission <strong>0.626</strong><br> This is an ensemble of two best models from different fold and varying level of augmentation</p> <p>Feature extractor : <strong>Resnet18</strong><br> Network architecture : Sound Event Detection(Not PANN)<br> Method of training : Multi instance learning<br> Key layer : <strong>Adaptive Auto pooling</strong> Presented <a href="https://arxiv.org/pdf/1804.10070.pdf" target="_blank">here</a><br> Augmentation: extracted 20 sec sound data and mixed with other randomly chosen audio sample, Low pass filter(as low frequency waves travel longer distance), added background noise extracted from the provided autio sample.<br> Best score threshold : 0.30</p> <p><strong>Things i should have focused:</strong><br> i completely ignored the fact that there is additional data available and posted in the competition. this would have given me some more benefits. not aware of domain adaptation techniques and hoping to learn from others solution. Not changing from Resnet18 base model. for some reason i kept on working on the data and ignored to change the extractor when i had the time to experiment with it.</p> <p>code: <a href="https://github.com/yuvaramsingh94/Cornell-Birdcall-Identification-kaggle-solution" target="_blank">github</a></p> <p>the code needs some more cleaning and i will add a detailed Readme </p> <p>Thanks to <a href="https://www.kaggle.com/hidehisaarai1213" target="_blank">@hidehisaarai1213</a> <a href="https://www.kaggle.com/ttahara" target="_blank">@ttahara</a> and others for constantly sharing ideas and findings to help others. <br> On to the next competitions :)</p>
TReNDS Neuroimaging
47th Place - Site 2 Correction
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: TReNDS Neuroimaging <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>The best public notebook <a href="https://www.kaggle.com/david1013/trends-multi-layer-model" target="_blank">here</a> scores LB 0.1590. If you analyze the predictions, you will see that it underestimates target <code>age</code> and underestimates target <code>domain2_var1</code> for site 2 brain scans. If you adjust these 2 targets, you increase it's LB score to LB 0.1585. That's a 0.0005 LB Boost !</p> <h1>Classify Brain Scans as Site 2</h1> <p>Using an ensemble of logistic regression with L2 regularization and RAPIDS cuML support vector classification, you can build a site 2 classifier with AUC = 0.80. Below is the classifier's probability distribution. There are 3507 test samples with <code>prob = 0</code> of being site 2. There are 800 test samples with <code>0 &lt; prob &lt;= 0.5</code> and 508 test samples with <code>0.5 &lt; prob &lt; 1</code> and 1062 with <code>prob = 1</code>. (The 1062 includes the known 510).</p> <p><img src="https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1723677%2F23bdd9c9160467874ee0c021ed518740%2FScreen%20Shot%202020-06-29%20at%206.57.37%20PM.png?generation=1593482276909658&amp;alt=media" alt=""></p> <h1>Determine Target Bias of Site 2</h1> <p>Next if you plot the targets versus site 2 probability, we see that the targets <code>age</code> and <code>domain2_var1</code> decrease as the probability of site 2 brain scans increase. If we <strong>assume</strong> that site 1 and site 2 have the same <code>age</code> and <code>domain2_var1</code> mean then this is a statistically significant model bias based on site feature drift. </p> <p>(For samples of size 1000, the sample mean's standard deviation of target is <code>0.3 = OOF std / sqrt(1000)</code> therefore our observation is not random chance. )</p> <p><img src="https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1723677%2Fa39fa26954aff4aa77bdf7f9fa867f36%2FScreen%20Shot%202020-06-29%20at%206.54.42%20PM.png?generation=1593482098625573&amp;alt=media" alt=""></p> <h1>Post Process Correction - Boost LB 0.00050!</h1> <p>From the plot we observe that this biased model needs to add <code>1.9</code> to the test target <code>age</code> for site 2 brain scans with <code>prob = 1</code> and needs to add <code>0.67</code> to the test target <code>domain2_var1</code> for site 2 brain scans. Furthermore we can adjust <code>0.5 &lt; prob &lt; 1</code>, <code>0 &lt; prob &lt;= 0.5</code>, and <code>prob = 0</code> based on the plot. </p> <h3>1590 Public Notebook With PP</h3> <p><img src="https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1723677%2F83004b4000cf0d3c5a899cc13a4c5f00%2FScreen%20Shot%202020-06-29%20at%207.13.37%20PM.png?generation=1593483311555960&amp;alt=media" alt=""></p> <h3>1590 Public Notebook Without PP</h3> <p><img src="https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1723677%2F89139b7bc495ae25f565a1c8c281fbb3%2FScreen%20Shot%202020-06-29%20at%207.18.46%20PM.png?generation=1593483542944485&amp;alt=media" alt=""></p> <h1>Private Leaderboard</h1> <p>I was hoping that private leaderboard would have more site 2 data. Then this trick would increase private LB more than public LB and I would have climbed rank on private leaderboard :-) Instead this PP only increased private LB by +0.00025 and I dropped rank on private LB :-(</p> <p><strong>UPDATE</strong>: Two simple experiments suggest that private test has 510 site 2 brain scans and public test has 1020 site 2 brain scans. The experiments are described <a href="https://www.kaggle.com/c/trends-assessment-prediction/discussion/162907" target="_blank">here</a></p> <h1>Final Models</h1> <p>My final model was an ensemble of these 4 great notebooks:<br> <a href="https://www.kaggle.com/david1013/trends-multi-layer-model" target="_blank">trends-multi-layer-model</a> by NQ <a href="https://www.kaggle.com/david1013" target="_blank">@david1013</a><br> <a href="https://www.kaggle.com/andypenrose/baggingregressor-rapids-ensemble" target="_blank">BaggingRegressor + RAPIDS Ensemble</a> by Andy <a href="https://www.kaggle.com/andypenrose" target="_blank">@andypenrose</a><br> <a href="https://www.kaggle.com/ttahara/trends-simple-nn-baseline" target="_blank">TReNDS:Simple NN Baseline</a> by Tawara <a href="https://www.kaggle.com/ttahara" target="_blank">@ttahara</a><br> <a href="https://www.kaggle.com/hemavivekanandan/trends-eda-dnn-for-predicting-age" target="_blank">TRends: EDA,DNN for Predicting Age</a> by Hema <a href="https://www.kaggle.com/hemavivekanandan" target="_blank">@hemavivekanandan</a> </p> <p>Ensemble achieved LB 0.1588 with weights <code>0.60 * model_1 + 0.20 * model_2 + 0.15 * model_3 + 0.05 * model_4</code> and then PP increased this to LB 0.1583.</p>
Cornell Birdcall Identification
167 Place Solution
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Cornell Birdcall Identification <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Congrats to all winners! And thanks to organizers!<br> My score is not good, but sharing my gotten knowledge.</p> <h3>modeling</h3> <p>My base model is DenseNet201 trained ImageNet.<br> Most people used ResNet, but it not work for me.</p> <p>I read <a href="https://arxiv.org/pdf/1908.02876.pdf" target="_blank">this paper</a>, and apply applied to my model.</p> <p><img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1483555%2F4d0acfb9be5bb112c566bc8d55627aa2%2F2020-09-15%2018.45.50.png?generation=1600214606636136&amp;alt=media" alt=""></p> <p>code is:</p> <pre><code>class BirdcallNet(nn.Module): def __init__(self): super(BirdcallNet_densenet, self).__init__() densenet = densenet161(pretrained=config.PRETRAINED) self.features = densenet.features self.l8_a = nn.Conv1d(2208, config.N_LABEL, 1, bias=False) self.l8_b = nn.Conv1d(2208, config.N_LABEL, 1, bias=False) def forward(self, x, perm=None, gamma=None): # input: (batch, channel, Hz, time) frames_num = x.shape[3] x = x.transpose(3, 2) # (batch, channel, time, Hz) h = self.features(x) # (batch, unit, time, Hz) h = F.relu(h, inplace=True) h = torch.mean(h, dim=3) # (batch, unit, time) xa = self.l8_a(h) # (batch, n_class, time) xb = self.l8_b(h) # (batch, n_class, time) xb = torch.softmax(xb, dim=2) pseudo_label = (xa.sigmoid() &gt;= 0.5).float() clipwise_preds = torch.sum(xa * xb, dim=2) attention_preds = xb return clipwise_preds, attention_preds, pseudo_label </code></pre> <h4>Parameters</h4> <ul> <li>BCE loss</li> <li>5-fold CV</li> <li>Adam<ul> <li>learning_rate=1e-3</li> <li>55 epoch</li> <li>batch size=64</li></ul></li> <li>CosineAnnealingWarmRestarts<ul> <li>T=10</li></ul></li> </ul> <h3>Data Augumentation</h3> <ul> <li>Adjust Gamma</li> <li>Spec Augmentation Freq</li> <li>MixUp</li> </ul> <h3>Other Technique</h3> <ul> <li>SWA</li> </ul> <h3>Not Work for me</h3> <ul> <li>Denoise(I tried my best, but it didn't work …)</li> <li>"nocall" prediction by PANNs trained model</li> <li>Transformer</li> <li>WaveNet</li> <li>use secondary_labels</li> <li>optimize threshold</li> <li>Focal Loss</li> <li>CutMix</li> <li>Label Smoothing</li> <li>Spec Augmentation Time</li> <li>DIfferent learning rate for each layer</li> <li>Multi Sample Dropout</li> </ul> <h3>My Code</h3> <p><a href="https://github.com/trtd56/Birdcall" target="_blank">https://github.com/trtd56/Birdcall</a></p> <h3>My Blog(Japanese)</h3> <p><a href="https://www.ai-shift.co.jp/techblog/1271" target="_blank">https://www.ai-shift.co.jp/techblog/1271</a></p> <p>Thank you!!</p>
Halite by Two Sigma
Post-mortem for HuiUnited's Halite IV bot (26th rank)
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Halite by Two Sigma <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>The code for my highest score bot is <a href="https://github.com/arpakornb/Halite4" target="_blank">here</a>.</p> <p>First of all, I would like to thank Two Sigma and Kaggle for organizing such a fun competition. I'm also indebted to the notebook from <a href="https://www.kaggle.com/yegorbiryukov/halite-swarm-intelligence" target="_blank">Yegor Biryukov</a> and <a href="https://www.kaggle.com/alexisbcook/getting-started-with-halite" target="_blank">Alexis Cook</a> for getting me started.</p> <p>Initially I did this only as a way to learn python and start participating in kaggle competition. My background was in C programming for networking equipment with no ML experience.</p> <p>I took a direct (and you might say, naive) approach: dig, steer, deposit, with no attempt at hunting. Each ship scans its neighborhood up to four steps away from it to find the highest halite cell (with weight to prefer nearer cells) and goes there. Neighboring ships don't go to cells that have already been chosen. This seems good enough that I stick with it til the end. I augmented it (last week of competition) to improve the beginning phase (up to ~step 20) by choosing the top 9 halite cells in my quadrant (except two steps around yard) as targets for the first 9 ships. I control how much each ship digs by a maximum constant that varies based on game step and how aggressive other players are hunting.</p> <p>Navigating crowded space seems very challenging. I try to solve this by assessing risk two steps around each ship at the beginning of each step. I assign varying risk values to my or enemy ship, its distance and carrying halite. I let my ships that might be attacked choose its move first followed by ships that have lower risk value (trying to make room for ships in risky position).</p> <p>With all of the above, my submissions' score just would not go higher than 1100. It will do well up until around step 70-200 when not enough ships will survive the hunting onslaught. That's when I realized that I need to hunt as well so I experiment with the easiest approach. I stop collecting at around step 70 and every ship with zero halite will look for nearby enemy ships (three steps around) with the highest halite and step toward that ship. There is no coordination between ships whatsoever. This seems to raise my score into ~1200 level. I think it is not really the hunting that helps but mostly because I preserve enough ships to have a chance to collect again after step 300. I augmented this later by doing some digging if there's no enemy ship around and that helps a little bit.</p> <p>I also improve the shipyard creation and placement and see a small improvement. More precision is needed there.</p> <p>Other noteworthy improvements came from reacting to what other players do. rica_chan's bot taught me a lot. :) For example, its shipyard destruction near the end prompted me to tighten the ship and shipyard creation logic. I also copied mzotkiew's end game all-out deposit.</p> <p>All in all, this has been good fun and a great experience. Looking forward to the next competition. I'm thankful for everyone who has shared their code. It is great learning resource. Really appreciate it!</p>
Cornell Birdcall Identification
3rd place solution
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Cornell Birdcall Identification <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Very glad to end my journey to Kaggle GM with a 3rd place, congratz to my teamates and everybody who made it to the end !</p> <p>Our solution has three main aspects : data augmentation, modeling and post-processing</p> <h4>Data Augmentation</h4> <p>Data augmentation is the key to reduce the discrepancy between train and test. We start by randomly cropping 5 seconds of the audio and then add aggressive noise augmentations :</p> <ul> <li>Gaussian noise</li> </ul> <p>With a soud to noise ratio up to 0.5</p> <ul> <li>Background noise</li> </ul> <p>We randomly chose 5 seconds of a sample in the background dataset available <a href="https://www.kaggle.com/theoviel/bird-backgrounds" target="_blank">here</a>. This dataset contains samples without bircall from the example test audios from the competition data, and some samples from the freesound bird detection challenge that were manually selected.</p> <ul> <li>Modified Mixup</li> </ul> <p>Mixup creates a combination of a batch <code>x1</code> and its shuffled version <code>x2</code> : <code>x = a * x1 + (1 - a) * x2</code> where <code>a</code> is samples with a beta distribution. <br> Then, instead of using the classical objective for mixup, we define the target associated to <code>x</code> as the union of the original targets. <br> This forces the model to correctly predict both labels.<br> Mixup is applied with probability 0.5 and I used 5 as parameter for the beta disctribution, which forces <code>a</code> to be close to 0.5.</p> <ul> <li>Improved cropping </li> </ul> <p>Instead of randomly selecting the crops, selecting them based on out-of-fold confidence was also used. The confidence at time <code>t</code> is the probability of the ground truth class predicted on the 5 second crop starting from <code>t</code>.</p> <h4>Modeling</h4> <p>We used 4 models in the final blend :</p> <ul> <li>resnext50 [0.606 Public LB -&gt; 0.675 Private] - trained with the additional audio recordings.</li> <li>resnext101 [0.606 Public LB -&gt; 0.661 Private] - trained with the additional audio recordings as well.</li> <li>resnest50 [0.612 Public LB -&gt; 0.641 Private] </li> <li>resnest50 [0.617 Public LB -&gt; 0.620 Private] - trained with improved crops </li> </ul> <p>Turns out that training with more data was the key, and that both our resnest were overfitting to public LB. Thanks to people who shared the datasets ! </p> <p>They were trained for 40 epochs (30 if the external data is used), with a linear scheduler with 0.05 warmup proportion. Learning rate is 0.001 with a batch size of 64 for the small models, and both are divided by two for the resnext101 one, in order to fit in a single 2080Ti.</p> <p>We had no reliable validation strategy, and used stratified 5 folds where the prediction is made on the 5 first second of the validation audios.</p> <h4>Post-processing</h4> <p>We used 0.5 as our threshold <code>T</code>.</p> <ul> <li>First step is to zero the predictions lower than <code>T</code></li> <li>Then, we aggregate the predictions<ul> <li>For the sites 1 and 2, the prediction of a given window is summed with those of the two neighbouring windows. </li> <li>For the site 3, we aggregate using the max</li></ul></li> <li>The <code>n</code> most likely birds with probability higher than <code>T</code> are kept<ul> <li><code>n = 3</code> for the sites 1 and 2</li> <li><code>n</code> is chose according to the audio length for the site 3.</li></ul></li> </ul> <h4>Code</h4> <p>Everything is fully available :</p> <ul> <li>Inference : <a href="https://www.kaggle.com/theoviel/inference-theo?scriptVersionId=42527667" target="_blank">https://www.kaggle.com/theoviel/inference-theo?scriptVersionId=42527667</a> </li> <li>Train in Kaggle kernels : <a href="https://www.kaggle.com/theoviel/training-theo-3" target="_blank">https://www.kaggle.com/theoviel/training-theo-3</a> (code is a bit dirty but directly usable)</li> <li>Github : <a href="https://github.com/TheoViel/kaggle_birdcall_identification" target="_blank">https://github.com/TheoViel/kaggle_birdcall_identification</a> (code is cleaned and documented)</li> </ul> <h4>Final words</h4> <p>As we had no proper validation scheme, private LB was really a coinflip for us. The top 3 is a nice surprise ! Our best submission is actually the 5-fold ResNext50 alone, which was quite unpredictable.</p> <p>Thanks for reading !</p> <p>(topic will probably be updated)</p>
SIIM-ISIC Melanoma Classification
3rd place solution overview
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: SIIM-ISIC Melanoma Classification <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Code available here: <a href="https://github.com/Masdevallia/3rd-place-kaggle-siim-isic-melanoma-classification" target="_blank">https://github.com/Masdevallia/3rd-place-kaggle-siim-isic-melanoma-classification</a></p> <p>Hello everybody!</p> <p>Well… I am speechless. I am quite new at Kaggle and was not expecting such a good result, it has taken me completely by surprise.</p> <p>First of all, I need to deeply thank the entire Kaggle community. I've learned a lot throughout the entire competition thanks to all the knowledge and insights you have generously shared. Thank you also to the organizers and Kaggle for hosting the competition.</p> <p>I am away on vacation with a limited internet connection, but I will share my solution as soon as I can.</p> <p>As a quick summary, my main submission was an ensemble of 8 different models built with various combinations of image sizes (256, 384, 512, 768). Many thanks to <a href="https://www.kaggle.com/vbhargav875" target="_blank">@vbhargav875</a>, whose notebook "EfficientNet-B5_B6_B7 TF-Keras" was an incredible starting point. I used CV to implement some experiments, but my finals models where obtained with all available data (without validation). I used 2017-2018-2019 + 2020 TFrecords (huge thanks to <a href="https://www.kaggle.com/cdeotte" target="_blank">@cdeotte</a>), hair augmentation (thanks to <a href="https://www.kaggle.com/nroman" target="_blank">@nroman</a> and <a href="https://www.kaggle.com/graf10a" target="_blank">@graf10a</a>), heavy TTA, EfficientNet-B6 models and metadata (thanks to <a href="https://www.kaggle.com/titericz" target="_blank">@titericz</a>). This approach scored: 0.9481 private LB, 0.9596 public LB.</p> <p>However, I wanted to try to ensemble some public notebooks too, in order to add some diversity. I decided to go ahead with these two amazing notebooks, which introduced some juicy techniques that I didn't have time to test:</p> <ul> <li><a href="https://www.kaggle.com/rajnishe/rc-fork-siim-isic-melanoma-384x384" target="_blank">https://www.kaggle.com/rajnishe/rc-fork-siim-isic-melanoma-384x384</a> (thanks to <a href="https://www.kaggle.com/rajnishe" target="_blank">@rajnishe</a>).</li> <li><a href="https://www.kaggle.com/ajaykumar7778/efficientnet-cv" target="_blank">https://www.kaggle.com/ajaykumar7778/efficientnet-cv</a> (thanks to <a href="https://www.kaggle.com/ajaykumar7778" target="_blank">@ajaykumar7778</a>).</li> </ul> <p>This approach scored: 0.9484 private LB, 0.9620 public LB.</p> <p>Congratulations to all participants! I know that I still have a long way to go, but I am looking forward to continuing to grow alongside this incredible community.</p>
SIIM-ISIC Melanoma Classification
40th Place Summary - In Chris and CV we trust
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: SIIM-ISIC Melanoma Classification <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Hi Kaggle fam,</p> <p>Apologies this was a little delayed – was quite surprised at the result and took some time to retrace my own steps, but thought I would share a few findings that might add to what’s been shared already. </p> <p>Firstly massive shoutout to <a href="https://www.kaggle.com/cdeotte" target="_blank">@cdeotte</a> for his triple-stratified TFrecords which saved a heap of time, and also the interesting techniques he kindly shared which I’ve still yet to try out and fully understand – I like many other noivces look forward to learning more from you in future competitions!</p> <p>Like most teams, I realised early on that training different nets on images of different sizes generated varying results in terms CV across validation folds, so I thought ensembles that maximise local CV might be the way to go. My submissions were simple weighted averages of a bunch of EfficientNets of sizes (B4-B7), mostly initialised with noisy-student weights, trained on image sizes 384, 512 and 768 with TTA (15) across 5 validation folds. For augmentation, I believe the original author of the techniques I used is <a href="https://www.kaggle.com/agentauers" target="_blank">@agentauers</a>, so a huge thank you for sharing them. Previous competition data was also used for increasing the diversity of the ensemble.</p> <p>Something I found interesting was that with my setup, larger nets + larger images seemed to have generally performed a little better than smaller nets + smaller images (both CV &amp; private LB). Even when ensembling, smaller nets did not help with CV much at all and hence were largely not part of my final submissions. I’m curious to hear if that was the case for anyone else (sorry if it’s been talked about already).</p> <p>As for metadata, I had a hunch it might be useful so had been including it in some of my submissions – following Chris’s advice of a roughly 90/10 (image/meta) split. Shoutout to <a href="https://www.kaggle.com/titericz" target="_blank">@titericz</a> for his notebook, which worked very well for ensembling. I’d be interested to hear more from others who used metadata and how everyone incorporated it into their submissions.</p> <p>Thank you to the organisers and Kaggle fam for this wonderful competition. Here’s hoping for many more to come.</p> <p>Subs:</p> <table> <thead> <tr> <th>Sub</th> <th>No. of Effnets</th> <th>External Data</th> <th>Metadata</th> <th>Public LB</th> <th>Private LB</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>18</td> <td>Y</td> <td>N</td> <td>0.9521</td> <td>0.9408</td> </tr> <tr> <td>2</td> <td>18</td> <td>Y</td> <td>Y</td> <td>0.9535</td> <td>0.9434</td> </tr> <tr> <td>3</td> <td>45</td> <td>Y</td> <td>Y</td> <td>0.9447</td> <td>0.9344</td> </tr> <tr> <td>Unused smaller ensemble</td> <td>6</td> <td>Y</td> <td>Y</td> <td>0.9544</td> <td>0.9405</td> </tr> </tbody> </table>
Prostate cANcer graDe Assessment (PANDA) Challenge
5th place approach
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Prostate cANcer graDe Assessment (PANDA) Challenge <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>I've learned a bunch from this contest - big thanks to the organizers and all who took a shot at solving the problem, and congrats to the winners! My approach is nothing novel but here goes.</p> <h3>Models</h3> <p>My solution was an ensemble of semi-supervised ImageNet models based on @Iafoss' <a href="https://www.kaggle.com/iafoss/panda-concat-tile-pooling-starter-0-79-lb">concat tile pooling </a></p> <ul> <li>resnext50_32x4d_ssl: input 192x192, 256x256</li> <li>resnext50_32x4d_swsl: input size 384x384</li> </ul> <p>The only thing I changed was removing the final dropout layer and training the head for a few epochs before unfreezing the model. And of course @haqishen's genius <a href="https://www.kaggle.com/haqishen/train-efficientnet-b0-w-36-tiles-256-lb0-87">BCE loss</a>.</p> <h3>Data</h3> <p>I generated tile sizes 256 and 384 from the medium resolution based on @akensert's <a href="https://www.kaggle.com/akensert/panda-optimized-tiling-tf-data-dataset">optimized tiling</a>.</p> <p>There was a performance trade-off between selecting more tiles and larger batch size so I settled on randomly sampling <em>k</em> tiles from the top <em>N</em> tiles for each epoch.</p> <p>| model | input size | k | N | bs | ----- | --- | -- | -- | -- | resnext50_32x4d_ssl | 192 x 192 | 28 | 40 | 10 | resnext50_32x4d_ssl | 256 x 256 | 32 | 40 | 6 | resnext50_32x4d_swsl | 384 x 384 | 14 | 24| 6</p> <p>Training with a smaller size(128) seemed to overfit while the larger size(512) was unstable because I had to lower the batch size</p> <h3>Augmentations</h3> <p>Hue/saturation augmentations didn't improve CV so I stuck to affine transforms - rotations, flips, zoom, warp - all from the default fastai transforms. Randomly shuffling the tiles every other epoch also seemed to help.</p>
ALASKA2 Image Steganalysis
[9th place] Short summary
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: ALASKA2 Image Steganalysis <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Thanks to the hosts for this interesting competition and <a href="https://www.kaggle.com/christofhenkel" target="_blank">@christofhenkel</a> for the fun team!</p> <p>We are happy to make the jump on private LB which is as often is the case based on a strong blend that is not overfitting the public LB. That said, our best sub is both our best pub LB and private LB and we made the best selection.</p> <h3>Image norm</h3> <p>We observed slight differences in image channel distributions between train and test and doing local image normalization brought CV and LB closer together for us, which is why we sticked to it throughout our final models. That means we standardize each channel locally for each image.</p> <h3>Augmentations</h3> <p>Most models only use standard flips and transposes. Some models also add cutout and some add tiny random noise. For TTA we do either TTA4 or TTA8.</p> <h3>Models</h3> <p>We only use EfficientNets. We started fitting models only on fold 0, but then switched to fitting models "blindly" on full data as CV convergence always was stable for us. If we were unsure, we re-fitted on a fold on a new model and checked if the models overfit or not, and then trusted the full fits. This also meant that we had to blend a bit blindly though.</p> <p>We both fitted vanilla EfficientNets, but also got huge boosts on CV when changing the stride in the first layer to (1,1), as also other contestants did. This means that the models are fit for longer on the full resolution, and this is specifically helpful as a lot of information about the manipulation lies between neighboring pixels. We observed this facet also when randomly shuffling neighboring pixels in TTA and as soon as you shuffle further than one pixel away, the score deteriorates heavily.</p> <p>Our final sub consists of the following models:</p> <ul> <li>Vanilla EfficientNet B6 (one fold)</li> <li>Vanilla EfficientNet B8 (full data)</li> <li>Stride 1 EfficientNet B1 (full data)</li> <li>Stride 1 EfficientNet B2 (full data)</li> <li>Stride 1 EfficientNet B3 (full data)</li> </ul> <p>Unfortunately, we dont have the full logs plotted as some models finished on the last day, but this is how the training scores across models roughly look like (2x refers to stride 1 models):</p> <p><img src="https://i.imgur.com/ooXn6U9.png" alt=""></p> <p>You can see that B3 Stride 1 model was the best, also on a separate fit on CV. However, vanilla B6 model was the best on public LB, so things are a bit misleading there. On private LB actually B3 Stride 1 alone is our best one (925), followed by B8 (924) and so on. So actually matching the ranking on the plot above.</p> <h3>Fitting</h3> <p>All models are fitted over 40 epochs with cosine decay, AdamW, mixed precision, and varying batch sizes. We did not see changes in BS and LR to have much impact, which is why we basically left it untouched across models as we also did not have the time to tune it further.</p> <h3>Blending</h3> <p>Our final blend is composed of a 50-50 blend between (1) a blend between vanilla B6 and B8 (LB Score 936) and (2) a blend between epochs 30,35,39 of the B1,B2,B3 Stride 1 models (LB Score 935). The blend scored 937 on public LB and 928 on private LB.</p>
Prostate cANcer graDe Assessment (PANDA) Challenge
16th place solution
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Prostate cANcer graDe Assessment (PANDA) Challenge <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p><strong>Thank you very much to organizers, participants and my teammates</strong> <a href="/ryunosukeishizaki">@ryunosukeishizaki</a> <a href="/rinnqd">@rinnqd</a> for such competition.</p> <p>We can name our solution as <strong>"zero public LB to hero private LB"</strong>. In public we could even get a bronze and in private we are in top 20 teams. It's not a lucky submission because we have a lot of them and success points are real.</p> <ol> <li><p><strong>Removing noise</strong> (marks, duplicates) based on <a href="https://www.kaggle.com/c/prostate-cancer-grade-assessment/discussion/151323">this Zac Dannelly</a> and <a href="https://www.kaggle.com/iamleonie/panda-eda-visualizations-suspicious-data">this Leonie</a>, and also my own manual clean up</p></li> <li><p>Training efficientnet-b0, b2, b4 and mixnet-xl on <strong>different tiles sizes</strong> 36x256x256 (level 1) =&gt; 49x256x256 (level 1) =&gt; 64x256x256 (level 1) without regularization and with high (dropout 0.4)</p></li> <li><p><strong>Combining cleaning dataset training and raw data</strong></p></li> <li><p>Blending based on local <strong>CV weights</strong> w = w / np.sum(w)</p></li> </ol> <p><img src="https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1192776%2Fe5ab54359ade13256e9c62dbfdf5a80f%2F.PNG?generation=1595481733380627&amp;alt=media" alt=""></p> <p>5.<strong>Trust your local CV</strong> and train stable models!</p>
Cornell Birdcall Identification
17th Place Solution : file-level post-process
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Cornell Birdcall Identification <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p><a href="https://github.com/xins-yao/Kaggle_Birdcall_17th_solution" target="_blank">https://github.com/xins-yao/Kaggle_Birdcall_17th_solution</a></p> <h2>Feature Engineering</h2> <ul> <li>Log MEL Spectrogram</li> </ul> <pre><code>sr = 32000 fmin = 20 fmax = sr // 2 n_channel = 128 n_fft = 2048 hop_length = 512 win_length = n_fft </code></pre> <h2>Augment</h2> <ul> <li>Random Clip<br> randomly cut 5s clip from audio and only keep clips with SNR higher than 1e-3</li> </ul> <pre><code> def signal_noise_ratio(spec): spec = spec.copy() col_median = np.median(spec, axis=0, keepdims=True) row_median = np.median(spec, axis=1, keepdims=True) spec[spec &lt; row_median * 1.25] = 0.0 spec[spec &lt; col_median * 1.15] = 0.0 spec[spec &gt; 0] = 1.0 spec = cv2.medianBlur(spec, 3) spec = cv2.morphologyEx(spec, cv2.MORPH_CLOSE, np.ones((3, 3), np.float32)) spec_sum = spec.sum() try: snr = spec_sum / (spec.shape[0] * spec.shape[1] * spec.shape[2]) except: snr = spec_sum / (spec.shape[0] * spec.shape[1]) return snr </code></pre> <ul> <li>MixUp<br> mixup over LogMelSpec with beta(8.0, 8.0) distribution<br> beta(0.4, 0.4) and beta(1.0, 1.0) will raise more TruePositive but lead to much more FalsePositive</li> <li>Noise<br> add up to 4 noises with independent probabilities and scales in waveform<br> noises were extracted from training samples</li> </ul> <pre><code> def signal_noise_split(audio): S, _ = spectrum._spectrogram(y=audio, power=1.0, n_fft=2048, hop_length=512, win_length=2048) col_median = np.median(S, axis=0, keepdims=True) row_median = np.median(S, axis=1, keepdims=True) S[S &lt; row_median * 3] = 0.0 S[S &lt; col_median * 3] = 0.0 S[S &gt; 0] = 1 S = binary_erosion(S, structure=np.ones((4, 4))) S = binary_dilation(S, structure=np.ones((4, 4))) indicator = S.any(axis=0) indicator = binary_dilation(indicator, structure=np.ones(4), iterations=2) mask = np.repeat(indicator, hop_length) mask = binary_dilation(mask, structure=np.ones(win_length - hop_length), origin=-(win_length - hop_length)//2) mask = mask[:len(audio)] signal = audio[mask] noise = audio[~mask] return signal, noise </code></pre> <h2>Model</h2> <ul> <li>CNN<br> 9-layer CNN<br> average pooling over frequency before max pooling over time within each ConvBlock2D<br> SqueezeExcitationBlock within each ConvBlock2D<br> pixel shuffle: (n_channel, n_freq, n_time) -&gt; (n_channel * 2, n_freq / 2, n_time)</li> <li>CRNN<br> 2-layer bidirectional GRU after 9-layer CNN</li> <li>CNN + Transformer Encoder<br> Encoder with 8-AttentionHead after 9-layer CNN</li> </ul> <h2>Trainng</h2> <ul> <li>Label Smooth: 0.05 alpha</li> <li>Balance Sampler: randomly select up to 150 samples of each bird</li> <li>Stratified 5Fold based on ebird_code</li> <li>Loss Function: BCEWithLogitsLoss</li> <li>Optimizer: Adam(lr=1e-3)</li> <li>Scheduler: CosineAnnealingLR(Tmax=10)</li> </ul> <h2>Post-Process</h2> <p>if model gets a confident prediction of any bird, then lower threshold for this bird in the same audio file</p> <ul> <li>use thr_median as initial threshold</li> <li>use thr_high for confident prediction</li> <li>if any bird with probability higher than thr_high in any clip, lower threshold to thr_low for this specific bird in the same audio file</li> </ul>
Halite by Two Sigma
Team 677's Post-Mortem Writeup (29th Place)
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Halite by Two Sigma <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Hey everyone! Our team has finally finished our post-mortem writeup. You can check it out on Github <a href="https://github.com/josgoo/Halite" target="_blank">here</a>. We spent some time discussing the bot implementation, but we also devoted a section to the things we learned about approaching these kinds of coding competitions from the start---this was our team's first ever competition, so we hope our takeaways can help advise others getting started for the first time!</p> <p>Thanks again to Two Sigma and Kaggle for hosting such an awesome competition, and to our fellow competitors for their interesting writeups. We can't wait for the next one 😃</p>
SIIM-ISIC Melanoma Classification
241st place (bronze) solution (+ GitHub) with batch sampling
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: SIIM-ISIC Melanoma Classification <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Hey guys, I felt 93 positions after the shakedown, but still managed to get a bronze, was not a very good placing but still think would be nice to share my solution and experiments at my <a href="https://github.com/dimitreOliveira/melanoma-classification" target="_blank">Git</a> in case anyone is interested in taking a look.</p> <p>My best solution from the 3 chosen, was the one that according to my experiment had the best CV values, so trusting my CV helped me here. Basically it was a weighted average using exponential log like some people also did.</p> <h4>Models</h4> <ul> <li>1x EfficientNet B4 384x384</li> <li>3x EfficientNet B4 512x512</li> <li>1x EfficientNet B5 512x512</li> </ul> <p>They were training using one augmentation pipeline and predicted using a lighter one (with out Cutout and shear), all using the data provide by Chris<br> All models were very simple just a regular AVG pooling and dense head, label smoothing of 0.05, and Adam optimizer, one model example:</p> <pre><code>def model_fn(input_shape=(256, 256, 3)): input_image = L.Input(shape=input_shape, name='input_image') base_model = efn.EfficientNetB4(input_shape=input_shape, weights=config['BASE_MODEL_WEIGHTS'], include_top=False) x = base_model(input_image) x = L.GlobalAveragePooling2D()(x) output = L.Dense(1, activation='sigmoid', kernel_initializer='zeros', name='output')(x) model = Model(inputs=input_image, outputs=output) opt = optimizers.Adam(learning_rate=config['LEARNING_RATE']) loss = losses.BinaryCrossentropy(label_smoothing=0.05) model.compile(optimizer=opt, loss=loss, metrics=['AUC']) return model </code></pre> <h4>Training</h4> <p>One thing that worked very well for me was using upsampling, but in my case, I did in a way that I did not see people doing, I used <code>tf.data.experimental.sample_from_datasets</code> to sample from 2 different datasets, one was the regular data (2020 + 2018 + 2017) and the other was just malignant samples (all sets), then I used the weights <code>[0.6, 0.4]</code> this way <code>40%</code> of the data were only malignant for every batch, this made the models converge faster.<br> Used only TPUs, both from Kaggle and Colab<br> Also, I got better results using a cyclical cosine learning rate with warm restarts and warm-up, shown below.<br> <img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1182060%2Fa0849f9196f11493360c242a33cb1edc%2Fdownload.png?generation=1597710718834670&amp;alt=media" alt=""></p> <p>Here is a fold training history for illustration.<br> <img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1182060%2Fa488650b5cde87105510c0ed5c317a90%2Fhistory_fold2.png?generation=1597710894876834&amp;alt=media" alt=""></p> <p>Here is the link to <a href="https://github.com/dimitreOliveira/melanoma-classification" target="_blank">my Github</a>, there you will find all my models, <a href="https://github.com/dimitreOliveira/melanoma-classification/tree/master/Model%20backlog" target="_blank">its scores</a>, EDAs, scripts and a <a href="https://github.com/dimitreOliveira/melanoma-classification/tree/master/Documentation" target="_blank">page with all relevant content</a> that I gathered during the competition.</p> <p>About this competition, it was a great opportunity to experiment a little more with TPUs and TensorFlow, especially with the dataset API, I feel that a should join another computer vision competition to do some more practice. <br> I tried a lot to make BiT(Big transfer) work but had no success, I got good results with Cutout, was getting close to making MixUp work good here but had no time left.</p> <p>I tweaked a lot my augmentations pipeline and this was what roughly what gave me best results:</p> <pre><code>def data_augment(image): p_rotation = tf.random.uniform([], 0, 1.0, dtype=tf.float32) p_rotate = tf.random.uniform([], 0, 1.0, dtype=tf.float32) p_cutout = tf.random.uniform([], 0, 1.0, dtype=tf.float32) p_shear = tf.random.uniform([], 0, 1.0, dtype=tf.float32) p_crop = tf.random.uniform([], 0, 1.0, dtype=tf.float32) if p_shear &gt; .2: if p_shear &gt; .6: image = transform_shear(image, config['HEIGHT'], shear=20.) else: image = transform_shear(image, config['HEIGHT'], shear=-20.) if p_rotation &gt; .2: if p_rotation &gt; .6: image = transform_rotation(image, config['HEIGHT'], rotation=45.) else: image = transform_rotation(image, config['HEIGHT'], rotation=-45.) if p_crop &gt; .2: image = data_augment_crop(image) if p_rotate &gt; .2: image = data_augment_rotate(image) image = data_augment_spatial(image) image = tf.image.random_saturation(image, 0.7, 1.3) image = tf.image.random_contrast(image, 0.8, 1.2) image = tf.image.random_brightness(image, 0.1) if p_cutout &gt; .5: image = data_augment_cutout(image) return image </code></pre> <p>I would like to thank the community for all the helpful discussion and work shared and give a special thanks to <a href="https://www.kaggle.com/cdeotte" target="_blank">@cdeotte</a> for his amazing contributions to us all during the competition, this was a great learning opportunity.</p>
ALASKA2 Image Steganalysis
[ABBA McCandless] - 2nd place solution overview
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: ALASKA2 Image Steganalysis <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>A summary of our solution - 0.945/0.932 (Public/Private)</p> <p><strong>In short</strong>: Trust your CV</p> <p>I used 4 folds stratified by image size and quality factor with 20k holdout (5K Cover + 15K corresponding positive images). My team has a different split w/o folds but also with a holdout. We used the ranked average of second-level stacking (CatBoost and XGBoost) to blend individual models into ensembles and merge their predictions.</p> <p><strong>Models</strong> I used only B6/B7, and my teammates had B4/B5/B6/B7/MixNet plus SRNet and some hand-crafted features from "classical" steganalysis. I trained my models on RGB input (using cv2.imread) and then fine-tuned on non-rounded RGB images (by manually decoding DCT-&gt;YCbCr -&gt; RGB omitting rounding step). Lastly, I replaced Swish activation to Mish, which improved every model's score in my ensemble by +0.00044 on average.</p> <p><strong>Augmentations</strong> Like probably everyone, I've used D4 augmentations with coarse dropout for the training and D4 augmentations during the inference.</p> <p><strong>Losses</strong> I trained two heads for my models to predict binary (cover/stego) and multi-class (4 classes) outcomes. Based on early experiments, this showed to work well and speed up the convergence a little. I've played with different loss functions, including weighted BCE/CE, focal loss, and directly optimizing RoC AUC. But plain BCE/CE proved to work the best.</p> <p><strong>Ensembling</strong> For ensembling I had tested many ideas, but the final solution was to train XGBoost classifier using predictions of my B6/B7 models. Second level stacking was done using holdout predictions. The feature matrix was 20000x380 made from binary and multi-class outputs, and all intermediate logits from TTA). I ran 5-fold cross-validation using groupkfold split on image_id to find the best hyperparameters for XGboost, and that was my ensemble.</p> <p>My team made a similar approach to their model zoo but trained CatBoost stacker. We selected our ensembles for the final blend based on individual CV scores and Spearman correlation. The lower correlation factor - the higher LB score on the public we had.</p> <p>To come to this solution, it took almost two months. There have been dozens of unsuccessful training runs and experiments on this way to gold. To name a few: * Training models on DCT input (Didn't even pass 0.92) * Training ResNet and DenseNet family (Barely reached 0.935 LB) * Training model to always have Cover + Stego image pair in batch * Direct Roc AUC optimization * Metric learning with ArcFace * Training with extra data (iStego 100K) * B0-B7, Heavier models performed better * Training stacking model on embeddings * Training on TPU. In general, it worked, but Kaggle TPU machine is limited in its CPU/RAM, so the training speed was deficient. </p>
Cornell Birdcall Identification
2nd place solution
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Cornell Birdcall Identification <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Hi. This is my first Kaggle competition, and I really enjoyed participating.<br> Thank you to the organizers for an interesting competition, <a href="https://www.kaggle.com/hidehisaarai1213" target="_blank">@hidehisaarai1213</a> for the basic solution, and to all the teams for an interesting and intense fight.</p> <h1>My decision</h1> <p><strong>github</strong>: <a href="https://github.com/vlomme/Birdcall-Identification-competition" target="_blank">https://github.com/vlomme/Birdcall-Identification-competition</a><br> <strong>datasets</strong>: <a href="https://www.kaggle.com/vlomme/my-birdcall-datasets" target="_blank">https://www.kaggle.com/vlomme/my-birdcall-datasets</a><br> <strong>kaggle notebook</strong>: <a href="https://www.kaggle.com/vlomme/surfin-bird-2nd-place" target="_blank">https://www.kaggle.com/vlomme/surfin-bird-2nd-place</a></p> <ul> <li>Due to a weak PC and to speed up training, I saved the Mel spectrograms and later worked with them</li> <li><strong>IMPORTANT</strong>! While training different architectures, I manually went through 20 thousand training files and deleted large segments without the target bird. If necessary, I can put them in a separate dataset.</li> <li>I mixed 1 to 3 file</li> <li><strong>IMPORTANT</strong>! For contrast, I raised the image to a power of 0.5 to 3. at 0.5, the background noise is closer to the birds, and at 3, on the contrary, the quiet sounds become even quieter.</li> <li>Slightly accelerated / slowed down recording</li> <li><strong>IMPORTANT</strong>! Add a different sound without birds(rain, noise, conversations, etc.)</li> <li>Added white, pink, and band noise. Increasing the noise level increases recall, but reduces precision.</li> <li><strong>IMPORTANT</strong>! With a probability of 0.5 lowered the upper frequencies. In the real world, the upper frequencies fade faster with distance</li> <li>Used BCEWithLogitsLoss. For the main birds, the label was 1. For birds in the background 0.3.</li> <li>I didn't look at metrics on training records, but only on validation files similar to the test sample (see dataset). They worked well.</li> <li>Added 265 class nocall, but it didn't help much</li> <li>The final solution consisted of an ensemble of 6 models, one of which trained on 2.5-second recordings, and one of which only trained on 150 classes. But this model did not work much better than an ensemble of 3 models, where everyone studied in 5 seconds and 265 classes.</li> <li>My best solution was sent 3 weeks ago and would have given me first place=)</li> <li>Model predictions were squared, averaged, and the root was extracted. The rating slightly increased, compared to simple averaging.</li> <li>All models gave similar quality, but the best was efficientnet-b0, resnet50, densenet121.</li> <li>Pre-trained models work better</li> <li>Spectrogram worked slightly worse than melspectrograms</li> <li>Large networks worked slightly worse than small ones</li> <li>n_fft = 892, sr = 21952, hop_length=245, n_mels = 224, len_chack 448(or 224), image_size = 224*448</li> <li><strong>IMPORTANT</strong>! If there was a bird in the segment, I increased the probability of finding it in the entire file.</li> <li>I tried pseudo-labels, predict classes on training files, and train using new labels, but the quality decreased slightly</li> <li>A small learning rate reduced the rating</li> </ul> <p>I'll try writing more later here or on GitHub. I will be happy to answer your questions, because I almost didn't sleep and forgot to write a lot</p>
Halite by Two Sigma
17th Solution
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Halite by Two Sigma <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Hello everyone and congrats for all participants!!</p> <p>We want to share our team solution which is placed 17th. Our team "team-tokai" consists of minaminao( <a href="https://www.kaggle.com/mnmnao" target="_blank">@mnmnao</a> ), yasagure( <a href="https://www.kaggle.com/yasagure" target="_blank">@yasagure</a> ), and Johannes( <a href="https://www.kaggle.com/johannesmdr" target="_blank">@johannesmdr</a> ).</p> <h2>Table of Contents</h2> <ul> <li><a href="#approaches">Approaches</a></li> <li><a href="#our-strategy">Our Strategy</a><ul> <li><a href="#1-100-steps-collect-halite-and-make-ships-aggressively">1-100 steps: Collect halite and make ships aggressively</a></li> <li><a href="#101-300-steps-attack-opponents-do-not-collect-too-many-halite-make-ships">101-300 steps: Attack opponents, do not collect too many halite, make ships</a></li> <li><a href="#301-400-steps-mining-halite-aggressively-not-making-ships">301-400 steps: Mining halite aggressively, not making ships</a></li> <li><a href="#minimum-cost-flow">Minimum cost flow</a><ul> <li><a href="#optimal-matching-of-ships-and-target-cells">Optimal matching of ships and target cells</a></li> <li><a href="#optimal-matching-of-ships-and-next-cells">Optimal matching of ships and next cells</a></li></ul></li> <li><a href="#prevent-our-bases-from-destroyed">Prevent our bases from destroyed</a></li> <li><a href="#set-up-bases-to-increase-the-area-of-our-position">Set up bases to increase the area of our position</a></li></ul></li> <li><a href="#afterword">Afterword</a></li> <li><a href="#code">Code</a></li> <li><a href="#Japanese-version">Japanese version</a></li> </ul> <h2>Approaches</h2> <p>There are two types of algorithmic approaches: using/not using reinforcement learning. We knew that reinforcement learning is not suitable for some games, so early in the competition, we spent a lot of time "understanding the nature of Halite games" and "systematizing the cases where reinforcement learning works" to determine if reinforcement learning makes sense as a problem solver.</p> <p>We concluded that it was going to be a big swamp to work on reinforcement learning, and we chose not to use reinforcement learning. The main reasons were "the size of the player's action space" and "the difficulty of seeking <em>global</em> optimization". For example, with 30 ships, there are 6^30 action patterns per turn; even in Go, where AlphaGo is active, there are only a few hundred options per turn at most.</p> <p>To solve this large action space, it seems reasonable to take a ship-by-ship reinforcement learning approach. However, while we may be able to seek a per-ship optimum, it is difficult to seek a holistically optimal action that takes into account all ships, leading us to believe that considerable effort would be required to go beyond a non-reinforcement learning approach.</p> <p>On the other hand, in the last Halite competition (with slightly different rules than this one), some teams had done well in reinforcement learning, so we decided not to abandon reinforcement learning altogether, and our team member Johannes decided to continue to stick with it from the middle of the competition onwards.</p> <h2>Our Strategy</h2> <p>There are six key points in our strategy.</p> <ol> <li>Aggressively mine halite until 100 steps. If we can make ships, make them.</li> <li>From 101 to 300 steps, attack opponents and do not collect too many halites. If we can make ships, make them.</li> <li>From 301 steps onwards, we should collect halites aggressively. Do not make ships.</li> <li>Solve for two stages of matching, "optimal matching between ship and target cell" and "optimal matching between ship and next turn cell", with minimum cost flow.</li> <li>Locate the ship at the base and do not let the base be destroyed.</li> <li>Set up bases to increase the area of the position.</li> </ol> <h3>1-100 steps: Collect halite and make ships aggressively</h3> <p>Like many of the top teams, we generated ships as soon as possible. The earlier you generate ships, the better, and as we will see below, the more ships you have, the better the advantage you have when attacking our opponents. Therefore, storing halite at the beginning of the game is a bad idea, and it is important to create more ships in the beginning of the game while collecting halite efficiently.</p> <h3>101-300 steps: Attack opponents, do not collect too many halite, make ships</h3> <p>Around 100th step, the halite is nearly exhausted. This is the so-called "tragedy of the common ground". We will also have about 20 ships (if each players' abilities are balanced).</p> <p>From here, the strategy of destroying our opponents' ships is advantageous, as there is little to be gained by mining halite. Generating a ship need 500 halite, so destroying a ship will cost the attacking player about 500 halite. We attacked an opponent's ship with maximum of four ships, as attacking with multiple ships is much more likely to get the enemy ship out of position than attacking with a single ship.</p> <p>It is also advantageous to avoid mining halites as much as possible, because if we collect halites, they will become a target of attack. If we collect them in a cell far away from the base, they have a higher chance of being destroyed. We avoided collecting halites in cells at a certain distance from the base.</p> <p>To avoid mining halite has another purpose: regenerating the amount of halite. Mining halite in moderation prevents halite depletion.</p> <h3>301-400 steps: Mining halite aggressively, not making ships</h3> <p>By step 300, the number of opponents' ships will be decreasing. Also, by attacking and not mining too much halite around our base, the halite will have been stored in place. We mined these halite all at once.</p> <p>Ship creation is stopped. Even if you create a new ship, it is difficult to collect 500 halite from that ship.</p> <h3>Minimum cost flow</h3> <p>We resolved matching problems by using minimum cost flow. This is a familiar mathematical optimization problem in competition programming.<br> We have used this algorithm in two stages as follows.</p> <h4>Optimal matching of ships and target cells</h4> <p>Mining halite should be considered several turns ahead of arriving at the target cell. Since each ship has a different distance to each cell and a different amount of halite in its possession, optimal matching of ships and target cells is important. Depending on the matching, we can solve following all bad moves at once.</p> <ul> <li>Send multiple ships to the same cell.</li> <li>There are ships that arrive earlier.</li> <li>Collide with our own ships.</li> </ul> <p>The latter two are particularly difficult to deal with the method of determining the target cell by turning a loop for each ship.</p> <p>Each ship requires each cell to be evaluated as follows:</p> <ol> <li><p>In the event of a collision, our ship will be defeated and the cell with the enemy ship and the four squares around it will be forbidden to move. Using a width-first search to find the shortest path for each cell.</p></li> <li><p>Using the shortest path, find out for each cell "how many turns it is necessary to stay in the cell and return to the nearest base in order to maximize the average amount of halite acquired in one turn". Here, we also take into account returning to the base.</p> <ul> <li>Same technique as in the notebook <a href="https://www.kaggle.com/solverworld/optimus-mine-agent" target="_blank">Optimus Mine Agent</a>.</li> <li>However, there is room for improvement because this logic does not take into account mining halite from more than one cell.</li> <li>From 101 to 300 steps, if there are enemy ships in the cell, the halite held by the enemy ships is added to the evaluation.</li></ul></li> <li><p>Take that average amount of halite gained as the evaluation value for each cell.</p></li> </ol> <p>The minimum cost flow based on this evaluation gives the overall optimal ship-target cell combination.</p> <h4>Optimal matching of ships and next cells</h4> <p>After finding the target cell, we want to find the next cell to move for each ship (next cell). We considered the cell you are in and 4 cells around you. Find the shortest distance to get to the target cell, and the smaller the distance, the better the evaluation value. However, a cell that can be moved in a single turn by an enemy ship that could be destroyed if our ships collide with it makes for an extremely poor rating.</p> <p>The minimum cost flow based on this evaluation gives the overall optimal ship/next-turn cell combination. Due to the way the flow edges are stretched, our ships will not collide with each other.</p> <h3>Prevent our bases from destroyed</h3> <p>Some opponents attacked our bases. If a base is destroyed, it will cause a lot of damage for two reasons.</p> <ol> <li>To create a base, you need to generate a ship from our base and convert it from a ship to a base, which requires 1000 halite in total.</li> <li>We are making all sorts of logics on the basis of having bases.</li> </ol> <p>We solved this problem by placing ships on top of the base at all times.</p> <h3>Set up bases to increase the area of our position</h3> <p>In the middle steps of the game, we must prevent regenerating halite from mined by enemy ships. Even if an enemy ship enters our position and collects our halite, it will be easier to surround and destroy the enemy ship.</p> <h2>Afterword</h2> <p>We also implemented a few other minor algorithms, but we won't go into those. Early in the contest, we introduced an algorithm that uses a two-step minimum cost flow. We think this algorithm was easy to combine with other logic and worked well until the end. We regret that we did not apply reinforcement learning well!</p> <h2>Code</h2> <p><a href="https://gist.github.com/minaminao/cbe4a3d514ea9ae924cb5d59181d78cc" target="_blank">Here</a> is our final code. There are some Japanese comments;)</p> <h2>Japanese version</h2> <p><a href="https://minaminao.com/halite-by-two-sigma/" target="_blank">Here</a> is our solution in Japanese!</p>
Global Wheat Detection
[16th place solution]
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Global Wheat Detection <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Thanks to the organizers for this interesting competition! Thanks to my teammates @vandesa003 @kevinzc @xiaoyushowyou2 @karkin96 . Congratulation to all!</p> <h2>Summary</h2> <ul> <li>Data Augmentation: MultiScale, Mosaic, Mixup, RandomCrop, Cutout, Hue, Brightness, CLAHE, RGBShift, RandomGamma, ToGray, Horizontal and Vertical Flip, Rotate90 </li> <li>Backbone: ResNeSt 101, ResNeXt 101 DCNv2</li> <li>Neck: FPN </li> <li>Head: ATSS</li> <li>Loss: Quality Focal Loss + DIOU Loss </li> <li>5x TTA (origin, HorizontalFLIP, VerticalFLIP, ROTATE90, Rotate270) + WBF </li> <li>2 models ensemble with WBF</li> <li>2 rounds Pseudo Label</li> </ul> <h3>1. Data Split</h3> <p>We shuffle the train dataset and split to fixed training set and validation set from the beginning of the competition. About 260 images for validation, others are used for training. </p> <h3>2. Model Training</h3> <p>We train a ResNeSt 101 and a ResNeXt 101 DcnV2 model for model ensembling. The neck part I tried PAFPN and SEPC, but they didn't work. So we use FPN as the simple neck part. The model heads are both ATSS, because it's quite good performance. And we use the DIOU Loss for box regression and use Quality Focal Loss (<a href="https://arxiv.org/pdf/2006.04388.pdf">https://arxiv.org/pdf/2006.04388.pdf</a>) for classification. I also tried the Distributed Focal Loss in QFL paper. It worked well in COCO dataset. But it didn't work for this dataset. What's more, we adjust the anchor boxes from 8 * strides to 6 * strides. Because the boxes in this dataset are smaller than COCO according to the statistics. We use COCO pretrained models and traing with an input size of 1024, batch size 8, SGD optimizer, 36 epochs for both of these two models. </p> <h3>3. Model Inference</h3> <p>We use 5x TTA as listed above. The TTA results are merged by WBF. And the two models outputs are also merged by WBF. Besides, 2 rounds Pseudo Lable are applied for the ResNeSt model. We also tried to apply PL to the DcnV2 model at the same time. But the score droped down comparing with only RS model PL. We guessed that it's caused by the hyperparameters. There are too many inference hyperparameters, such as model score threshold, nms threshold, wbf threshold, pseudo label score threshold and so on. For avoiding over toggling in public test dataset, we only coarsely tuned it according to our knowledge and COCO using.</p> <h3>4. Final Plan</h3> <p>ResNeSt + DcnV2 Ensemble -&gt; ResNeSt Pseudo Label training -&gt; ResNeSt' + DcnV2 Ensemble -&gt; ResNeSt PL training -&gt; ResNeSt'' + DcnV2 Ensemble</p> <p>Public Score: 0.7672 Private Score: 0.7125</p>
ALASKA2 Image Steganalysis
congrats to Guanshuo Xu! and [14th place] solution
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: ALASKA2 Image Steganalysis <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>This was a nice competition with lots of ideas and sharing on the forums - thank you to kaggle and the organisers for hosting it. </p> <p>I would like to congratulate my colleague (at <a href="https://www.h2o.ai/" target="_blank">h2o.ai</a>) ,<a href="https://www.kaggle.com/wowfattie" target="_blank">Guanshuo Xu</a> <strong>for winning the competition and for becoming the new kaggle #1</strong>. It takes a lot of hard work and dedication to achieve this - well done!</p> <p>My solution is fairly simple. Where I think I did really well is I never became emotional and never tried things that I did not see them working in validation first. </p> <p>I used a single holdout (20%) for validation (stratified by type) . I trained 2 models - an EfficientNet b3 and b4 on the training (80%) part of the data AND 2 more models on 100% of the data. So 4 models in total. Using a cosine learning schedule, all models (small and full ones), had very similar behaviour. </p> <p>I generated multiple checkpoints predictions (over 10) from each one of these models. I progressively added more augmetations, swapped optimizers , (lowered) learning rates and batch sizes. I would make changes every-time I would see the validation performance getting halted. Every single time, I did get improvements from these swaps. In total, I trained the b3 model for 150 epochs and the b4 120 epochs. </p> <p>Augmentations in stages:</p> <ul> <li>Vertical and horizontal flips</li> <li>Vertical and horizontal + transpose + rotate</li> <li>Vertical and horizontal + transpose + rotate + cutout (1 hole, 80)</li> <li>Vertical and horizontal + transpose + rotate + cutout (2 holes, 64)</li> <li>Vertical and horizontal + transpose + rotate + cutout (4 holes, 64) </li> </ul> <p>For TTA I used Vertical , horizontal and Vertical + horizontal </p> <p>my models are all in pytorch . At some point, I tried to run EfficientNetb3 in keras (TF) with same batch size, optimmizers and augmentations and performance was significantly worse (not sure why) .</p> <p>I got a lot of gain from stacking - around +0.003-4 in LB. For test predictions in stacking, I had 25% the predictions generated from the small(80%) model and 75% of the model trained with 100% of the data. </p> <p>NN with 2 hidden layers, leakyrelu and a bit of l2 regularization had the best cv for me (0.936). <a href="https://lightgbm.readthedocs.io/en/latest/Parameters.html" target="_blank">Lightgbm </a>with dart was a close second. <a href="http://scikit-learn.org/stable/modules/generated/sklearn.ensemble.ExtraTreesClassifier.html" target="_blank">EextraTreesClassificer </a> added a little bit too. </p>
Global Wheat Detection
Would-be 39th place solution with single model (yolov4) from a first time competitor
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Global Wheat Detection <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><h2>Introduction and thanks</h2> <p>My team used both Effdet and YOLOv4 (though our final submissions were both Effdet). I focused on YOLOv4 so I will do a bit of a write up from my side. I started the competition about 2 weeks before the end after beginning learning machine learning in March. </p> <p>Thanks to my team for supporting me throughout this competition even though I was underqualified and helping me debug. Thanks to Hawkey and NVNN for their YOLOv5 Pseudolabelling/OOF evaluation notebook, pabloberhauser for his notebook converting label formats to yolov4, and Mark Peng for precompiling Darknet binaries to work on the Kaggle enviornment. </p> <h2>Training</h2> <p>I used AlexeyAB's <a href="https://github.com/AlexeyAB/darknet" target="_blank">Darknet</a> to train. Using Colab Pro, the maximum image size I could get with reasonable speed was 704x704, batch size of 64, 32 subdivisions, and 94 epochs (6000 batches). All other parameters were the default given by Darknet, only adjusting filter, steps, etc. in order to train with 1 label. Training on Darknet was quite simple since it handles CV and augmentations automatically. However, labels need to be converted to txt files. I used <a href="https://www.kaggle.com/pabloberhauser/creating-label-files-for-use-in-yolov4" target="_blank">Pabloberhauser's notebook</a> to do this. This baseline alongside WBF over TTA gets a score of only about 0.7115 public and 0.6371 private. <a href="https://www.kaggle.com/stanleyjzheng/yolov4-wbf-inference?scriptVersionId=39789314" target="_blank">The WBF over TTA inference notebook is here</a>. I experimented lots with the training; I tried modifying anchors so that they were the same as yolov5, cutmix, but none of it worked as well as default on CV. </p> <h2>Pseudolabelling</h2> <p>I used NVNN's YOLOv5 notebook with Hawkey's OOF evaluation. For inference, I used <a href="https://github.com/Tianxiaomo/pytorch-YOLOv4" target="_blank">PytorchYOLOv4</a> to convert the .weights saved model generated by Darknet into a Pytorch file for inference. I had tons of issues with training pseudolabels however. PytorchYOLOv4 was not very robust, and gave me errors randomly. After a few PR and the deadline fast approaching, I tried using Darknet to train. Libcuda.so is inaccessible on Kaggle environments, so Darknet would not compile either. Many thanks for Mark Peng for precompiling Darknet for use with Kaggle. Finally, we used Darknet to train pseudolabels. </p> <p>The precompiled Darknet did not have OpenCV, so we could not use mosaic. Therefore, we had to be very careful with overfitting to the pseudolabels. We used the same config as the training above, but only 800 batches (12 epochs). Then, we performed bayesian optimization and TTA over WBF for our final submissions. The best submission was 0.7406 on public LB and 0.6625 on private LB. </p> <p><a href="https://www.kaggle.com/stanleyjzheng/yolov4pl-oof?scriptVersionId=40172709" target="_blank">Here is the notebook</a></p> <h2>Final Remarks</h2> <p>This methodology can definitely be improved. However, with how long it took to train a model (About 28 hours on a P100 on Colab Pro at 704x704 resolution) and the short timeline I had (2 weeks), I feel this is a pretty good solution. Once late submissions open up, I plan on testing other models as well as an ensemble with effdet. </p> <p>On a more personal note, this whole competition has been a long journey that has felt like ages. I'm 16, and really turned myself around at the start of quarantine to begin learning machine learning. I discovered Kaggle only 3 months ago, and was super surprised by the community; the community is so generous with sharing knowledge and code. I feel so proud of getting my first medal in my first competition. I hope this write-up can be inspiring as notebooks from the likes of Chris Deotte and Alex Shonenkov. Thanks to everyone!</p>
Google Landmark Retrieval 2020
5th place solution write-up
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Google Landmark Retrieval 2020 <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>I would like to thank my teammate <a href="https://www.kaggle.com/aerdem4" target="_blank">@aerdem4</a> for his work, discussions and ideas throughout this challenge, our first team-up turned out to be quite successful ✊. Congratulations to all the winning teams and solo winners ! Finally, many thanks to the organizers and Kaggle for hosting this interesting competition.<br> Our final submission consisted of 4 models from two different architectures (gempool cnn and delg). </p> <p><strong>1. Data pre-processing</strong></p> <ul> <li>Training only on clean train set (81313 classes), validation by computing global average precision metric on a subset of 120000 images (having overlapping classes with train set) randomly sampled from the index set.</li> <li>Data augmentations: resize image longer side to [544, 672] then random crop 512x512, RandAugment + Cutout.</li> </ul> <p><strong>2. Modeling</strong></p> <ul> <li>Two architectures: CNN (with SEResNeXt50, SEResNeXt101 and ResNeXt101-32x4d as backbones) with CosFace head, and DELG (re-implemented in PyTorch, with SEResNet101 as backbone).</li> <li>Generalized mean pooling with frozen p set to 3 was used; bottleneck structure (GEMPool(2048) -&gt; Linear(512) -&gt; BatchNorm1d -&gt; CosFace(81313)) to reduce computation. </li> <li>Models were trained either in 10 or 20 epochs with AdamW optimizer and warm-up cosine annealing scheduler.</li> <li>Focal loss and label smoothing were better than cross entropy loss</li> </ul> <p><strong>3. Inference</strong></p> <ul> <li>Features (512-dim) extracted at scale 1 for each model.</li> <li>Concatenate 4 models’ features into a 2048-dim vector.</li> <li>Kernel runtime: 8 hour 20 minutes</li> </ul> <p><strong>4. Public/Private performance</strong></p> <table> <thead> <tr> <th>Methods</th> <th>Epochs</th> <th>Public</th> <th>Private</th> </tr> </thead> <tbody> <tr> <td>resnext101 gem</td> <td>20</td> <td>0.34596</td> <td>0.31024</td> </tr> <tr> <td>seresnext50 gem</td> <td>20</td> <td>0.3349</td> <td>0.29811</td> </tr> <tr> <td>seresnext101 gem</td> <td>20</td> <td>0.34749</td> <td>0.31282</td> </tr> <tr> <td>seresnet101 delg</td> <td>10</td> <td>0.336</td> <td>0.29882</td> </tr> <tr> <td>ensemble</td> <td></td> <td>0.36644</td> <td>0.32878</td> </tr> </tbody> </table> <p><strong>5. Ablations on DELG vs GEM</strong><br> We used SEResNeXt50 for all experiments in this section. </p> <table> <thead> <tr> <th>Methods</th> <th>Epochs</th> <th>Public</th> <th>Private</th> </tr> </thead> <tbody> <tr> <td>gem</td> <td>10</td> <td>0.32163</td> <td>0.28434</td> </tr> <tr> <td>gem + self attention block after res5</td> <td>15</td> <td>0.32006</td> <td>0.28187</td> </tr> <tr> <td>gem + online hard neg mining</td> <td>15</td> <td>0.32357</td> <td>0.28687</td> </tr> <tr> <td>gem + focal loss</td> <td>20</td> <td>0.32634</td> <td>0.29054</td> </tr> <tr> <td>delg + focal loss</td> <td>20</td> <td>0.32928</td> <td>0.29263</td> </tr> <tr> <td>gem + focal loss + cutout</td> <td>20</td> <td>0.3349</td> <td>0.29811</td> </tr> </tbody> </table> <p><strong>6. Things that didn't work for us</strong></p> <ul> <li>Pre-training on v1 dataset hurt.</li> <li>Training on concatenated v1 and v2 data.</li> <li>Earlier, I trained an EfficientNet B3 and found out that given the same training configs/ epochs, it performed worse than my baseline ResNet50 (which scored 0.299 on public LB). EfficientNets seem to only work well when you train them long enough with hard augmentations. After reading the 1st place solution, I know which experiment I'm gonna run next for the recognition challenge 😁</li> </ul>
Google Landmark Retrieval 2020
2nd place solution summary
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Google Landmark Retrieval 2020 <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p><strong>[update]</strong><br> add google driver download link: <br> <a href="https://drive.google.com/file/d/1XnzxMOHhzua9tjrAjo-X55ieKVJzRJw_/view?usp=sharing" target="_blank">https://drive.google.com/file/d/1XnzxMOHhzua9tjrAjo-X55ieKVJzRJw_/view?usp=sharing</a><br> <strong>[update]</strong><br> submission to arxiv is on hold. We provide detailed information in pdf file, download link: <a href="https://vis-bj.bj.bcebos.com/landmark/landmark2020_retrieval.pdf" target="_blank">https://vis-bj.bj.bcebos.com/landmark/landmark2020_retrieval.pdf</a></p> <p><strong>Method:</strong><br> Our retrieval method for this competition is depicted in Figure 1. We mainly train two models for final submission and each model includes a backbone model for feature extraction and a head model for classification. ResNeSt2692 and Res2Net200 vd are selected as the backbone model since their good performance on ImageNet. Head model includes a pooling layer and two fully connected(fc) layers. The first fc layer is often called embedding layer or whitening layer whose output size is 512. While the output size of second fc layer is corresponding to the class number of training dataset. Instead of using softmax loss for training, we train these models with arcmargin loss. Arcmargin loss is firstly employed in face recognition, we found it works well in retrieval tasks which can produce distinguishing and compact descriptor in landmark.<br> <img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F3556209%2F3128c6a35d4df708a26530ff360c3f98%2Ffigure1.png?generation=1598414665139238&amp;alt=media" alt=""></p> <p>The training process mainly consists of three steps. Firstly, we train the two models with resolution 224x224 on GLDv1 dataset which has total 1215498 images of 14950 classes, and GLDv2-clean dataset which has total 1580470 images of 81313 classes. Secondly, these two models are further trained on GLDv2-clean dataset with resolution 448x448, the parameters of arcmargin loss may change during the process. We believe that using large input size is beneficial to extract feature of tiny landmark. However, we have to adopt the training strategy “from small to large” mainly due to the large cost and lack of GPUs. In the final step, some tricks are experimented to increase the performance. We have tried a lot of methods, such as triplet loss finetuning, circle loss finetuning and etc but only “GemPool” and “Fix” strategy are helpful.</p> <p><strong>Training and test details</strong><br> At the data level, we first used GLDv1 and GLDv2-clean data with small resolution to train at a large learning rate, and then used GLDv2-clean data with large resolution to train at a small learning rate. The specific details are listed in Table 1. Table 2 shows the results of training with the above strategies. Table 3 lists the mAP@100 score of model ensemble.</p> <p><img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F3556209%2F69543b8fa754361b44694b4375eb8a2b%2Ft1.png?generation=1598414755535679&amp;alt=media" alt=""></p> <p><img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F3556209%2Fe70fe15075878b440733828569423c57%2Ft2.png?generation=1598414770976775&amp;alt=media" alt=""></p>
Cornell Birdcall Identification
21st Place Write-up [Stack-up]
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Cornell Birdcall Identification <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>First of all, I would like to thank kaggle and the organizers for hosting such an interesting competition.</p> <p>thanks for my wonderful team <a href="https://www.kaggle.com/seshurajup" target="_blank">@seshurajup</a> and <a href="https://www.kaggle.com/tarique7" target="_blank">@tarique7</a>. this was great learning and collaboration.</p> <p><a href="https://www.kaggle.com/seshurajup" target="_blank">@seshurajup</a> and I worked hard for this from the last 20days</p> <h4>[Big Shake-up]</h4> <ul> <li>LB : 0.533 ---&gt; Private LB : 0.632</li> <li>From 364th place ---&gt; 21st place</li> </ul> <p><img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F2058044%2F0725e3d4482b444098f50d6df08441ef%2FScreenshot%20from%202020-09-16%2006-20-45.png?generation=1600217490267914&amp;alt=media" alt=""></p> <h3>[Summary]</h3> <ul> <li>converted mp3 audio file into wav with sample_rate 16k, because of colab drive space and birds sing up to 12kHz</li> <li>we trained <strong>stage1</strong> model based on 5sec random clip.</li> <li>It gives average of 0.65+ AMP on 5-fold</li> <li>we created 1sec audio clips dataset.</li> <li>predicted 5fold <strong>stage1</strong> models on 1sec dataset.</li> <li>selected <code>df[(df.ebird_code == df.pred_code) &amp; (df.pred_prob &gt;= 0.5)]</code> selected those 1sec clips for <strong>stage3</strong></li> <li>we trained <strong>stage2</strong> model on topof <strong>stage1</strong> using public data</li> <li>again predicted <strong>stage1</strong> and <strong>stage2</strong> models on public 1sec clips</li> <li>again select <code>df2[(df2.ebird_code == df2.pred_code) &amp; (df2.pred_prob &gt;= 0.5)]</code>selected those 1sec clips for <strong>stage3</strong></li> <li><strong>stage3</strong> dataset is <code>stage3_df = df.append(df2)</code> we endup with 612K 1sec clips with sudo labels</li> <li>we created 1sec noise clips using PANN <strong>Cnn14_16k</strong> model.</li> <li>we predict <strong>Cnn14_16k</strong> model on 1sec dataset and select some noise labels from PANN labels </li> <li>those labels are <code>['Silence', 'White noise', 'Vachical', 'Speech', 'Pink noise', 'Tick-tock', 'Wind noise (microphone)','Stream','Raindrop','Wind','Rain', ...... ]</code> selected those labels as noise labels</li> <li>based on those noise labels and <strong>stage1</strong> model predicted probabilities we select 1sec noise clips data.</li> <li><code>noise_df = df[(df.filename.isin(noise_labels_df.filename)) &amp; df.pred_prob &lt; 0.4]</code></li> <li>we end up with 103k noise 1sec clips you find dataset <a href="https://www.kaggle.com/gopidurgaprasad/birdsong-stage1-1sec-sudo-noise" target="_blank">link</a></li> <li>we know in this competition our main goal is to predict a mix of bird calls.</li> <li>now the main part, at the end we have <strong>stage1</strong>, <strong>stage2</strong> models, <strong>1sec</strong> dataset with Sudo labels, and <strong>1sec noise data</strong>. we trained the <strong>stage3</strong> model using all of those.</li> <li>now in front of us, we need to build <strong>CV</strong> and train a model that more reliable on predicting a mix of bird calls.</li> </ul> <h3>[CV]</h3> <ul> <li>we created a <strong>cv</strong> based on <strong>1sec bird calls</strong> and <strong>1sec noise data</strong></li> <li>In the end, we need to predict for <strong>5sec</strong> so we take 5 random birdcalls and noise stack them and give labels based on birdcall clips.</li> </ul> <pre><code>call_paths_list = call_df[["paths", "pred_code"]].values nocall_paths_list = nocall_df.paths.values def create_stage3_cv(index): k = random.choice([1,2,3,4,5]) nocalls = random.choises(nocall_paths_list, k=k) calls = random.choises(call_paths_list, k=5-k) audio_list = [] code_list = [] for f in nocalls: y, _ = sf.read(f) audio_list.append(y) for l in calls: path = l[0] code = l[1] y, _ = sf.read(path) audio_list.append(y) code_list.append(code) random.shuffle(audio_list) audio_cat = np.concatenate(audio_list) codes = "_".join(code_list) sf.write(f"{index}_{codes}.wav", audio_cat, sample_rate=16000) _ = Parallel(n_jobs=8, backend="multiprocessing")( delayed(create_stage3_cv)(i) for i in tqdm(range(160000//5))) ) </code></pre> <p>Ex: <code>10000_sagthr_normoc_gryfly.wav</code> in this file you find 3bird calls and 2noise as 5sec clip.<br> you find the cv dataset at <a href="https://www.kaggle.com/gopidurgaprasad/birdsong-stage3-cv" target="_blank">link</a></p> <h3>[Stage3]</h3> <ul> <li>on top of <strong>stage1</strong> and <strong>stage2</strong> models we trained <strong>stage3</strong> model using <strong>1sec birdcalls</strong> and <strong>1sec noise</strong>.</li> <li>the training idea is very simple as same as <strong>cv</strong>.</li> <li>at dataloder time we are taking 20% of <strong>1sec noise</strong> clips and 80% of <strong>1sec birdcalls</strong> clips</li> </ul> <pre><code>if np.random.random() &gt; 0.2: y, sr = sf.read(wav_path) labels[BIRD_CODE[ebird_code]] = 1 else: y, sr = sf.read(random.choice(self.noise_files)) labels[BIRD_CODE[ebird_code]] = 0 </code></pre> <ul> <li>at each batch time, we did something like shuffle and stack, inspired from cut mix and mixup</li> <li>In each batch, we have 20% noise and 80% birdcalls shuffle them and concatenate.</li> </ul> <pre><code>def stack_up(x, y, use_cuda=True): batch_size = x.size()[0] if use_cuda: index0 = torch.randperm(batch_size).cuda() index1 = torch.randperm(batch_size).cuda() index2 = torch.randperm(batch_size).cuda() index3 = torch.randperm(batch_size).cuda() index4 = torch.randperm(batch_size).cuda() ind = random.choice([0,1,2,3,4]) if ind == 0: mixed_x = x mixed_y = y elif ind == 1: mixed_x = torch.cat([x, x[index1, :]], dim=1) mixed_y = y + y[index1, :] elif ind == 2: mixed_x = torch.cat([x, x[index1, :], x[index2]], dim=1) mixed_y = y + y[index1, :] + y[index2, :] elif ind == 3: mixed_x = torch.cat([x, x[index1, :], x[index2], x[index3, :]], dim=1) mixed_y = y + y[index1, :] + y[index2, :] + y[index3, :] elif ind == 4: mixed_x = torch.cat([x, x[index1, :], x[index2], x[index3, :], x[index4, :]], dim=1) mixed_y = y + y[index1, :] + y[index2, :] + y[index3, :] + y[index4, :] mixed_y = torch.clamp(mixed_y, min=0, m[](url)ax=1) return mixed_x, mixed_y </code></pre> <ul> <li>for <strong>stage3</strong> model we mouniter row_f1 score from this <a href="https://www.kaggle.com/shonenkov/competition-metrics" target="_blank">notebook</a> </li> <li>for every epoch our <strong>cv</strong> increased, then we conclude that we are going to trust this <strong>cv</strong></li> <li>at the end the best <strong>cv</strong> <strong>row_f1</strong> score in between <strong>[0.90 - 0.95]</strong></li> <li>this all processes are done in the last 3days so we are managed to train up to 5 models.</li> <li>at the end we don't have time as well as submissions, so we did a simple average on 5 models and using a simple threshold 0.5</li> <li>our average <strong>row_f1</strong> score is 0.94+ on 5 models.</li> </ul> <h3>[BirdSong North America Set]</h3> <ul> <li>for some folds in <strong>stage3</strong> we are only trained on North America birds it improves our <strong>cv</strong></li> <li>you can find North America bird files in this <a href="https://www.kaggle.com/seshurajup/birdsong-north-america-set-stage-3" target="_blank">notebook</a> </li> </ul> <h3>[Stage3 Augmentations]</h3> <pre><code>import audiomentations as A augmenter = A.Compose([ A.AddGaussianNoise(p=0.3), A.AddGaussianSNR(p=0.3), A.AddBackgroundNoise("stage1_1sec_sudo_noise/", p-0.5), A.Normalize(p=0.2), A.Gain(p=0.2) ]) </code></pre> <h3>[Stage3 Ensamble]</h3> <ul> <li>we trained our stage3 models 2dyas before the competition ending so we are managed to train 5 different models.</li> <li>1. <code>Cnn14_16k</code></li> <li>2. <code>resnest50d</code></li> <li>3. <code>efficientnet-03</code></li> <li>4. <code>efficientnet-04</code></li> <li>5. <code>efficientnet-05</code></li> <li>we did a simple average of those 5-models with simple threshold <code>0.5</code> our <em>cv</em> <code>0.94+</code> on LB: <code>0.533</code></li> <li>in the end, we satisfied our selves and trust our <strong>CV</strong> and we know we need to predict a mixed bird calls.</li> <li>so we selected as our final model and it gives Private LB: 0.632 </li> <li>we frankly saying that we are not able to beat the public LB score but we trusted our cv and training process</li> <li>that brings us 21st place in Private LB.</li> </ul> <blockquote> <p>inference notebook : <a href="https://www.kaggle.com/gopidurgaprasad/birdcall-stage3-final" target="_blank">link</a></p> </blockquote>
Google Landmark Retrieval 2020
1st place solution summary
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Google Landmark Retrieval 2020 <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>[Update] solution arxiv link : <a href="https://arxiv.org/abs/2009.05132" target="_blank">https://arxiv.org/abs/2009.05132</a><br> </p> <h1> </h1> <p>Great thanks to google and kaggle team for hosting this competition, and congrats to all participants who finished successfully. I really learned a lot during the competition through reading articles, analysing codes, and doing experiments.</p> <p>I'd like to share my solution, and detailed solution will be uploaded to arxiv in a few days.</p> <p>Model structure is as below.<br> <img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F701191%2Fb1ac1bca6f58600f19ccbb31a2496682%2Fmodels_jpg.jpg?generation=1597910875460797&amp;alt=media" alt=""></p> <h1>Basic Configuration</h1> <p>Validation set : 1 sample per class which has &gt;=4 samples in GLD v2 clean dataset(72322/81313 classes)<br> Cosine softmax : s=determined by adacos, m=0<br> Weighted cross entropy : proportional to 1/log(class cnt)<br> Augmentation : left-right flip<br> Optimizer : SGD(1e-3, momentum=0.9, decay=1e-5)<br> Embedding Dimension : 512 for every model<br> Hardware : Colab TPUs</p> <h1>Training Strategy</h1> <p>1.Use GLD v2 clean dataset to train model to classify 81313 classes<br> efn7 512x512 priv.LB:0.30264, pub.LB:0.33907<br> 2.Take efficientnet backbone from step 1, use GLD v2 total dataset to train model to classify 203094 classes<br> efn7 512x512 priv.LB:0.33749, pub.LB:0.36576</p> <p>3.Take whole model from step 2, give increasingly bigger images to the model<br> efn7 640x640 priv.LB:0.35389, pub.LB:0.39121<br> efn7 736x736 priv.LB:0.36364, pub.LB:0.40174<br> 4.Take whole model from step 3, set twice loss weight for GLD v2 clean samples<br> efn7 640x640 priv.LB:0.35932, pub.LB:0.39881<br> efn7 736x736 priv.LB:0.36569, pub.LB:0.40215</p> <h1>Ensemble</h1> <p>1.736x736 efn7+efn6+efn5+efn5 weighted concat<br> (all train step3, weight : efn7=1.0, efn6=0.8, efn5=0.5)<br> priv.LB:0.38366, pub.LB: 0.41986<br> 2.Same Config, with train step 4 for efn7<br> priv.LB:0.38677, pub.LB: 0.42328</p> <h1> </h1> <p>If you have any questions, feel free to ask.<br> Thank you. </p>
Global Wheat Detection
[340th place Solution] EfficientDet with PLx2
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Global Wheat Detection <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Thanks for all the work done by the contributor of the notebooks community, thanks for their sharing, we really learned a lot from it, and we thanks for all the participant's work that makes the leaderboard more energetic!</p> <p>Is not easy to get 340th place, we try to use a number of methods but hard to improve. <br> Through our tireless efforts, we got 0.7666 on public and 0.6916 on private.<br> These are some strategies for our final used submission.</p> <h3>Data Cleaning</h3> <ul> <li>We deleted some boxes that squared wheat which cannot be seen very clearly and some boxes that appeared in the edge of the picture while squared nothing.</li> <li>We also resize the boxes that are squared awn of wheat to only the wheat head. We did not resize all pictures because we concerned about the reduction of the predicted box may lead to a low percentage, for the IOU of predicted and ground truth &gt; 0.5 got hit.</li> </ul> <p>Here is our dataset of cleaning markings. <a href="https://www.kaggle.com/dpyrtfq2372/pure-box" target="_blank">link to pure-box</a> Thanks to <a href="https://www.kaggle.com/songzhijin" target="_blank">@songzhijin</a> <a href="https://www.kaggle.com/luluqie" target="_blank">@Abusi Brown</a> They are my team member, thanks for their great effort and amazing work on the data cleaning. <br> We used this tool to relabel the box. <a href="https://github.com/tzutalin/labelImg" target="_blank">Labelimg</a><br> And I code this notebook for some format converting.<a href="https://www.kaggle.com/dpyrtfq2372/train-marking-to-pascalvoc/data" target="_blank">Train Marking(csv) to PascalVOC(xml)</a></p> <h3>Training</h3> <p>We used 1024x1024 images, Stratified 5 Folds Splitting, some Augmentation like others, on Efficientdet-D5.<br> And we used apex.amp so that we can use batch-size=2 in 1024 to have a better loss on training.</p> <h3>Inferencing</h3> <p>We used 2 times of Pseudo Labeling, in the PLabeling we choose WBF iou_thr=0.2, skip_box_thr=0.33, each of them got training 3 epochs, the data consist of training data with our cleaned label and testing data with PLabel .<br> In the final prediction, we used back to iou_thr=0.44, skip_box_thr=0.43 of WBF to get a more precise result.</p> <p>The detection effect like this:<br> <img src="https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F4931964%2Fe83af1b1abef9051fceb33e93a4f0eca%2F__results___61_0.png?generation=1596705036976428&amp;alt=media" alt=""></p> <p>Here is our notebook link. <a href="https://www.kaggle.com/dpyrtfq2372/efficientdet-with-double-psudo-labeling" target="_blank">Efficientdet-with-double-Pseudo-Labeling</a><br> Thanks for your reading, I hope we can give you some inspiration through this page.</p> <p>And I want to say in the end, thanks a lot to kaggle team, we really appreciate they managed to contain the rules of the competition and gave us the platform to communicate with others!</p>
SIIM-ISIC Melanoma Classification
Our best private solution (0.9498) [not selected]
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: SIIM-ISIC Melanoma Classification <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>As most participants, we have not chosen our best private solution. But we would like to share it with you. Maybe it will be helpful for someone!</p> <p><a href="https://www.kaggle.com/vladimirsydor/solution-private-score-0-9498-not-selected" target="_blank">https://www.kaggle.com/vladimirsydor/solution-private-score-0-9498-not-selected</a></p> <p>Thanks to Kaggle team and all participants and good Kaggling! </p>
Google Landmark Retrieval 2020
9th place solution overview
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Google Landmark Retrieval 2020 <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>We thank all organizers for this very exciting competition.<br> Congratulations to all who finished the competition and to the winners.</p> <p>We trained models using only GLDv2clean dataset on PyTorch and converted them to TensorFlow’s saved_model.<br> Then, we validated them using GLR2019 public and private datasets.</p> <h2>Final submission</h2> <p>ResNeSt50 + ResNet101 + ResNet152 + SEResNeXt101</p> <table> <thead> <tr> <th>model</th> <th>output dim</th> <th>input size</th> <th>GLR2019 mAP@100</th> <th>Public LB</th> <th>Private LB</th> </tr> </thead> <tbody> <tr> <td>ResNeSt50</td> <td>512</td> <td>416</td> <td>0.3114</td> <td>0.335</td> <td>0.292</td> </tr> <tr> <td>ResNet101</td> <td>512</td> <td>608</td> <td>0.3243</td> <td>0.346</td> <td>0.303</td> </tr> <tr> <td>ResNet152</td> <td>512</td> <td>480</td> <td>0.3180</td> <td>0.336</td> <td>0.288</td> </tr> <tr> <td>SEResNeXt101</td> <td>512</td> <td>480</td> <td>0.3209</td> <td>0.337</td> <td>0.296</td> </tr> <tr> <td>Ensemble of 4 models</td> <td>2048 (concat)</td> <td>-</td> <td>0.3396</td> <td>0.361</td> <td>0.317</td> </tr> </tbody> </table> <h2>Model details</h2> <ul> <li>Backbones: Ensemble of ResNeSt50, ResNet101, ResNet152 and SEResNeXt101</li> <li>Pooling: GeM (p=3)</li> <li>Head: FC-&gt;BN-&gt;L2 (the same as the last year’s first place team)</li> <li>Loss: CosFace with Label Smoothing (ArcFace was also good, but CosFace was better)</li> <li>Data Augmentation: RandomResizedCrop, Rotation, RandomGrayScale, ColorJitter, GaussianNoise, Normalize, and GridMask</li> <li>LR: Cosine Annealing LR with warmup, training for 30 epochs</li> <li>Input image size in training: 352</li> </ul> <h2>What we tried and worked</h2> <ul> <li>Automatic mixed precision training</li> <li>Replace GeM p=3 with p=4 in testing</li> <li>Increase input image size last few epochs of training with freezed BN</li> <li>Large and multiple input image sizes in testing: 416, 480 and 608</li> <li>MVArcFace</li> </ul> <h2>What did not work</h2> <ul> <li>PCA whitening</li> <li>Maintaining the aspect ratio of input images in testing (perhaps because our models were trained on square images)</li> <li>Combination of arcface loss and pairwise (e.g., triplet) loss<br> We have tried arcface loss with pairwise loss (specially multi-similarity loss). However, the single arcface loss was better than multiple losses.</li> <li>EfficientNet</li> <li>Circle loss</li> <li>Removing noisy classes<br> We have tried to remove the worst 3 noisy classes which have high variance based on arcface class weight, but it did not work.</li> </ul> <h2>What we have not tried</h2> <ul> <li>Training with GLDv1 dataset</li> <li>Training without changing the aspect ratio of images </li> </ul>
Cornell Birdcall Identification
1st Place Solution
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Cornell Birdcall Identification <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Most of my solution was based on the baseline SED model provided by <a href="https://www.kaggle.com/hidehisaarai1213" target="_blank">@hidehisaarai1213</a> . Without his kernel I wouldn't have achieved the result I did. So I am really grateful to him. Thanks for sharing a lot during the competition, I learnt a lot. </p> <h2>Data Augmentation</h2> <p>No external data.</p> <ul> <li>Pink noise</li> <li>Gaussian noise</li> <li>Gaussian SNR</li> <li>Gain (Volume Adjustment)</li> </ul> <h2>Models</h2> <p>I noticed that the default SED model had over 80 million parameters so I switched all my models to use a pretrained densenet121 model as the cnn feature extractor and reduced the attention block size to 1024. Since it was much smaller and wouldn't overfit as much as we only had around 100 files for each audio class. I mainly tried densenet as previous top solutions to audio competitions used a densenet like architecture. I also replaced the clamp on the attention with tanh as mentioned in the <a href="https://www.kaggle.com/hidehisaarai1213/introduction-to-sound-event-detection/comments#962915" target="_blank">comments on the SED notebook</a></p> <ul> <li>4 fold models without mixup</li> <li>4 fold models with mixup</li> <li>5 fold models without mixup</li> </ul> <h2>Training</h2> <ul> <li>Cosine Annealing Scheduler with warmup </li> <li>batch size of 28</li> <li>Mixup (on 4 of the final models)</li> <li>50 epochs for non-mixup models and 100 epochs for mixup models</li> <li>AdamW with weight_decay 0.01</li> <li>SpecAugmentation enabled</li> <li>30 second audio clips during training and evaluating on 2 30 second clips per audio.</li> </ul> <h3>Loss Function</h3> <p>My loss function looked something like the below. I wanted to experiment with different parameters but in the end I mainly used the default values, which was just BCELoss. I used a different loss function for 2 of the non-mixup models and it was based on randomly removing the primary label predictions from the loss function, to try increase the secondary_label predictions but I gave up on the approach for the rest of the models since I was running out of time and resources.</p> <pre><code>class SedScaledPosNegFocalLoss(nn.Module): def __init__(self, gamma=0.0, alpha_1=1.0, alpha_0=1.0, secondary_factor=1.0): super().__init__() self.loss_fn = nn.BCELoss(reduction='none') self.secondary_factor = secondary_factor self.gamma = gamma self.alpha_1 = alpha_1 self.alpha_0 = alpha_0 self.loss_keys = ["bce_loss", "F_loss", "FScaled_loss", "F_loss_0", "F_loss_1"] def forward(self, y_pred, y_target): y_true = y_target["all_labels"] y_sec_true = y_target["secondary_labels"] bs, s, o = y_true.shape # Sigmoid has already been applied in the model y_pred = torch.clamp(y_pred, min=EPSILON_FP16, max=1.0-EPSILON_FP16) y_pred = y_pred.reshape(bs*s,o) y_true = y_true.reshape(bs*s,o) y_sec_true = y_sec_true.reshape(bs*s,o) with torch.no_grad(): y_all_ones_mask = torch.ones_like(y_true, requires_grad=False) y_all_zeros_mask = torch.zeros_like(y_true, requires_grad=False) y_all_mask = torch.where(y_true &gt; 0.0, y_all_ones_mask, y_all_zeros_mask) y_ones_mask = torch.ones_like(y_sec_true, requires_grad=False) y_zeros_mask = torch.ones_like(y_sec_true, requires_grad=False) *self.secondary_factor y_secondary_mask = torch.where(y_sec_true &gt; 0.0, y_zeros_mask, y_ones_mask) bce_loss = self.loss_fn(y_pred, y_true) pt = torch.exp(-bce_loss) F_loss_0 = (self.alpha_0*(1-y_all_mask)) * (1-pt)**self.gamma * bce_loss F_loss_1 = (self.alpha_1*y_all_mask) * (1-pt)**self.gamma * bce_loss F_loss = F_loss_0 + F_loss_1 FScaled_loss = y_secondary_mask*F_loss FScaled_loss = FScaled_loss.mean() return FScaled_loss, {"bce_loss": bce_loss.mean(), "F_loss_1": F_loss_1.mean(), "F_loss_0": F_loss_0.mean(), "F_loss": F_loss.mean(), "FScaled_loss": FScaled_loss } </code></pre> <p>`</p> <h2>Thresholds</h2> <p>I used a threshold of 0.3 on the <code>framewise_output</code> and 0.3 on the <code>clipwise_output</code> to reduce the impact of false positives. So if the 30 second clip contained a bird according to the clipwise prediction and the 5 second interval based on framewise prediction also said it had the same bird then it would be a valid prediction. During inference I also applied 10 TTA by just adding the same audio sample 10 times in the batch and enabling Spec Augmentation.</p> <h2>CV vs LB</h2> <p>My CV didn't match the public LB at all, so I mainly relied on the LB for feedback. During training I monitored the f1 score of the clipwise prediction, framewise prediction and the loss associated with classes existing in the audio (i.e the value of <code>F_loss_1</code> in the above loss function). When loss value of <code>F_loss_1</code> increased it generally meant that it would do worse on the LB even though the f1 score was increasing too. </p> <h2>Ensemble</h2> <p>I used voting to ensemble the models. My voting selection was based on LB score so in total I had 13 models with 4 votes to consider if the bird existed or not. <br> On the public LB, the 3 votes approach scored 0.617 which was slightly better than 4 votes model of 0.616, but I didn't select the 3 votes approach as I thought it was too risky which turnout out to be the correct choice as the 4 votes approach achieved 0.002 better than the 3 votes model on the private LB. My second selected submission was an an ensemble of the nomix up models (9 models) with 3 votes which scored 0.676 private, 0.613 public LB.</p> <p>My individual models were pretty bad on the public LB. I didn't check some of them individually as I was running out of submissions but they generally ranged between 0.585-0.605 on the Public LB. I mainly relied on my ensemble technique to get the score boost.</p> <p>Thanks to the hosts and Kaggle for this interesting competition. </p> <p><strong>Inference Notebook</strong>: <a href="https://www.kaggle.com/taggatle/cornell-birdcall-identification-1st-place-solution" target="_blank">https://www.kaggle.com/taggatle/cornell-birdcall-identification-1st-place-solution</a> <br> <strong>Training Code</strong>: <a href="https://github.com/ryanwongsa/kaggle-birdsong-recognition" target="_blank">https://github.com/ryanwongsa/kaggle-birdsong-recognition</a><br> <strong>Example on How to train the model on Kaggle Kernels</strong>: <a href="https://www.kaggle.com/taggatle/example-training-notebook" target="_blank">https://www.kaggle.com/taggatle/example-training-notebook</a></p>
SIIM-ISIC Melanoma Classification
My 23rd Place Aprroach
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: SIIM-ISIC Melanoma Classification <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p><strong>Update;</strong></p> <p>Since my TPU limit reset I shared light version of my approach here:</p> <p><a href="https://www.kaggle.com/datafan07/final-melanoma-model-18th-place-solution-light-v" target="_blank">https://www.kaggle.com/datafan07/final-melanoma-model-18th-place-solution-light-v</a></p> <p>First of all thank you Kaggle and rest of the people involved in this competition. It was my first serious competition ever and learned a lot on the way. I wanted to write what worked for me (at least what I think worked), I learnt a lot from this community so I wanted to share them back!</p> <p>My highest scored submission on public score was based only 2020 data only. They were doing good with efficientnet + meta blend but I noticed they weren't doing great in terms of non seen data. I thought this were due to some unseen test set which Chris and I pointed out in some public discussions.</p> <p>I was getting some unstable results for some cases in the test set, there were big differences between only 2020 trained predictions and only 2019 predictions. I had gut feeling that this might be caused by some medical differences about the stage of the melanoma, or different scanning device but that's not my expertise area at all so to get overcome that I decided to use external data, I thought adding more examples would make my model better at predicting these weird cases. Thanks to Chris I used the external tfrecords and malignant upsampling on my existing model.</p> <p>Well… That increased my CV a lot but wasn't the case with LB. I decided to add these external data one by one and at the end decided to keep out 2019 part out of my model and only used 2018. This helped me a little but there was a big problem: <strong>overfitting</strong>. Tried some augmentations and regularizing but wasn't enough imo. I was really interested in Coarse Dropout from Chris but it was kinda damaging my model speed at the dropout levels I want. Then found <a href="https://www.kaggle.com/benboren" target="_blank">@benboren</a> 's great sprinkle method and fine tuned it for my model:</p> <pre><code>def make_mask(num_holes,side_length,rows, cols, num_channels): """Builds the mask for all sprinkles.""" row_range = tf.tile(tf.range(rows)[..., tf.newaxis], [1, num_holes]) col_range = tf.tile(tf.range(cols)[..., tf.newaxis], [1, num_holes]) r_idx = tf.random.uniform([num_holes], minval=0, maxval=rows-1, dtype=tf.int32) c_idx = tf.random.uniform([num_holes], minval=0, maxval=cols-1, dtype=tf.int32) r1 = tf.clip_by_value(r_idx - side_length // 2, 0, rows) r2 = tf.clip_by_value(r_idx + side_length // 2, 0, rows) c1 = tf.clip_by_value(c_idx - side_length // 2, 0, cols) c2 = tf.clip_by_value(c_idx + side_length // 2, 0, cols) row_mask = (row_range &gt; r1) &amp; (row_range &lt; r2) col_mask = (col_range &gt; c1) &amp; (col_range &lt; c2) # Combine masks into one layer and duplicate over channels. mask = row_mask[:, tf.newaxis] &amp; col_mask mask = tf.reduce_any(mask, axis=-1) mask = mask[..., tf.newaxis] mask = tf.tile(mask, [1, 1, num_channels]) return mask def sprinkles(image, cfg = CFG): num_holes = cfg['num_holes'] side_length = cfg['side_length'] mode = cfg['sprinkles_mode'] PROBABILITY = cfg['sprinkles_prob'] RandProb = tf.cast( tf.random.uniform([],0,1) &lt; PROBABILITY, tf.int32) if (RandProb == 0)|(num_holes == 0): return image img_shape = tf.shape(image) if mode is 'normal': rejected = tf.zeros_like(image) elif mode is 'salt_pepper': num_holes = num_holes // 2 rejected_high = tf.ones_like(image) rejected_low = tf.zeros_like(image) elif mode is 'gaussian': rejected = tf.random.normal(img_shape, dtype=tf.float32) else: raise ValueError(f'Unknown mode "{mode}" given.') rows = img_shape[0] cols = img_shape[1] num_channels = img_shape[-1] if mode is 'salt_pepper': mask1 = make_mask(num_holes,side_length,rows, cols, num_channels) mask2 = make_mask(num_holes,side_length,rows, cols, num_channels) filtered_image = tf.where(mask1, rejected_high, image) filtered_image = tf.where(mask2, rejected_low, filtered_image) else: mask = make_mask(num_holes,side_length,rows, cols, num_channels) filtered_image = tf.where(mask, rejected, image) return filtered_image </code></pre> <p><img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4616296%2F9f27283c72e3b99022acdff72643cce0%2F__results___13_0.png?generation=1597716024628082&amp;alt=media" alt=""></p> <p>After adding this to my regular augmentations, I have noticed it decreased overfitting but it also reduced my models learning speed. To fix that I wanted to add attention on my model, thought that might speed up the training speed and also helps with the cv so ended up adding Scott Madder's attention model to my efficientnet top, attention explanation directly from his notebook <a href="https://www.kaggle.com/kmader/attention-on-pretrained-vgg16-for-bone-age#Show-Attention" target="_blank">here</a>. So I played with it edited it here and there meanwhile added another input to my model including metadata from tfrecords and ended up with this:</p> <pre><code>def get_model(): with strategy.scope(): inp1 = tf.keras.layers.Input(shape = (cfg['net_size'],cfg['net_size'], 3), name = 'inp1') inp2 = tf.keras.layers.Input(shape = (9), name = 'inp2') efnetb3 = efn.EfficientNetB3(weights = 'noisy-student', include_top = False) pt_depth = efnetb3.get_output_shape_at(0)[-1] pt_features = efnetb3(inp1) bn_features = tf.keras.layers.BatchNormalization()(pt_features) attn_layer = tf.keras.layers.Conv2D(64, kernel_size = (1, 1), padding = "same", activation = "relu")(tf.keras.layers.Dropout(0.5)(bn_features)) attn_layer = tf.keras.layers.Conv2D(16, kernel_size = (1, 1), padding = "same", activation = "relu")(attn_layer) attn_layer = tf.keras.layers.Conv2D(8, kernel_size = (1,1), padding = 'same', activation = 'relu')(attn_layer) attn_layer = tf.keras.layers.Conv2D(1, kernel_size = (1, 1), padding = "valid", activation = "sigmoid")(attn_layer) up_c2_w = np.ones((1, 1, 1, pt_depth)) up_c2 = tf.keras.layers.Conv2D(pt_depth, kernel_size = (1, 1), padding = "same", activation = "linear", use_bias = False, weights = [up_c2_w] ) up_c2.trainable = False attn_layer = up_c2(attn_layer) mask_features = tf.keras.layers.multiply([attn_layer, bn_features]) gap_features = tf.keras.layers.GlobalAveragePooling2D()(mask_features) gap_mask = tf.keras.layers.GlobalAveragePooling2D()(attn_layer) # To account for missing values from the attention model gap = tf.keras.layers.Lambda(lambda x: x[0] / x[1], name = "RescaleGAP")([gap_features, gap_mask]) gap_dr = tf.keras.layers.Dropout(0.5)(gap) dr_steps = tf.keras.layers.Dropout(0.25)(tf.keras.layers.Dense(128, activation = "relu")(gap_dr)) x1 = tf.keras.layers.Dense(16)(inp2) x1 = tf.keras.layers.Activation('relu')(x1) x1 = tf.keras.layers.Dropout(0.2)(x1) x1 = tf.keras.layers.BatchNormalization()(x1) x1 = tf.keras.layers.Dense(8)(inp2) x1 = tf.keras.layers.Activation('relu')(x1) x1 = tf.keras.layers.Dropout(0.2)(x1) x1 = tf.keras.layers.BatchNormalization()(x1) concat = tf.keras.layers.concatenate([dr_steps, x1]) concat = tf.keras.layers.Dense(512, activation = 'relu')(concat) concat = tf.keras.layers.BatchNormalization()(concat) concat = tf.keras.layers.Dropout(0.15)(concat) output = tf.keras.layers.Dense(1, activation = 'sigmoid',dtype='float32')(concat) model = tf.keras.models.Model(inputs = [inp1, inp2], outputs = [output]) opt = tf.keras.optimizers.Adam(learning_rate = LR) model.compile( optimizer = opt, loss = [tfa.losses.SigmoidFocalCrossEntropy(gamma = 2.0, alpha = 0.90)], metrics = [tf.keras.metrics.BinaryAccuracy(), tf.keras.metrics.AUC()] ) return model </code></pre> <p>I got predictions for different image sizes and different efficientnets and different data ratios (external etc.).</p> <p>At the end looking for ensembling I choose pretty basic way of averaging different models. I got CV's and LB's for many models and ensembled them basically depending on correlations between them, the heatmap looked like this, sorry for the mess :)</p> <p><img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4616296%2F85de95f55a0d3fb77a21b5b81e30aae1%2FScreenshot_2020-08-18%20corr%20-%20Jupyter%20Notebook.png?generation=1597716422214100&amp;alt=media" alt=""></p> <p>Simply I ensembled the high cv predictions with less correlations between them. And got the final results.</p> <p>This was my first proper competition and I wasn't expecting writing something like this so this might be not looking like your usual writeups. I learnt a lot in this competition and wanted to share some of them back! Maybe I'll release the notebook in more proper way later but that's it for now. Thank you all!</p>
SIIM-ISIC Melanoma Classification
16 Place Solution
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: SIIM-ISIC Melanoma Classification <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Congrats to all winners! Thank you to the organizers and Kaggle for hosting this competition. We really hope that the winning models can make a difference here. Thank you <a href="https://www.kaggle.com/kazanova" target="_blank">@kazanova</a> for all the works we have tried. It was fun!</p> <p>We also want to extend our gratitude to <a href="https://www.kaggle.com/cdeotte" target="_blank">@cdeotte</a> (<a href="https://www.kaggle.com/cdeotte" target="_blank">https://www.kaggle.com/cdeotte</a>) for the great work that he did throughout the competition, providing very useful insights as well as preparing the datasets in a good format to make them easy to use.</p> <p>Our approach is an ensemble of 30+ different models built with various combinations of image sizes and networks. We used a 5-fold CV and we optimized for logloss. <em>We found logloss to be a bit more stable than AUC when assessing what the best model is.</em> We could run the same model with different seed and (even though there was a lot of TTA ) the differences in AUC could be +- 0.02 in a single fold, whereas logloss was much more stable.</p> <p>The augmentations that worked best for us (apart from the usual ones like rotations and flips) were (in this order):</p> <ul> <li>Coarse dropout </li> <li>Grid mask</li> <li>Cutmix</li> <li>mixup</li> </ul> <p><strong>Network-wise, we only used EfficientNet models.</strong> We experimented with other pretrained networks, but they did not perform as well. The best performing combination of model and size was EfficientNet b5 with 512. Most of our models were built in tensorflow using TPUs (in colab or Kaggle). The TPU environment made quite a big difference for us – we were able to accelerate training and experimentation which fundamentally helped us to find good training schemas for this competition. We had some models built in pytorch too. Cv-wise both frameworks were close, with the tensorflow implementation being a bit better here (in both cv and LB).</p> <p><strong>Constant scheduling, checkpoint averaging and a lot of tta (with 30 different combinations of augmentations) worked very well.</strong> Each fold prediction used 150 inferences (5 checkpoint x 30 augmentations). This helped a lot to create stability for our models. Apart from averages, for every model, we also used maximum, minimum, standard deviation and geometrical mean (of all those 150 predictions). <em>We were quite surprised that standard deviation was quite often performing better than mean in both logloss and AUC. The interpretation could be that the more uncertain we are about what the actual prediction is, the more likely it is to be malignant.</em></p> <p><strong>For our final model, we used stacking using ExtraTreesClassifier</strong> (<a href="https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.ExtraTreesClassifier.html" target="_blank">https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.ExtraTreesClassifier.html</a>) . Our cv was 0.9536 (and LB 0.9457). Our best performing stacking model (version 38) was (almost) the best at private LB. Our previous version (37) was the best. There is very good relationship between cv and LB for all our stacking models.</p> <p><strong>Detailed recipes that work\not work for us</strong></p> <p><strong>What works well:</strong></p> <ul> <li>2018, and external data (with 30K samples)</li> <li>Multiple Checkpoint + TTA with Mean\Max\Min\Std </li> <li>Different sized images and efficientnets (efb5, 512 is best in cv)</li> <li>Pretrain with external data, then finetune on 2020 data</li> <li>Stacking with extraTreesClassifier</li> </ul> <p><strong>What works not well:</strong></p> <ul> <li>Train a multiclassifier</li> <li>Focal loss</li> <li>Patient-level stacking: aggregate predictions by patient</li> <li>Tuning with SWA/AdamW/stochastic depth for efficientnets</li> <li>Batch accumulation for larger image sizes (768\1024)</li> </ul>
Prostate cANcer graDe Assessment (PANDA) Challenge
12th Place Solution - Overview with code files
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Prostate cANcer graDe Assessment (PANDA) Challenge <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>First of all, I would like to thank all the people and organizations that have made this Competition possible. In capital letters, THANK YOU to all the TEAMS that with their dedication and effort I hope contribute to improve the diagnosis of prostate cancer and thereby improve people's lives. Indeed, my most sincere congratulations to the WINNERS.</p> <p>I am very happy as you can imagine. In a few lines I share with you a quick overview of my time in this Challenge.</p> <h3>Kaggle Learning</h3> <p>I want to comment here what is usually included in the acknowledgments part but I reserve this special section to highlight the work of those competitors who have made my final solution better, 1) because their ability was not present in my initial knowledge or 2) because their performance improves together with the experience of mine. I mean, in no order of priority,</p> <ul> <li><strong>(Salman)</strong> <a href="https://www.kaggle.com/micheomaano" target="_blank">@micheomaano</a>:</li> </ul> <ol> <li><a href="https://www.kaggle.com/micheomaano/tf-record-256-256-48" target="_blank">Dataset tf-record-256-56-48</a></li> <li><a href="https://www.kaggle.com/micheomaano/tpu-training-tensorflow-iafoos-method-42x256x256x3" target="_blank">TPU Training Tensorflow Iafoos Method 42x256x256x3</a></li> <li><a href="https://www.kaggle.com/micheomaano/pandas-42x256x256x3-inference" target="_blank">Pandas 42x256x256x3 Inference</a></li> </ol> <ul> <li><strong>(Qishen Ha)</strong> <a href="https://www.kaggle.com/haqishen" target="_blank">@haqishen</a>:</li> </ul> <ol> <li><a href="https://www.kaggle.com/haqishen/train-efficientnet-b0-w-36-tiles-256-lb0-87" target="_blank">Train EfficientNet-B0 w/ 36 tiles_256 [LB0.87]</a></li> <li><a href="https://www.kaggle.com/haqishen/panda-inference-w-36-tiles-256" target="_blank">PANDA Inference w/ 36 tiles_256</a></li> </ol> <ul> <li><strong>(RAHUL SINGH INDA)</strong> <a href="https://www.kaggle.com/rsinda" target="_blank">@rsinda</a>:</li> </ul> <ol> <li><a href="https://www.kaggle.com/rsinda/panda-inference-efficientnet-b1" target="_blank">Panda Inference EfficientNet-b1</a></li> </ol> <ul> <li><strong>(Iafoss)</strong> <a href="https://www.kaggle.com/iafoss" target="_blank">@iafoss</a>: The Best Accelerator in the Competition, ahead of TPUs.</li> </ul> <h3>Submission Notebook</h3> <p>I have shared an original copy of my inference kernel without additional cleaning as well as a dataset that includes the necessary weights of each of the models that are used in obtaining the final submission,</p> <ul> <li><a href="https://www.kaggle.com/coreacasa/12th-place-solution-quick-save-inference" target="_blank">Quick Save Inference</a></li> <li><a href="https://www.kaggle.com/coreacasa/pandaenetb042x256x256x3" target="_blank">Dataset Model Weights for Inference</a></li> </ul> <h3>[TPU] Kaggle/Google(Colaboratory)</h3> <p>For all my trainings I used the free TPU resources offered by Kaggle / Google (Colaboratory). Thank you very much.</p> <h3>Training One: My only approach to validation</h3> <p>Very closed to Salman's training kernel I just re-ran its code to complete cross validation. I ran a fold up to 60 epochs to see the evolution of the loss and the rest down to 40 epochs.</p> <p>Individually the behavior of the folds was more or less similar in final loss values (mse) and in the number of times in which it stopped improving. The issue is that its merge did not improve the individual performance of some of them over LB and their performance was also uneven when they were introduced into an external ensemble.</p> <p>The noise of the labels is a probable cause as already discussed in the discussions or perhaps the sensitivity of the qwk metric to even small variations in mse when its jump to LB.</p> <ul> <li><strong><a href="https://www.kaggle.com/coreacasa/code-base-training-one" target="_blank">code-base-training-one</a></strong> file, training topics:</li> </ul> <p><code>Size Image</code> 256<br> <code>Size Tiles</code> 256<br> <code>Tiles</code> 42<br> <code>Augmentation</code> horizonal p=0.5 and vertical p=0.5 flips<br> <code>Validation</code> StratifiedKFold 5 on isup grade classes<br> <code>Arch</code> EfficientNetB0<br> <code>Convolutional Base's Weight</code> Imagenet trainable<br> <code>On Top</code> GlobalAveragePooling2D, Dropout(0.5), Dense(1024)<br> <code>Output</code> Dense(1) regression objective<br> <code>Loss</code> mean_squared_error<br> <code>Optimizer</code> Adam<br> <code>Leaning Rate</code> 5e-04 init<br> <code>Reduce LR</code> decreasing 0.5 with patience 3 epochs<br> <code>Save</code> weights only with best validation loss epochs<br> <code>Batch Size</code> 64</p> <h3>Training Two: Art(Instinct) Validation</h3> <p>I never tried detecting noisy labels to remove them from training data. In general I am not in favor of losing any existing information, although in principle it could be harmful by elevating the non-regular part of a data generating process. I would rather transform data than remove it.</p> <p>I didn't try either any transformation so I thought about training the models with full dataset in order to prevent the possible existence of more noise in some folds than in others, which probably would be increasing the variability in the inference results.</p> <p>Art Validation appears here and it is when the art of the data scientist enters and it is his instinct that determines the goodness of fit and stability of performance in generalization against new observations. Yes, this is Alchemy.</p> <ul> <li><strong><a href="https://www.kaggle.com/coreacasa/code-base-training-two-enets" target="_blank">code-base-training-two-enets</a></strong> file, from which I trained 3 members of the EfficientNet family. Changes on training one training topics:</li> </ul> <p><code>Tiles</code> 48<br> <code>Validation</code> Art Validation on instinct<br> <code>Arch</code> EfficientNetB0, EfficientNetB1 and EfficientNetB2<br> <code>Convolutional Base's Weight</code> Noisy Student trainable<br> <code>Output</code> Dense(5,activation='sigmoid) ordinal regression objective<br> <code>Loss</code> sigmoid_cross_entropy_with_logits<br> <code>Leaning Rate</code> custom with 5up, 3sustain, 0.8decay<br> <code>Limits LR</code> 1e-05min, 4e-04max<br> <code>Save</code> weights only with best loss epochs<br> <code>Batch Size</code> 32<br> <code>Epochs</code> 60</p> <ul> <li><strong><a href="https://www.kaggle.com/coreacasa/code-base-training-two-densenet" target="_blank">code-base-training-two-densenet</a></strong> file, from which I trained 1 member of the DenseNet family. Changes on training topics of the previous net family:</li> </ul> <p><code>Arch</code> Densenet121<br> <code>Convolutional Base's Weight</code> Imagenet trainable<br> <code>Epochs</code> 40</p> <h3>Inference: Diversity of Archs, nTiles and TTAs</h3> <p>Of the 2 training processes shown above, the following models were available,</p> <ol> <li>EfficientNetB0 (5 skf), 42x256x256x3</li> <li>EfficientNetB0 (1), 48x256x256x3 </li> <li>EfficientNetB1 (1), 48x256x256x3 </li> <li>EfficientNetB2 (1), 48x256x256x3 </li> <li>DenseNet121 (1), 48x256x256x3 </li> </ol> <p>Having re-run the Salman kernel, from the public notebooks referenced at the beginning I had,</p> <ol> <li>EfficientNetB0 (1 skf), 36x256x256x3 (Qishen Ha) </li> <li>EfficientNetB1 (1 skf), 36x256x256x3 (RAHUL SINGH INDA)</li> </ol> <ul> <li><p><strong>Test Time Augmentation</strong><br> <code>Type A: 5xTTA deterministic</code> <br> 1xoriginal, 1xTranspose, 1xVerticalFlip, 1xHorizontalFlip, 1xTranspose-&gt;VerticalFlip-&gt;HorizontalFlip<br> <code>Type B: 4xTTA pseudo deterministic</code> <br> 1xoriginal, 1xVerticalFlip, 2xHorizontalFlip(p=0.5)-&gt;VerticalFlip(p=0.5)<br> <code>Type C: 2xTTA random </code> <br> 2xHorizontalFlip(p=0.5)-&gt;VerticalFlip(p=0)</p></li> <li><p><strong>White Padding Tile Extraction (Qishen modes)</strong><br> 1x add zero pad and 1x add 256 pad, that is, 2 different extractions for ALL the images.</p></li> </ul> <h3>Model Selection and Final Ensemble</h3> <pre><code>(3/10)*Public-Quishen [TTA Type A] (3/10)*Public-RAHUL SINGH INDA [TTA Type A] (1/30)*EfficientNetB0-Fold0-Training One [TTA Type C] (1/30)*EfficientNetB0-Fold2-Training One [TTA Type C] (1/30)*EfficientNetB0-Fold4-Training One [TTA Type C] (1/15)*EfficientNetB0-Training Two [TTA Type C] (1/15)*EfficientNetB1-Training Two [TTA Type C] (1/15)*EfficientNetB2-Training Two [TTA Type C] (1/10)*DenseNet121-Training Two [TTA Type B] </code></pre> <p>The random component of the TTAs was not seed (I'll be lucky) and the reproducibility of the results may vary with it. I have just re-run my inference kernel and the results are Private Score 0.92983 (0.92960 original) and Public Score 0.89443 (089352 original).</p> <p>With this models structure I was only able to test the last day of the competition. For example, this other ensemble got Private Score 0.93047 and Public Score 0.88889, not including random component in TTA.</p> <pre><code>(3.5/10)*Public-Quishen [TTA Type A] (3.5/10)*Public-RAHUL SINGH INDA [TTA Type A] (1/15)*EfficientNetB0-Training Two [TTA Type A] (1/15)*EfficientNetB1-Training Two [TTA Type A] (1/15)*EfficientNetB2-Training Two [TTA Type A] (1/10)*DenseNet121-Training Two [TTA Type A] </code></pre> <p>One more, my last submission and that finished tight after the deadline got Private Score 0.93052 and Public Score 0.89110,</p> <pre><code>(3.5/10)*Public-Quishen [TTA Type A] (3.5/10)*Public-RAHUL SINGH INDA [TTA Type A] (1/30)*EfficientNetB0-Fold0-Training One [TTA Type C] (1/30)*EfficientNetB0-Fold2-Training One [TTA Type C] (1/30)*EfficientNetB0-Fold4-Training One [TTA Type C] (1/15)*EfficientNetB0-Training Two [TTA Type C] (1/15)*EfficientNetB1-Training Two [TTA Type C] (1/15)*EfficientNetB2-Training Two [TTA Type C] </code></pre> <h3>That is all, Thanks a lot!</h3> <p>By the way, I still tremble with fear<br> Update: No longer!</p>
OSIC Pulmonary Fibrosis Progression
6th place solution
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: OSIC Pulmonary Fibrosis Progression <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>I would like to thank kaggle &amp; host for the interesting competition and to all the participants for giving me a lot of ideas. And congrats to winners!</p> <p>My work is based on </p> <ul> <li>My tabular approach notebooks<ul> <li><a href="https://www.kaggle.com/yasufuminakama/osic-lgb-baseline" target="_blank">https://www.kaggle.com/yasufuminakama/osic-lgb-baseline</a> </li> <li><a href="https://www.kaggle.com/yasufuminakama/osic-ridge-baseline" target="_blank">https://www.kaggle.com/yasufuminakama/osic-ridge-baseline</a> </li></ul></li> <li>Image approach notebooks<ul> <li><a href="https://www.kaggle.com/miklgr500/linear-decay-based-on-resnet-cnn" target="_blank">https://www.kaggle.com/miklgr500/linear-decay-based-on-resnet-cnn</a></li> <li><a href="https://www.kaggle.com/khoongweihao/k-fold-tf-efficientnet-models-training" target="_blank">https://www.kaggle.com/khoongweihao/k-fold-tf-efficientnet-models-training</a></li></ul></li> </ul> <h1>Solution Overview</h1> <p><img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1695531%2F1f5423ba0fc5e5bb3bc182c0b8a75b5a%2FOSIC-solution.png?generation=1602040115132884&amp;alt=media" alt="OSIC-solution-overview"></p> <h1>How to construct input data</h1> <p>As I showed in <a href="https://www.kaggle.com/yasufuminakama/osic-lgb-baseline" target="_blank">my notebook</a>, I constructed input data by treating every single measurement as if it were a “baseline” measurement. And “Week” is used to create “Week_passed” for each measurements. We don’t know which “Week” is given in test data, so this input data construction gives us robustness to build models.</p> <h1>How to treat image data</h1> <p>Based on image approach notebooks, I used efficientnet-b0 for image size 320x320. <br> I tried other efficientnet models but there are not so much different results among them when I fix quantile value as 0.5, so I used the smallest one.<br> This efficientnet-b0 output is used for FVC &amp; Confidence model training with tabular features.</p> <h1>FVC prediction</h1> <p>FVC prediction is almost same as my notebooks, the difference is I prepared 5 models and blend them automatically using <code>sp.optimize.minimize</code>, weight is [Lasso, Ridge, ElasticNet, SVM, NN] = [0.68573749, 0., 0., 0.07551167, 0.23750526].</p> <h1>Confidence prediction</h1> <p>Confidence labels are made using FVC oof &amp; <code>sp.optimize.minimize</code> as shown in my notebooks.<br> Confidence prediction is almost same as my notebooks too, the difference is I prepared 5 models and blend them automatically using <code>sp.optimize.minimize</code>, weight is [Lasso, Ridge, ElasticNet, SVM, NN] = [0.22062125, 0., 0., 0., 0.80819966].</p> <h1>About shake up</h1> <p>There are so many public notebooks which overfits Public LB.<br> Public LB has not so much data, so you don't need to care about Public LB so much.</p> <h1>CV and LB Transition</h1> <table> <thead> <tr> <th>Model</th> <th>CV</th> <th>Public</th> <th>Private</th> <th>Medal</th> </tr> </thead> <tbody> <tr> <td>LGB</td> <td>-6.85094</td> <td>-6.9605</td> <td>-7.0037</td> <td>None</td> </tr> <tr> <td>Ridge</td> <td>-6.73738</td> <td>-6.9357</td> <td>-6.8562</td> <td>Bronze</td> </tr> <tr> <td>Efficientnet-b0 + Ridge</td> <td>-6.58651</td> <td>-6.8921</td> <td>-6.8443</td> <td>Silver</td> </tr> <tr> <td>Efficientnet-b0 + Blend models v1</td> <td>-6.54917</td> <td>-6.8922</td> <td>-6.8421</td> <td>Top Silver</td> </tr> <tr> <td>Efficientnet-b0 + Blend models v2</td> <td>-6.53815</td> <td>-6.8972</td> <td>-6.8363</td> <td>Gold</td> </tr> </tbody> </table> <h1>Final result</h1> <p>I selected my best CV, and it was the best Private LB submission.<br> CV (4fold): -6.53815<br> Private LB: -6.8363</p>
OSIC Pulmonary Fibrosis Progression
10th Place Solution
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: OSIC Pulmonary Fibrosis Progression <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Congratz to the winners !</p> <p>Many thanks to kaggle team for hosting this competition,hope the winning solutions will bring useful insight to the problem.</p> <p>My solution is based only on tabular data.</p> <h1>Data Augmentation</h1> <p>The strategy has been shared in many public kernels.<br> You can find it <a href="https://www.kaggle.com/ttahara/osic-baseline-lgbm-with-custom-metric" target="_blank">here</a>.</p> <h1>Validation</h1> <p>I already shared my validation strategy <a href="https://www.kaggle.com/c/osic-pulmonary-fibrosis-progression/discussion/168610" target="_blank">here </a>during the competition.</p> <h1>Features</h1> <p>I use the following features : <code>'base_FVC', 'base_Percent', 'base_Age', 'Week_passed', 'Sex', 'SmokingStatus'</code></p> <h1>FVC Prediction</h1> <p>Final fvc prediction is a mean of the following regressor : </p> <ul> <li>SVM</li> <li>KNN</li> <li>NN</li> <li>Quantile Regressor (0.5)</li> <li>RF</li> <li>LM</li> <li>HuberRegressor</li> <li>ElasticNet</li> <li>Lgbm</li> </ul> <h1>Confidence Prediction</h1> <p>1 - Compute the optimal Confidence value for final fvc,which is actually:<br> <code>Confidence = np.sqrt(2)*np.abs(FVC_true - FVC_pred)</code><br> 2 - Use the same models in FVC prediction to train on the Confidence this time<br> 3 - Train a binary classifier to know if <code>Confidence&lt;=100</code><br> 4 - Use prediction from (2) and post-process them by (3)</p> <h1>Things that didn't work for me</h1> <ul> <li>Everything with image data</li> <li>Linear Augmentation on tabular data</li> </ul>
OSIC Pulmonary Fibrosis Progression
Last 3 CV -6.8746 solution which suffered giant shake up to 1525th place
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: OSIC Pulmonary Fibrosis Progression <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Congrats to winners of this shaky competition. For me, it's very disheartening result…<br> I made effort to achieve good CV score with 3 fold and it was successful at CV -6.8746.<br> I believed that my solution will at least give a silver medal, but my CV betrayed.</p> <p>This is my solution:</p> <p><strong>Features</strong><br> I used tabular features from this notebook<br> <a href="https://www.kaggle.com/ulrich07/osic-multiple-quantile-regression-starter" target="_blank">https://www.kaggle.com/ulrich07/osic-multiple-quantile-regression-starter</a><br> and image features that my teammate <a href="https://www.kaggle.com/samshipengs" target="_blank">@samshipengs</a> engineered (following).</p> <p>total_lung_kurtosis<br> max_slice_lung_skew<br> min_slice_lung_skew<br> total_lung_skew<br> lung_height<br> total_lung_volume</p> <p>This helped much for improving CV (about + 0.05), but private score became dismal.</p> <p><strong>Model 1: Lasso</strong><br> last 3 MAE 182.20 last 3 CV -6.8892</p> <p>I made this model on the final day of this comp.<br> I thought Lasso greatly reduced overfitting, but…<br> This model is following process, all of prediction process is Lasso:</p> <ol> <li>Assume we predict fold 3, construct training data with fold 1&amp;2 data + fold 3 first visit data * 6 (6 times sampled). Simultaneously, construct training data with fold 1&amp;2 data + test first visit data * 2 for test prediciton</li> <li>Predict first FVC value and replace first FVC value with (prediciton + actual value) / 2</li> <li>Predict FVC with adjusted first FVC value + other feats for both training data and validation/ test data, then take absolute value of prediction error of training data</li> <li>Predict absolute value of error then Confidence = max( predicted error * √2, 70)</li> </ol> <p>Using first visit data of validation data worked greatly for CV.</p> <p><strong>Model 2: 4 layers MLP</strong><br> last 3 MAE 185.51 last 3 CV -6.9057</p> <p>This is by my teammate <a href="https://www.kaggle.com/drtausamaru" target="_blank">@drtausamaru</a> .<br> This model predicts FVC and Confidence separately.<br> Using Huber loss for FVC and quantile loss for Confidence. </p> <p><strong>Ensemble</strong><br> FVC = Lasso * 0.65 + MLP * 0.35<br> Confidence = Lasso * 0.5 + MLP * 0.5<br> last 3 MAE 180.50 last 3 CV -6.8746</p>
Google Landmark Retrieval 2020
Finetuning the baseline - silver medal solution [0.285 public LB]
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Google Landmark Retrieval 2020 <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Since the majority of teams just resubmitted a public model, it turned out that in this competition it was enough just to beat the baseline in order to receive a silver medal, which is what I did.</p> <p>My idea for doing that was finetuning a baseline model. It turned out it was much harder than it sounds, due to extensive computational resources required for the task! Here are some pointers on how I was able to train on the huge dataset provided by Google, while using limited computational resources and budget.</p> <p>In order to train a model, I decided to use TPU from Colab Pro (9.99$ / month) since it gives performance comparable to multiple GPUs (so allows for fast iteration), and I was unable to get GPU / TPU quota from Google Cloud.</p> <p>In order to train on the TPUs, the dataset has to be uploaded to Google Storage, preferably in TFRecord format. I used Google Compute Engine to download and prepare the dataset using scripts from <a href="https://github.com/tensorflow/models/tree/master/research/delf/delf/python/training" target="_blank">https://github.com/tensorflow/models/tree/master/research/delf/delf/python/training</a> I think it used around 6$ of Google's 300$ free trial.</p> <p>To sum up - you could beat the baseline for as little as 9.99$ (or even 0$ if you use Kaggle's TPU, but 30h/week was too stringent for me, although it would be more than enough to train the model), if you used TPUs for training.</p> <p>Some tricks I used in order to be able to train on TPUs:</p> <ul> <li>Reimplement model in Keras to get access to high-level APIs for training on TPUs. This required model rewrite in Keras and using this trick: <a href="https://www.kaggle.com/qiubit/fetching-weights-from-baseline-model" target="_blank">https://www.kaggle.com/qiubit/fetching-weights-from-baseline-model</a></li> <li>Only use a subset of 14000 classes (7000 largest and the rest uniformly sampled) out of ~81k available in gldv2_clean dataset, in order to cut the parameters of the ArcFace layer from ~165M to around ~29M. A necessity, since memory on TPU available in Colab is really limited (just 8GB).</li> <li>Only retrain a couple of final layers. I was unable to fit into memory of TPU when re-training entire model. Un-freezing consecutive layers gave subsequent public leaderboard improvements.</li> <li>Uploading TFRecords to multi-region US Google Storage bucket to avoid bills for Network egress from Google Cloud (all TPUs on Colab are currently located in US).</li> </ul> <p>Specific methods used during finetuning:</p> <ul> <li>Data augumentation.</li> <li>Train on 800x800 input (TPU input has to have fixed size for entirety of training). It was inspired by last year's solution of team smlyaka, which suggested larger image size for final epochs. The input size of 800x800 was chosen, because I discovered that this is max dimension of any image in gldv2_clean dataset.</li> <li>Cyclical learning rate, Learning rate finder: <a href="https://www.pyimagesearch.com/2019/07/29/cyclical-learning-rates-with-keras-and-deep-learning/" target="_blank">https://www.pyimagesearch.com/2019/07/29/cyclical-learning-rates-with-keras-and-deep-learning/</a> <a href="https://www.pyimagesearch.com/2019/08/05/keras-learning-rate-finder/" target="_blank">https://www.pyimagesearch.com/2019/08/05/keras-learning-rate-finder/</a></li> <li>Ensemble with 0.277 baseline was used to increase score a little bit.</li> </ul>
OSIC Pulmonary Fibrosis Progression
I should have won gold medal and 12th by trusting my augmentation approach
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: OSIC Pulmonary Fibrosis Progression <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>In the begining i had an augmentation with only tabular data that i knew stable but i didn't choose it. It remembers my M5 blunder. For those interested i post the related notebook here <a href="https://www.kaggle.com/ulrich07/osic-basic-tabular-data-augmentation-nn?scriptVersionId=39788369" target="_blank">https://www.kaggle.com/ulrich07/osic-basic-tabular-data-augmentation-nn?scriptVersionId=39788369</a>.</p>
OSIC Pulmonary Fibrosis Progression
Another first place solution and shake up explanation
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: OSIC Pulmonary Fibrosis Progression <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>These were our best private leaderboard submissions. There was no way to know they were going to win because they were my test submissions.</p> <p><img src="https://i.ibb.co/khVpqpb/subs.jpg" alt="i"></p> <p>The best score is output of a quantile regression model trained with 25 epochs. Another thing to consider is, those models were using baseline Percent instead Percent feature. . All of the public notebooks were using 800 epochs which caused lots of overfitting on training data. Using Percent feature instead of baseline Percent caused models to output non-linear curves. I think those two things caused the shake up.</p> <p>I plotted oof FVC curves in those versions. You can see what kind of predictions did well on private leaderboard.<br> <a href="https://www.kaggle.com/gunesevitan/osic-pulmonary-fibrosis-progression-3-cv-3-model?scriptVersionId=39886853" target="_blank">https://www.kaggle.com/gunesevitan/osic-pulmonary-fibrosis-progression-3-cv-3-model?scriptVersionId=39886853</a></p>
OSIC Pulmonary Fibrosis Progression
A non-selected solution [private lb: -6.8331]
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: OSIC Pulmonary Fibrosis Progression <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>This baseline kernel was made two months ago and I believe many of you could have kernels with a similar result. I don't learn a lot from this result and please feel free to comment on your experience .</p> <p><a href="https://www.kaggle.com/dxchen/fork-of-pytorch-tabular-nn" target="_blank">https://www.kaggle.com/dxchen/fork-of-pytorch-tabular-nn</a></p>
Google Landmark Retrieval 2020
4th place solution and experience sharing
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Google Landmark Retrieval 2020 <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Hi all, here's our brief solution writeup:</p> <h4>What we have tried and works</h4> <ul> <li>Augmentation: such as random crop and rotate. Using AutoAugmentation really helps.</li> <li>Backbones: Resnest200 and Resnet152 due to the resource limit.</li> <li>Pretrain: ImageNet pretrained and Softmax pretrained helps convergence.</li> <li>Loss Function: angular based loss function such as ArcFace.</li> <li>Label Smoothing</li> <li>Cosine learning rate with warmup</li> <li>Larger input size. We try 224, 336, 448 and 560. We choose 448 as final input size because of its higher cost performance. Smaller input size causes a drop in score.</li> </ul> <h4>What we have tried but not works</h4> <ul> <li>EfficientNet B7: we trained b7 in pytorch and transferred it in TF savedmodel format, but it failed with <strong>Notebook Timeout</strong>.</li> <li>Some other large backbones but with lower scores: SEResNext, APolyNet, FishNet, HRNet.</li> <li>Some other hyper param in loss function such as larger or smaller margin.</li> <li>AdaBN</li> <li>DCN</li> </ul> <h4>What we haven't tried</h4> <ul> <li>Larger backbones, such as Resnest269. </li> <li>It seems that B7 works <a href="https://www.kaggle.com/c/landmark-retrieval-2020/discussion/175306" target="_blank">here</a>. Maybe the way we transfer our models from pytorch to tensorflow causes high time cost in the submission.</li> <li>Multi scale input like what baseline model has done.</li> <li>EMA</li> <li>KD</li> </ul> <p>Trained models will be upload in a few days. Thanks.</p>
OSIC Pulmonary Fibrosis Progression
top 9 solution
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: OSIC Pulmonary Fibrosis Progression <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Congratulations to all participants and thanks to organizers for making this competition possible. Despite it didn't go as expected, I hope many people learned something new here. Also, I would like to express my gratitude to my teammates for working together with me on this challenge. Special thanks to <a href="https://www.kaggle.com/jaideepvalani" target="_blank">@jaideepvalani</a> for not giving up on this competition and motivating our team to keep going, without him we would not go that far. Though, getting the medal I have a little bit bitter feeling. I'll take this chance and describe some of our ideas: hopefully they could help organizers to fight fibrosis. </p> <h3>CT model: Concatenate Tile Pooling</h3> <p>Working on PANDA competition I have proposed <a href="https://www.kaggle.com/c/prostate-cancer-grade-assessment/discussion/169205" target="_blank">Concatenate Tile Pooling</a> method, which also appeared to be applicable quite well for CT scan data. The idea of this method is illustrated in image below. Instead of assigning labels, like FVC decay and confidence to each CT layer, which may be difficult to predict based on a single image, why not to assign it to all images together?<br> <img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1212661%2Fde95b636611aa0e65432f4dcf6756269%2Ftile.png?generation=1602038549896215&amp;alt=media" alt=""><br> <strong>why not 3D conv?</strong></p> <ul> <li>CT scans have different spacing, which deteriorates performance of 3D models. It can be viewed as training and performing inference with random stretch of images along one dimension.</li> <li>Many accurate and well-optimized 2D pretrained models.</li> <li>Not possible to train a good 3D model from scratch for so limited data</li> </ul> <p><strong>Important details:</strong></p> <ul> <li>Since the provided data is very limited, just ~150 samples, train the model first on masked lungs only (masks are produced with <a href="https://github.com/JoHof/lungmask/" target="_blank">lungmask</a>) with following finetuning on the original images to be able to perform inference without lungmask (So I could do inference of a single 4 fold model within just 10-20 min at kaggle). Check the image below.<br> <img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1212661%2F31a1d24eb0da1882deb565777c1281f2%2Fmasks.png?generation=1602039389832792&amp;alt=media" alt=""></li> <li>For CT models it's better to predict percent rather than FCV. Image augmentation, like zoom, as well as use only of a limited number of slides makes it difficult to compute the volume based on CT. Meanwhile, the model could more reliably say what is the percent of the entire volume is affected by fibrosis by looking just at several scans.</li> <li>Assume linear dependence of the FVC and confidence on the week and predict the slope and the initial value.</li> <li>LLL_loss (Laplace Log Likelihood) works but for convergence one needs to ensure that the output at the beginning of training is close to the gt FVC. I used the following: <code>FVC = V0*(0.01*a*(w-w0)/134 + b + 0.01*p0)</code>, <code>sigma = V0*softplus(c*w/134 + d)</code>, were a,b,c,d are model predictions, V0 is the full lung volume computed as V0 = 100*FVC/percent. So, initially the predicted FVCs for model before training are quite close to the expected FVC, and the loss converges nicely. I have computed the loss based on all FVC measurements for a given patient (dropping the first one), so there was no need to evaluate gt slops explicitly. An alternative could be doing something similar to public kernels: model tries to predict FVC directly with using mloss, followed by model finetuning with LLL_loss (which is essentially the metric in this competition).</li> <li><a href="https://www.kaggle.com/c/prostate-cancer-grade-assessment/discussion/169205" target="_blank">Tile cutout</a> - random selection of CT layers during training could be viewed as a cutout in 3d image.</li> <li>When work with the data try to plot it to see what is really going on. For a number of patients I saw incorrect offsets, so the level of signal must be changed. Also I clipped signal at [-1024,600]. Finally, some images are not square, so I needed to take a crop to prevent deformation of images when rescale. </li> </ul> <p><strong>Additional details:</strong><br> 64 layers x 256 x 256 setup<br> ResNeXt50 and ResNet18 backbones<br> Standard augmentation like rotation, zoom, horizontal flip at the pretraining stage.<br> Unfortunately, this beautiful approach didn't work well giving only ~6.85/6.90 at private/public LB.</p> <h3>Tabular models</h3> <p>This is quite standard, and one can find many examples in public kernels. <strong>The important thing: always do proper validation and exclude all kinds of leaks.</strong> So percent must not be used as a feature unless it is set to be equal to the value at the first visit (and the first visit must be excluded from training and validation). Also, we have computed validation based on last 3 visits, similar to the competition metric. We have 2 kinds of models: based only on tabular and tabular+CT features (with some additional variations). <br> Some thoughts about <strong>percent madness</strong> people used in public kernels: It seems that by chance public LB contains mostly cases with low slope (FVC decay rate), so anything that artificially reduces slope could boost public LB. If one is training with percent feature and then set it to the constant, it is equivalent to pivoting the prediction in such a way that reduces the slope. </p> <h3>Final submission</h3> <p>Our final submission is an ensemble of CT models + TAB NN based models + <a href="https://www.kaggle.com/jeabat/osic-bayesian-ridge-regression" target="_blank">Bayesian Ridge Regression</a> based on maximizing CV. This submission got 6.8385/6.8884 at private/public LB. It is surprising for so large shake up: we have chosen our best private LB sub.</p>
SIIM-ISIC Melanoma Classification
12th Place unexpected result
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: SIIM-ISIC Melanoma Classification <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>This was my 2nd competition in which I invested time. My strategy was this: I ordered notebooks and discussion posts by Chris Deotte <a href="https://www.kaggle.com/cdeotte" target="_blank">@cdeotte</a> by date and basically implemented each of those kernels and suggestions from discussion posts. I did training in colab and tried to follow his recommendation of first experimenting with lower resolution images and simpler models. Also, he posted a link to previous years winners where they used ensembles of models with progressively more complex model architectures using progressively higher resolutions. That idea did not work that well for me, the lower complexity models did not perform very well. But I stuck with them for the final submission and weighted the lower models (BO with 128, B1 with 192 etc, ) very very low. </p> <p>I do not think this gold medal is deserved. I was hoping for a top 20% finish. I think that would have been a fair reflection of my intellectual contribution. They're still working with the results, so it could still be that the final standing is more accurate. I think the one thing I did learn is that ultimately I need to be able to write notebooks like the TFR Triple Stratified from scratch. Similarly, I learned from various discussion posts threads.</p>
Global Wheat Detection
Updated lb position 228 ,unselected 15th place
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Global Wheat Detection <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>It is clearly known factor that there many noisy bbx in the train data unlike test data. <br> Here are things that worked best for me in 10 days</p> <p>1) Label correction of small bounding boxes by decreasing the x,y with 2 percent and increasing width ,height by factor of 1.5 . This would have enlarged very point size bbx to some visible level without affecting much accuracy of bboxes</p> <p>2) Removing all bbx with area less than 500 after above correction</p> <p>3) Pseudo label training with img size 1024 by removing the noisy train images and usign it along with test images which were far more accurate. </p> <p>4) 512 img size model worked best on Public LB but it was 1024 that worked best on private LB,it is true in atleast my case.</p> <p>These above were key things i could think of at best in last 10 days. <br> I regret i dint select the submission of 1024 img size worked based on above observation and it apparently turned to be one scoring highest in Private lb but moderately on public lb. 67.13 unselected </p> <p>Few other things due short of time i couldnt explore was Faster RCNN with mobile Net v2 , this was light model could have worked in this competition. </p> <p>Congrats to all top positions..</p> <p>May be if i had joined earlier could have been better placed.</p> <p>Next Competition is OSIC…</p>
Google Landmark Retrieval 2020
8th place solution
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Google Landmark Retrieval 2020 <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>First, thanks to Google and Kaggle for hosting this competition and congratulations to the winners :)</p> <p>Since our solution is quite similar to the ones already posted and to DELG itself, I'll keep it simple and brief</p> <h3>Dataset</h3> <ul> <li>GLDv2 clean</li> <li>80% training, 20% val split by image</li> </ul> <h3>Loss</h3> <ul> <li>ArcFace Layer<ul> <li>Margin: 0.3</li> <li>Scale: 46</li></ul></li> </ul> <h3>Models</h3> <ul> <li>ResNet101</li> <li>EfficientNetB5</li> <li>GeM pooling<ul> <li>p=3 frozen for R101</li> <li>p trained for B5</li></ul></li> <li>2048d descriptors by applying FC + BN after pool</li> </ul> <h3>Training</h3> <ul> <li>Trained until convergence at 512x512</li> <li>Fine-tuned for a few epochs at 640x640</li> <li>Around 35 epochs for R101 and 20 for B5</li> </ul> <h3>Inference</h3> <ul> <li>Multi-scale TTA<ul> <li>R101: Resize to (640, 768) squared images </li> <li>B5: Resize to 640 squared images + resize to 1024 preserving AR</li> <li>2048d descriptors per model by averaging multi-scale predictions followed by l2-normalization</li></ul></li> <li>Ensembling by concatenating model's predictions into a 4096d descriptor followed by l2-normalization</li> </ul>
OSIC Pulmonary Fibrosis Progression
67th Place Solution but Just ElasticNet performed way better!
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: OSIC Pulmonary Fibrosis Progression <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Thanks to OSIC and Kaggle for hosting this competition. It was lot of fun exploring and learning from public kernels, discussion forums and testing new methods</p> <p><strong>Brief Summary</strong><br> Our Solution is an ensemble of EffNet B5 with competition metrics for evaluating CV performance. Quantile Regression with modified loss functions and ElasticNet</p> <ul> <li>EffNet B5 -&gt; (520x520) -&gt; Linear Decay based on EffNet for coefficient prediction, CV performance evaluated based on competition metrics</li> <li>Quantile Regression with modified loss function</li> </ul> <pre><code>def new_asy_qloss(y_true,y_pred): qs = [0.2, 0.50, 0.8] q = tf.constant(np.array([qs]), dtype=tf.float32) e = y_true - y_pred epsilon = 0.8 v = tf.maximum( -(1-q)*(e+q*epsilon), q*(e-(1-q)*epsilon)) v1 = tf.maximum(v,0.0) return K.mean(v1) </code></pre> <ul> <li>ElasticNet with 10folds on GroupKFold </li> </ul> <p>And finally an ensemble of all the models.</p> <p><strong>Just an ElasticNet on 10folds with GroupKfold performed better compared to our ensemble submission.</strong></p> <p><a href="https://www.kaggle.com/jagadish13/osic-baseline-elasticnet-eda-testing?scriptVersionId=43936071" target="_blank">Check: ElasticNet Final Submission</a></p> <p><strong>Congrats to all the winners!</strong></p>
Cornell Birdcall Identification
13th place digest
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Cornell Birdcall Identification <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>It was my first audio competition and I really enjoyed it! Thanks to organizers and Kaggle for it.<br> Thanks to my teammates <a href="https://www.kaggle.com/tikutiku" target="_blank">@tikutiku</a> <a href="https://www.kaggle.com/zfturbo" target="_blank">@zfturbo</a> the great collaboration, it was a pleasure and I've learnt a lot again.</p> <p>Here is a digest of our solution.</p> <p><strong>Main Pipeline</strong> (see image below):</p> <ul> <li>MEL-Spectrogram (torchaudio) with differents settings to capture most birds frequency shapes.</li> <li>Most processing/augmentation occurs in GPU to speed up training and inference.</li> </ul> <p><strong>Time Augmentations</strong>:</p> <ul> <li>Pink Noise/White noise</li> <li>Time roll</li> <li>Volume gain</li> <li>PitchShift</li> <li>Additional bandpass filters,lowcut (1kHz-2.5kHz), highcut (10kHz-15kHz)</li> <li>Background/Ambient noise Mixup</li> <li>Other birds Mixup (2 to 3 birds)</li> </ul> <p><strong>Spec/Image augmentations</strong>:</p> <ul> <li>Frequency/time masking</li> <li>Color jitter</li> </ul> <p><strong>CNN backbones</strong>:</p> <ul> <li>EfficientNet B1 and B2</li> <li>SEReseXt26</li> <li>ResneSt50</li> <li>Optional GRU layer to learn about time sequences (see <a href="https://github.com/srvk/TALNet" target="_blank">TALNet Sound Event Classifier</a>)</li> <li>Different pooling to apply SED concept with either Attention block or max pooling<br> We also had one model based on 1D signal only (DensetNet1D)</li> </ul> <p>What did not work well (it worked but was disapointing):</p> <ul> <li>Wavegram + MEL-Spectrogram model (was bad with soundscape)</li> <li>Create large image with 3x2 grid spectrogram (was bad on inference)</li> </ul> <p><strong>Data</strong>:</p> <ul> <li>Train audio provided with duration outliers removed</li> <li>Additional xeno-canto data (from Vopani dataset, thanks <a href="https://www.kaggle.com/rohanrao" target="_blank">@rohanrao</a> for your clean dump)</li> <li>Distractors (NoBird/Nocall/Ambient) 10s slices (from freefield1010)<br> We've built our own validation data by mixing test_audio/birds/noise/nocall to try to correlate LB. It correlated a bit but was not enough to give trust in it. Too bad as it was key for this competition.</li> </ul> <p><strong>Training procedure</strong>:</p> <ul> <li>Stage1: Train a few models with 5s slices picked randomly, then save birds probabilities on CV OOF, ensemble all OOF models results to generate "<em>hot</em>" slices with high probabilities.<br> It allowed to reach public LB=0.582</li> <li>Stage2: Train more models with only such 5s <em>hot slices</em>.<br> It allowed to reach public LB=0.596<br> While reading other's solutions, we should have tried another stage with "very hot" slices to have a super clean train dataset.</li> </ul> <p><strong>Final ensemble</strong>:<br> Ensemble is a combination of models (8 to 10) with union strategy and with per-model threshold tuned on public LB (it overfitted for sure).<br> Idea of union was to capture most of the TP (better for metric used in this competition), drawback is that we capture FP too.<br> Inference was fast, we cached resampled audio in memory, and (almost) full GPU pipeline helped. It ran in around 1h30 so we still had room for more models.</p> <p><strong>Post-processing</strong>:<br> We have a "nobird" majority vote to try to remove FP (force nocall) as some models have been trained with 265 classes instead of 264 (class 265 = nobird)</p> <p>Both our final submissions reached similar score on private LB.</p> <p><img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F698363%2F4e2db4b7460eb1a51737fbf81bd8ed50%2Fpipeline.png?generation=1600274872405000&amp;alt=media" alt=""></p> <p>Final words to conclude: Congratulations to top teams! and thanks to <a href="https://www.kaggle.com/hidehisaarai1213" target="_blank">@hidehisaarai1213</a>, <a href="https://www.kaggle.com/hengck23" target="_blank">@hengck23</a> for their sharings.</p>
SIIM-ISIC Melanoma Classification
[Summary] Public 11 Private 23 and Congrats to a new Master
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: SIIM-ISIC Melanoma Classification <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>First of all, congratulations to everyone who insists on CV and finally got its deserved place ! 😁</p> <p>A lot of thanks to my teammates <a href="https://www.kaggle.com/jielu0728" target="_blank">@jielu0728</a> <a href="https://www.kaggle.com/meliao" target="_blank">@meliao</a> <a href="https://www.kaggle.com/dandingclam" target="_blank">@dandingclam</a> <a href="https://www.kaggle.com/captain0602" target="_blank">@captain0602</a> 😏Even though a little frustrated with the final result because we had hoped to win a gold. We were almost the least shaken among the top teams. </p> <p>Our 0.9451 solution ranked 6th among all our 300+ submissions, and our 2 highest submissions are 0.9462. But I don’t regret it personally, because these submissions looked so inconspicuous, they are neither the highest CV nor the highest LB. I would never think of choosing them even with 10 extra days.</p> <h3>[Final submissions]</h3> <p>Ensemble 1 (trust lb) : Our best public LB 0.9723 (private 9268)<br> Ensemble 2 (trust model number) : Simple Average Rank on 18 submissions between LB 0.9680 and 0.9700 (private 9397)<br> Ensemble 3 (trust cv) : Simple Average Rank of 12 best models gives CV 0.9517 (private 9451)</p> <h3>[Single models]</h3> <p>In the image section, we made improvements based on <a href="https://www.kaggle.com/cdeotte/triple-stratified-kfold-with-tfrecords" target="_blank">chris's notebook</a>.<br> We tried training with B0-7 on image sizes of 256, 384, 512, 600, 768. </p> <p>ResNet gives smaller gap but we didn’t use due to their low public scores.</p> <p>Our best single model CV : 0.942-943, best LB : 9578</p> <p>In the metadata section, we tried ridge, xgb, and lgb. But nothing was better than a weighted blend with <a href="https://www.kaggle.com/titericz/simple-baseline" target="_blank">Giba's baseline</a></p> <h3>[What worked]</h3> <p>BCE + Focal loss (FL) =&gt; details in the end<br> Using Effnet on their best resolutions. Ex. 384 with B4, 512 with B5<br> Using upsample and 2018ext data<br> Gridmask, we found gridmask is better than coarse dropout =&gt; details in the end<br> noisy-student, train 18 epochs, early stop, train 15 folds help for some models</p> <h3>[What didn't work]</h3> <p>Add hair augment<br> Save model using lowest loss<br> Change seed<br> Change class weights in FL<br> Extreme upsample, like 25X upsample on 2020 mal</p> <h3>[How we achieved public LB 9723]</h3> <p>9603 : unweighted gmean on 3 single models</p> <p>9643 : 9603 * 0.4+giba's baseline * 0.6</p> <p>9694 : 9643+<a href="https://www.kaggle.com/datafan07/eda-modelling-of-the-external-data-inc-ensemble" target="_blank">9577</a> then <a href="https://www.kaggle.com/khoongweihao/post-processing-technique-c-f-1st-place-jigsaw" target="_blank">post-processing</a></p> <p>9723 : minmax post-processing</p> <p>When I reached 9694, I knew I was overfitted. Because there are few such complicated winning solutions in Kaggle Competitions, but like most people, I cannot restrain myself from seeking a higher LB score. Facts once again prove that simple solutions are better 😑</p> <h3>[BCE+FL]</h3> <pre><code>def Focal_Loss(y_true, y_pred, alpha=0.25, gamma=2, weight=5): y_true = K.flatten(y_true) y_pred = K.flatten(y_pred) BCE = K.binary_crossentropy(y_true, y_pred) BCE_EXP = K.exp(-BCE) alpha = alpha*y_true+(1-alpha)*(1-y_true) focal_loss = K.mean(alpha * K.pow((1-BCE_EXP), gamma) * BCE) return BCE+weight*focal_loss </code></pre> <h3>[Grid Mask]</h3> <pre><code>def add_mask(img, dim): num_grid = 3 gm = GridMask(mode=0, num_grid=num_grid) gm.init_masks(dim,dim) init_masks = tf.cast(gm.masks[0], dtype='float32') init_masks = tf.stack([init_masks]*3, axis=2) rotated_masks = transform(init_masks, DIM=init_masks.shape[0]) mask_single = tf.image.random_crop(rotated_masks,[dim,dim,3]) img = img*mask_single return img </code></pre>
OSIC Pulmonary Fibrosis Progression
Solution for the first place, but we didn't select
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: OSIC Pulmonary Fibrosis Progression <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>We'd like to first thank Open Source Imaging Consortium (OSIC) and Kaggle for providing us with an interesting, real-world dataset of decline in lung function based on a CT scan of their lungs to play with!</p> <p>We are very happy to get our first silver medal in Kaggle from this competition.</p> <p>It was really difficult to select the best model. We trusted our CV score and selected our model for the submission, which allowed us to win a silver medal.<br> However, the fact that we had a first-place solution, it shows how difficult to select the best model for this competition.</p> <p>We shared our first-place solution (didn't select) in the notebook below. I think the embedding layer helped improve the score.</p> <p><a href="https://www.kaggle.com/lhagiimn/solution-for-the-first-place-but-we-didn-t-select" target="_blank">https://www.kaggle.com/lhagiimn/solution-for-the-first-place-but-we-didn-t-select</a></p>
Google Landmark Retrieval 2020
[Update] 3rd place solution
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Google Landmark Retrieval 2020 <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>[Update 2020/10/09] our code: <a href="https://github.com/Raykoooo/3rd_place_to_Kaggle_Google_Landmark_Retrieval_2020" target="_blank">https://github.com/Raykoooo/3rd_place_to_Kaggle_Google_Landmark_Retrieval_2020</a></p> <p>[Update] arxiv: <a href="https://arxiv.org/abs/2008.10480" target="_blank">https://arxiv.org/abs/2008.10480</a></p> <p>Our solution:<br> <a href="https://drive.google.com/file/d/1QOeQqVckIlvDAWfAh0E_lrMEqmQR_Bzr/view" target="_blank">https://drive.google.com/file/d/1QOeQqVckIlvDAWfAh0E_lrMEqmQR_Bzr/view</a></p> <p>We have submitted a paper describing our method to arxiv. But it cannot be accessed now. Once the arxiv link of the paper can be accessed, we will immediately post it here. </p>
Cornell Birdcall Identification
43rd place solution
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Cornell Birdcall Identification <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Big thank you to HOSTKEY for allowing me to use a machine with 2x1080Ti as a grant. You can check them out here: <a href="https://www.hostkey.com/gpu-servers#/" target="_blank">https://www.hostkey.com/gpu-servers#/</a> HOSTKEY servers are cheaper than AWS and Google Cloud, and they are offering pre-orders for servers with RTX 3080's on them.</p> <p>The goal of this competition is to predict the species of bird in a soundscape recording, given non-soundscape recordings. Basically, they give you a 5 second clip recorded in a forest, and you have to say what birds they are. There are 264 species in total to predict.</p> <p>The difficulties in this competition come from: </p> <ol> <li>The training data is from recordings of any birdwatchers - anyone can record and upload, which means sometimes it is recorded just on a smartphone, there is speech in it, etc. However, the testing data is recorded from boxes strapped to trees, recording for 10 minutes at a time.</li> <li>The training data is of variable length, from seconds to minutes. The data is recorded at different sample rates, at different volumes, in different locations. The test data comes from 3 unknown sites.</li> <li>Some species of birds make different birdcalls even though they are the same species. There are regional dialects of birdcalls. And some calls can vary (alarm call, mating call, etc.)</li> <li>The training clips can have different birds in the background, or they have long periods of no birds.</li> <li>You can have false positives through other animals like chipmunks, cicadas, flies, cars driving nearby, etc.</li> </ol> <p>It is evident that the training data is extremely different from the testing data. I noticed that an improvement in my validation loss on a 20% holdout set from the training set yielded weaker leaderboard results on the hidden test set.</p> <p>Then, I decided to train for lots more epochs, past the optimum for my validation loss. This ended up getting better on the leaderboard. So I concluded that training more epochs = better score, even if I considered it locally overfit.</p> <p>In order to address Difficulty #1, I randomly augment my training clips. I add pink noise with varying volumes, and random soundscape recordings (up to 3 with different volumes). I also randomly applied a Butterworth filter (randomly lowpass, highpass, bandpass, bandstop) with random cutoffs. I also used Cutout augmentation, which randomly replaces an area of the clip with noise pixels. I also randomly use ColorJitter to change saturation, hue, brightness, and contrast. <strong><em>You can see I use the word "random" so much -- I really wanted to make sure my submission was very robust.</em></strong> Much of these ideas are inspired from previous Birdclef solution: <a href="http://ceur-ws.org/Vol-2125/paper_140.pdf" target="_blank">http://ceur-ws.org/Vol-2125/paper_140.pdf</a></p> <p>In order to address Difficulty #2, I randomly sample 5 second clips from the training clips. If the clip is less than 5 seconds, then add 0's to the start/end of the clip randomly.</p> <p>I hoped the model could cope with Difficulty #3 by itself.</p> <p>In order to address Difficulty #4's long periods of no birds, I removed contiguous stretches &gt;= 4 seconds in my training clips where the absolute signal amplitude doesn't exceed the 99.9th quantile. This effectively removed long contiguous seconds of silence, which allows my model to focus more on the birdcalls and less on the absence of birds. I did not use "secondary_labels" for different birds in a single clip because I found it empty or inconsistent in many clips.</p> <p>In order to address Difficulty #5, I also added examples of chipmunks/insects as background noise to tell my model that it is an absence of birds.</p> <p>All models converted the 5 second training clip into a Melspectrogram, which is a 2D "picture" that represents what the sound looks like. Some models then used Power_to_Db function to convert the power spectrogram to decibel units; this is called Log-Melspectrogram. Other models used PCEN which is a novel transformation shown to outperform Log-Melspectrograms (<a href="http://www.justinsalamon.com/uploads/4/3/9/4/4394963/lostanlen_pcen_spl2018.pdf)" target="_blank">http://www.justinsalamon.com/uploads/4/3/9/4/4394963/lostanlen_pcen_spl2018.pdf)</a>.</p> <p>I trained one Efficientnet-B1, two Efficientnet-B2, one Efficientnet-B3 (<a href="https://arxiv.org/abs/1905.11946)" target="_blank">https://arxiv.org/abs/1905.11946)</a>, one Resnest50 (<a href="https://arxiv.org/abs/2004.08955)" target="_blank">https://arxiv.org/abs/2004.08955)</a>, two Inceptionv4 (<a href="https://arxiv.org/abs/1602.07261)" target="_blank">https://arxiv.org/abs/1602.07261)</a>, and one SE-Resnext (<a href="https://arxiv.org/abs/1709.01507)" target="_blank">https://arxiv.org/abs/1709.01507)</a>. I also trained an Efficientnet-B5 and more Resnest50/101, but it would not fit into the runtime to use these models. I also trained a 1D Convolutional Net but it wasn't strong enough. All models were initialized with pretrained imagenet weights. Some models have mixup and some have label smoothing for additional diversity.</p> <p>In order to fit all of these models in the runtime, I converted all models into ONNX format which brought significant speedup.</p> <p>Instead of averaging the predictions, I found that squaring the predictions, taking the mean, and then taking square root was better (follows from Lasseck's findings in previous Birdclef competition). I early stopped the models through intuition and Leaderboard feedback.</p> <p>I trained on full 100% training data blindly, using BinaryCrossEntropyWithLogits as the loss. All models have different Melspectrogram parameters. I found that using high <code>fmin</code> parameter was good to get rid of some noisiness (effectively simulates a "zoom" into the birdcalls). Different image sizes and <code>n_mels</code> were also used. Different model heads were used (with different dropouts and number of Linear layers)</p> <p>Special thanks to the strong Japanese Kaggle contributors (Tawara and Hidehisa Arai) and thank you to thesoundofai.slack.com for inspiration and tips.</p> <p>Things that worked:</p> <ul> <li>Cutting out silence from training data</li> <li>Overlaying noise onto training data</li> <li>Data augmentation methods (noise injection, Cutout, ColorJitter, etc.)</li> <li>Squaring predictions, averaging, then Square Rooting</li> <li>Ensemble with different parameters</li> </ul> <p>Things that didn't work:</p> <ul> <li>ArcFace Loss</li> <li>Custom F1 Row-wise Micro Loss</li> <li>MultiLabelSoftMarginLoss</li> <li>Freesound2019 Winning CNN solution architecture</li> <li>Removing the top k losses from each batch, assuming some clips are still noisy/incorrect in training data</li> <li>Using Freesound non-bird audio external dataset</li> <li>Using NIPS 2013 Bird identification external dataset</li> </ul> <p>Things I didn't try:</p> <ul> <li>Adding in MFCC information or other numeric features</li> <li>Using external Xenocanto data</li> <li>PANN/pretrained "audionet" models</li> </ul>
Cornell Birdcall Identification
7th place solution (writeup with code)
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Cornell Birdcall Identification <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>First of all, congratulations to all the participants, and thanks a lot to the organizers for this competition! It was great fun!</p> <p>In short, our approach was based on <a href="https://github.com/f0k/birdclef2018" target="_blank">Jan's Sound Event Detection model from BirdCLEF 2018</a>, replacing the predictor with a pretrained CNN from <a href="https://github.com/qiuqiangkong/audioset_tagging_cnn" target="_blank">Qiuqiang Kong's PANN repository</a>. It was trained on 30-second snippets from the official training set extended with <a href="https://www.kaggle.com/c/birdsong-recognition/discussion/159970" target="_blank">Rohan Rao's xeno-canto crawls</a>, using binary cross-entropy against all labeled foreground and background species. Data was augmented by choosing random weights for downmixing the left and right channel to mono (for stereo files), and by mixing in bird-free background noise from the <a href="https://doi.org/10.5285/be5639e9-75e9-4aa3-afdd-65ba80352591" target="_blank">Chernobyl BiVA</a> and <a href="https://zenodo.org/record/1205569" target="_blank">BirdVox-full-night</a> datasets. Inference followed a two-stage procedure that first established a set of species for the recording, using 20-second windows and a threshold of 0.5, then looked for these species in 5-second windows with a threshold of 0.3. Code is <a href="https://github.com/f0k/kagglebirds2020" target="_blank">available on github</a>.</p> <p>The following sections will explain things in more detail, spread over additional posts due to Kaggle's post size limit. Choose "Sort by: Oldest" to see them in their original order.</p> <p>If you prefer a slide deck over text, feel free to click through <a href="https://docs.google.com/presentation/d/10m0W13sJozYmfWPcPlaBg1j-MOW7p6w_-Tp3pG5KGE0/edit?usp=sharing" target="_blank">some slides explaining what we did</a>.</p>
SIIM-ISIC Melanoma Classification
12th place solution
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: SIIM-ISIC Melanoma Classification <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>First of all thanks to the Kaggle community for active participation in the discussions and notebooks. A special mention to the pipeline set by <a href="https://www.kaggle.com/cdeotte" target="_blank">@cdeotte</a> in his great notebook Triple Stratified KFold with TFRecords (<a href="https://www.kaggle.com/cdeotte/triple-stratified-kfold-with-tfrecords)" target="_blank">https://www.kaggle.com/cdeotte/triple-stratified-kfold-with-tfrecords)</a>. It helped us (<a href="https://www.kaggle.com/vikrant06" target="_blank">https://www.kaggle.com/vikrant06</a> and me) quickly try out multiple configurations of EffNet. What also seemed to work was the 'noisy-student' Effnet weights. </p> <p>We used 3 folds including the data of 2018 and 2019 on 384x384 images along with brightness and contrast augmentation on B5, B6 and B7 (imagenet and noisy student weights for each) ensembled using power averaging with the power of 2. </p> <p>The resultant ensemble when ensembled (weighted average) against the top 4 public leaderboard solutions (which were ensembled using power averaging with the power of 2) gave us Public LB score of 0.9644 and private LB score of 0.9458.</p>
OSIC Pulmonary Fibrosis Progression
Probably simplest solution - 180 lb
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: OSIC Pulmonary Fibrosis Progression <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>i just made good (kfold == 20) validation and found one coefficient manually, that's all)<br> <a href="https://www.kaggle.com/lao777/baseline?scriptVersionId=40987085" target="_blank">link</a></p>
Google Landmark Recognition 2020
3rd Place Solution — A Pure Global Feature Approach
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Google Landmark Recognition 2020 <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Thanks to the organizers and congrats to all the winners! Our ( <a href="https://www.kaggle.com/haqishen" target="_blank">@haqishen</a> <a href="https://www.kaggle.com/boliu0" target="_blank">@boliu0</a> <a href="https://www.kaggle.com/garybios" target="_blank">@garybios</a> <a href="https://www.kaggle.com/alexanderliao" target="_blank">@alexanderliao</a>) solution is a pure global feature metric learning approach with some tricks.</p> <h2>architecture: sub-center ArcFace with dynamic margins</h2> <p>ArcFace (<a href="https://arxiv.org/abs/1801.07698" target="_blank">paper</a>) has become a standard metric learning method on Kaggle over the past two years or so. In this competition, we used Sub-center ArcFace (<a href="https://www.ecva.net/papers/eccv_2020/papers_ECCV/papers/123560715.pdf" target="_blank">paper</a>), a recent improvement over ArcFace by the same authors. The idea is that each class may have more than one class center. For example, a certain landmark's photos may have a few clusters (e.g. from different angles). Sub-center ArcFace's weights store multiple class centers' representations, which can increase classification accuracy and improve global feature's quality.</p> <p>The classes in GLD dataset are extremely imbalanced with longs tails. For models to converge better in the presence of heavy imbalance, smaller classes need to have bigger margins as they are harder to learn. Instead of manually setting different margin levels based on class size, we introduce <em>dynamic margins</em>, a family of continuous functions mapping class size to margin level. This give us some major boost. Details to be described in paper.</p> <p>We train the model using ArcFace loss only.</p> <h2>validation scheme</h2> <p>Stratified 5-fold. Training using 4 folds, validate on only 1/15 of 1 fold to save time. Use different folds for different single models, for maximal diversity in ensemble.</p> <p>We use GAP metric to validate. CV GAP is very high compared to LB. All model's CV GAP are over 0.967. Good news is that CV GAP and LB have high correlation.</p> <h2>test set predicting strategy</h2> <ul> <li>If we use model's ArcFace head to predict test set, our best single fold model's public LB is only <strong>0.564</strong></li> <li>A better strategy is to calculate the global feature cosine similarity of each [private train image, private test image] pair, and use the top1 neighbor and corresponding cosine similarity of each test image as prediction. This gives us <strong>0.604</strong> public LB for the same single fold model</li> <li>Instead of using top1 neighbor only, we can improve it by combining top5 neighbors and their similarities. Best combining function is 8th power. <br> E.g. let's say test image A's top5 neighbors and their cosine similarities are: class 1 (0.9), class 2 (0.8), class 2 (0.7), class 1 (0.5), class 3 (0.45). Then class 1's total score is <code>0.9**8 + 0.5**8 = 0.434</code>; class 2's total score is <code>0.8**8 + 0.7**8 = 0.225</code>. So we predict class 1 with p=0.434<br> LB increases to <strong>0.610</strong></li> <li>We can further improve it by incorporating ArcFace head's predictions with 12th power. In above example, assuming image A's ArcFace head give class 1 score = 0.75, class 2 score = 0.88. Then class 1's total score becomes <code>(0.9**8 + 0.5**8) * 0.75**12 = 0.0138</code>; class 2's total score becomes <code>(0.8**8 + 0.7**8) * 0.88**12 = 0.0486</code>. Now we predict class 2 with p=0.0486<br> LB increases to <strong>0.618</strong></li> </ul> <h2>augmentations</h2> <p>We resize all images to square shape without cropping.</p> <pre><code>import albumentations as A A.Compose([ A.HorizontalFlip(p=0.5), A.ImageCompression(quality_lower=99, quality_upper=100), A.ShiftScaleRotate(shift_limit=0.2, scale_limit=0.2, rotate_limit=10, border_mode=0, p=0.7), A.Resize(image_size, image_size), A.Cutout(max_h_size=int(image_size * 0.4), max_w_size=int(image_size * 0.4), num_holes=1, p=0.5), A.Normalize() ]) </code></pre> <h2>pretraining and finetuning</h2> <ul> <li>In cGLDv2 (cleaned GLDv2), there are 1.6 million training images and 81k classes. All landmark test images belong to these classes.</li> <li>In GLDv2, there are 4.1m training images and 200k classes, among which 3.2m images belong to the 81k classes in cGLDv2.</li> </ul> <p>We noticed that (1) training with the 3.2m data gives better results than only the 1.6m competition cGLDv2 data, (2) pretraining on all 4.1m data then finetuning on 3.2m data gives even better results.</p> <h2>3-stage training schedule</h2> <ul> <li>Stage 1 (pretrain): 10 epochs with small image size (256) on 4.1m data</li> <li>Stage 2 (finetune): about 16 epochs with medium image size (512 to 768 depending on model) on 3.2m data. Number of epochs varies by model and ranges from 13 to 21. </li> <li>Stage 3 (finetune): 1 epoch with large image size (672 to 1024) on 3.2m data</li> </ul> <p>Note: above schedules are for Sub1 (private 0.6289). Sub2 has higher score (private 0.6344) but more complex schedules, i.e. longer with more rounds of finetuning. Both submissions are 3rd place.</p> <h2>ensemble</h2> <p>7 models: EfficientNet B7, B6, B5, B4, B3, <a href="https://github.com/zhanghang1989/ResNeSt" target="_blank">ResNeSt101</a>, <a href="https://github.com/clovaai/rexnet" target="_blank">ReXNet2.0</a></p> <p>For global feature neighbor search, we concatenate each model's 512-dimension feature; for ArcFace head, we take simple average of each model's logits.</p> <p>Best single model is EfficientB6. <strong>private = 0.6005, public = 0.6179</strong> (We didn't submit all the epochs, there may be higher ones)<br> Sub1 is 7 model ensemble. <strong>private = 0.6289, public = 0.6604</strong><br> Sub2 is 9 model ensemble (B5 and B6 twice). <strong>private = 0.6344, public = 0.6581</strong></p> <h3>[update 10/12/2020]</h3> <p>paper: <a href="https://arxiv.org/abs/2010.05350" target="_blank">https://arxiv.org/abs/2010.05350</a><br> repo: <a href="https://github.com/haqishen/Google-Landmark-Recognition-2020-3rd-Place-Solution" target="_blank">https://github.com/haqishen/Google-Landmark-Recognition-2020-3rd-Place-Solution</a></p>
Google Landmark Recognition 2020
(Public>0.54) Provisional 36th solution and kernel
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Google Landmark Recognition 2020 <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Thank Kaggle for hosting this awesome competition! And congrats the top teams!<br> This link is our kernel (version 10) <br> <a href="url" target="_blank">https://www.kaggle.com/tangshuyun/lb-0-54-effnetb6b7-global-feature</a><br> Our approach is very straightforward and simple:<br> Thanks to Ragnar's awesome kernel of training Effnet, we find some practical ways to train our own models. After reading Keetar's fantastic writeup of his GLD retrieval, we trained our Effnet B6 and B7 first with 384 sized images. Then we use the increasing 512 sized images to further tuned our B6 and B7. The training environment is Colab Pro. Then we simply put the two model ensembling predictions to the global feature extraction.</p> <p>For more details and adjustments, please refer to the kernel above. </p> <p>Feel free to ask if you have any questions</p>
Cornell Birdcall Identification
9th place solution
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Cornell Birdcall Identification <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>I would like to thank the hosts for this unique challenge. Congratulations to my teammate <a href="https://www.kaggle.com/canalici" target="_blank">@canalici</a> and to all competitors. It was indeed a very educative competition in the audio domain. Many thanks to <a href="https://www.kaggle.com/hidehisaarai1213" target="_blank">@hidehisaarai1213</a> guidance through competition, and <a href="https://www.kaggle.com/doanquanvietnamca" target="_blank">@doanquanvietnamca</a> for GRU-SED and Dmytro Karabash for ideas.</p> <h2>Data Augmentation</h2> <p>Models have trained in both original and extended datasets. Augmentations applied in both waveform and mel-spectrogram level.</p> <ul> <li>Gaussian Noise</li> <li>SpecAug</li> </ul> <h2>Modeling</h2> <p>I have modified the SED model (PANN’s) and replace its inefficient backbone with a noisy-Efficientnet and further experimented with GRU’s, LSTM’s, and with Transformers for temporal modeling. We had a CNN backbone -&gt; a GRU layer -&gt; and attention layer in the final model. </p> <ul> <li>EfficientNet-B4 (Noisy Student) </li> <li>EfficientNet-B7 (Noisy Student)</li> <li>EfficientNet-B7 (Noisy Student)</li> </ul> <p>To ensemble different solutions, I have removed the attention layer for each model, kept pre-trained weights of the extracted part, and re-trained an attention layer from features extracted from 3 different models listed above.<br> <img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4470174%2F00b6195649463cefa402d7d0097e17d1%2FUntitled-3.png?generation=1600242638521318&amp;alt=media" alt=""></p> <h2>Training</h2> <ul> <li>Batch size of 32 for B4, and 8 for B7 models (single GPU)</li> <li>No mixup :( </li> <li>BCELoss </li> <li>AdamW with Cosine Anneal</li> <li>5 seconds of audio clips (501, 64) (scaling mel_bins into 224, 300 would really have helped, but very expensive)</li> <li>Pre-training on primary labels, fine tuning with secondary labels</li> </ul> <p>For validation, we have hand-labeled no-calls into gt_birdclef2020_validation_data and excluded irrelevant species, which provided a chance to test the algorithm in the wild. </p> <h3>Possible further work</h3> <p>Pre-trained models proven self to be leverage in many knowledge transfer tasks. It is tough not to over-fit our classifier, especially in this competition, where we had a few audio clips with very noisy labels. Hidehisa Arai pointed out PANN’s(one of the largest pre-trained models in the audio domain) for this issue, their CNN backbone was less potent than lighter alternatives. We have used a firm CNN backbone to overcome this issue, pre-trained on a large corpus of images (Noisy Student, Efficientnet). However, it is possible to extract mel-spectrogram encoder/decoder parts from very famous text-to-speech, speech conversation (Tacotron, Glow TTS…) algorithms that trained on a relatively larger corpus. It could be beneficial to adapt successfully pre-trained models from the Audio domain, fine-tuning it with all the bird data we have, then applying a noisy-student training scheme. </p>
Google Landmark Recognition 2020
[21st place] - My solution to 2 silver medals in GL 2020
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Google Landmark Recognition 2020 <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>First of all, congratulations to everyone for having interesting journeys across such a challenging competition, especially to the top teams and all who gained a lot from the competition. Also, thanks to google for organizing the 3rd Landmark competitions.</p> <p>For me, throughout two competitions of Google Landmark 2020, I really learnt such an amount of knowledge, and also came up with many ideas to compete in those harsh competitions. Here are things I have done.</p> <h1><strong>Retrieval competition</strong></h1> <p>Actually, I didn’t think this competition was for me at first, because I’m kind of a newbie in tensorflow :)). However, after a bad performance in Global Wheat Detection challenge, I decided to join seriously in the competition within 13 days left.</p> <h2>Architecture</h2> <p>First, I tried to train delf model from <a href="https://github.com/tensorflow/models/tree/master/research/delf" target="_blank">tf delf</a>, the result is no where near the host baseline kernel (only 0.12-0.13 compared to 0.271 of host baseline) so I quickly quitted this way.</p> <p>Luckily, <a href="https://www.kaggle.com/chandanverma/convert-pytorch-model-to-tf-2-2-submission-format" target="_blank">onnx</a> kernel was published and it was a big chance for a pytorch user like me that I could develop my own model. From top-down view, my final model is ensemble of 4 models, which can be represented as followed:</p> <pre><code>net_1 -&gt; feature_1 | ... |--[concat]--&gt; [fc 4096]--&gt; final_feature net_4 -&gt; feature_4 | </code></pre> <p>With net_i:</p> <pre><code>CNN backbone --&gt; GeM pooling --&gt; fc --&gt; batchnorm --&gt; arcface/cosface </code></pre> <p>More detailed:</p> <pre><code>net_1: efficientnet-b2, fc 1024 net_2: efficientnet-b3, fc 512 net_3: efficientnet-b3, fc 1024 net_4: efficientnet-b4, fc 512 </code></pre> <p>From my results, training one more fc layer on top of ensemble net gave a 0.02 boost on final score compared to simple concatenating.<br> I used input images of size 256x256, which might really affect my score (compared to top solutions that use images of large size), and training only with GLDv2 clean. Also while I always use RAdam optimizer, I realize that almost all top teams use SGD, maybe I should switch to SGD in the future?</p> <h2>Result</h2> <pre><code>Best single-model score: 0.270 - 0.233 (efficientnet-b3, fc 512) Best ensemble-model score: 0.293 - 0.260 </code></pre> <p>I had learnt a lot from public solution of top teams after the end of the competition, and figured out somethings I could improve in the retrieval task:</p> <ul> <li>larger image size</li> <li>dealing with imbalanced dataset using class weights</li> <li>training on extended dataset: GLDv1, GLDv2 full.</li> </ul> <p>Although I struggled with tf model submission type at first, it was at last very lucky for me because I didn't have to care about the post-processing phase such as local features, rescoring and reranking, ransac, etc. </p> <h1><strong>Recognition competition</strong></h1> <p>Maybe I was lucky in the retrieval competition, finally I had to deal with everything when coming to the recognition challenge :).</p> <h2>Global feature extraction</h2> <p>I used entirely different set of backbones in comparison with those in retrieval task:</p> <pre><code>net_1: resnest200, fc 512 net_2: resnest200, fc 1024 net_3: resnest269, fc 512 net_4: resnest269, fc 1024 net_5: resnet152, fc 512 </code></pre> <p>From my results, resnest and resnet152 gave much better performances than efficientnet (even b7). I trained with 224x224 images of GLDv1 + GLDv2 clean and fine-tuned with 448x448 of GLDv2 clean, using arcface.</p> <h2>Local feature extraction</h2> <p>I trained delg, delf with <a href="https://github.com/tensorflow/models/tree/master/research/delf" target="_blank">tf delf</a> again, and further trained a PCA to diminish dimension of descriptors from 1024 -&gt; 128. However, I couldn’t beat the delg model in the host baseline kernel. My best self-trained delg is worse 0.01 than baseline delg.<br> So for my final score, I chose the delg baseline model to extract local features.</p> <h2>Rescoring and reranking</h2> <p>I defined score of reranking process as followed:</p> <pre><code>score = global_score + local_score + recognition_score </code></pre> <p>Definition of my own recognition score:</p> <pre><code>recognition_score = max_value * (1-k/topk) ** alpha - recognition score is based on the arcface head of my model - max_value: max value of recognition score - k (&lt; topk): rank of predicted label in sorted arcface head - topk: topk prediction of arcface, recognition_score &gt; 0 if predicted label is in topk else 0 - alpha &lt; 1: giving a boost to small k (top1, top2 &gt;&gt; top 99, top 100) - My final submission: (max_value, topk, alpha) = (2, 200, 0.35) </code></pre> <p>I didn’t try many values of hyperparameters of my recognition_score, but it gave a 0.006 boost compared to the scoring scheme from the baseline kernel.</p> <h2>Result</h2> <pre><code>Best single-model score: 0.5424 - 0.5233 (resnest200, fc 512) Best ensemble-model score: 0.5640 - 0.5354 </code></pre> <h2>Not worked things</h2> <p>Here are some ideas which did not work well:</p> <ul> <li>Filter distractors by arcface head (if label not in top 200 -&gt; non-landmark) it downgraded my score around 0.01</li> <li>Online fine-tuning with private training set, downgraded my score around 0.02</li> </ul> <p>That might be a little long for now :)). I will update this post if I remember something interesting. Thank you for reading my sharing!</p>
Google Landmark Recognition 2020
2nd place solution
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Google Landmark Recognition 2020 <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Congratulations to all the winners, thanks to kaggle and Google for hosting Landmark Retrieval/Recognition competition. </p> <p>Here is my brief solution to this competition.</p> <p><strong>Definition</strong><br> <strong>GLD_v2c</strong>(cleaned GLDv2), there are 1.6 million training images and 81k classes. All landmark test images belong to these classes.<br> <strong>GLD_v2x</strong>, in GLDv2, there are 3.2 million images belong to the 81k classes in GLD_v2c. I define these 3.2m images as GLD_v2x.<br> <strong>query image</strong>, the test image when submitting to kaggle or the image in validation set when validate locally.<br> <strong>Index image set</strong>, the images from train set, as described in Data page of this competition, “subset contains all of the training set images associated with the landmarks in the private test set”<br> <strong>non-landmark image set</strong>, sub set of 5000 non-landmark images form test set of GLDv2.</p> <p><strong>Models to retrieve images</strong></p> <p>It’s very important to search related images from index image set accurately. I trained the efficientnet B5, B6, B7 and Resnet152 models according to the first place solution of Landmark Retrieval 2020 competition from <a href="https://www.kaggle.com/keetar" target="_blank">@keetar</a>, <a href="https://www.kaggle.com/c/landmark-retrieval-2020/discussion/176037" target="_blank">https://www.kaggle.com/c/landmark-retrieval-2020/discussion/176037</a>. I will only describe the differences of my training strategy, please refer to his great solution for details.<br> 1.Train 448x448 images from GLD_v2c for 5-6 epochs.<br> 2.Finetune the model of step1 on 448x448 images from GLD_v2x<br> 3.Finetune the model of step2 on 512x512 images from GLD_v2x for 5-6 epoch. I used GLD_v2x instead of GLD_v2 all.<br> 4.640x640 for 3-5 epochs<br> 5.736x736 for 2-3 epochs</p> <p><strong>Loss function</strong>: arcface instead of adacos loss.<br> <strong>Optimizer</strong>: SGD(0.01, momentum=0.9, decay=1e-5) <br> <strong>Inference</strong>: extract embeddings by feeding 800x800 images.<br> <strong>Validate set</strong>: sample 200 images from GLDv2 test set as val set and all the ground truth images of Google Landmark Retrieval Competition 2019 as index dataset</p> <p>After replacing the model in baseline kernel <a href="https://www.kaggle.com/camaskew/host-baseline-example" target="_blank">https://www.kaggle.com/camaskew/host-baseline-example</a> from the host with trained efficientnet B7 model, <br> the public and private score of B7 model are 0.5927/0.5582.</p> <p><strong>Validation strategy for Landmark Recognition Task</strong><br> The val set part 1: the 1.3k landmark images from GLDv2 test set( exclude those not in 81k classes) . <br> The val set part 2: sample 2.7k images from GLD_v2x-GLD_v2c.</p> <p>The index image set for val set: all the images of related landmarks from GLD_v2c train set and sample some other images to get 200k images.</p> <p>This strategy is quite stable during the whole competition, but unfortunately, the private test set distribution is a little different from my local CV and public test set. I should have used all the GLD-v2x images to generate index image set as many landmark images are not included in GLD-v2c. </p> <p><strong>SuperPoint+SuperGlue+pydegensac</strong><br> This combination is better than delf+kdtree+pydegensac.<br> The scored improved from 0.5927/0.5582 to 0.6146/0.5756, which can be top 10 on leaderboard.</p> <p><strong>Post-Processing</strong></p> <p>Although I force myself not pay to much efforts on post-processing, finding magic or reverse engineering, post-processing is so important in this competition that I had to spend a lot of time to analyse the model results and design rules on the validation set, I tried rules from winner solutions of last year, the following are the effective rules:<br> 1.Search top 3 non-landmark images from no-landmark image set for query a image, if the similarity of top3 &gt;0.3, then decrease the score of the query image.<br> 2.If a landmark is predicted &gt;20 times in the test set, then treat all the images of that landmark as non-landmarks.</p> <p>As many features(ransac inliers, similarity to index images, similarity to non-landmark images…) can be used for determining whether an image is non-landmark or not, I developed a model which can be called re-rank model. As to re-rank, we can refer to this post:<br> <a href="https://www.kaggle.com/c/tweet-sentiment-extraction/discussion/159315" target="_blank">https://www.kaggle.com/c/tweet-sentiment-extraction/discussion/159315</a></p> <p>After post-processing, the score of efficientnet B7 model improved from 0.6146/0.5756 to 0.6797/0.6301 which can be top-3 on leaderboard.<br> <strong>Ensemble</strong><br> My final scored was achieve by ensemble efficientnet B7, B6, B5, Resnet152 models, which is not a big improvement considering the complexity and computation resources.</p> <p>repo:<a href="https://github.com/bestfitting/instance_level_recognition" target="_blank">https://github.com/bestfitting/instance_level_recognition</a><br> [Update] with paper attached</p>
Google Landmark Recognition 2020
[22nd Place + Code] Margin Scheduling – First time on Kaggle :D
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Google Landmark Recognition 2020 <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>First, <strong>congratulations to the top teams!!!</strong> 🎉🎉🎉🎉🎉🎉🎉 What they achieved is incredible! </p> <p>This year's <a href="https://www.kaggle.com/c/landmark-retrieval-2020/" target="_blank">Landmark Retrieval</a> and <a href="https://www.kaggle.com/c/landmark-recognition-2020/" target="_blank">Recognition</a> challenges are the first ML competitions that I've ever participated in. Haven't touched anything ML-related for a year, so this was refreshing.</p> <p>Unfortunately, I joined the Retrieval competition late (8 days before the end) and got only around 2 weeks to participate in this one part-time. I've learned a lot during this competition. If there will be a landmark challenge next year, I'll give it a better fight!</p> <p>Also, I would like to thank <a href="https://www.kaggle.com/keetar" target="_blank">@keetar</a> for being an inspiration – what he achieved with just Colab Pro showed me that you don't need fancy hardware to compete, even in such a hard competition with a ton of data. His <a href="https://www.kaggle.com/c/landmark-retrieval-2020/discussion/176037" target="_blank">excellent writeup</a> was the sole reason why I decided to participate in the Recognition track.</p> <h2>Retrieval Track (39th, Silver medal)</h2> <ul> <li>Nothing special, just a weighted ensemble of <code>0.271</code> and <code>0.277</code> models and got silver medal lol lol lol 😆😆😆 I also tried some filtering using Places365 VGG model, but it doesn't work out.</li> </ul> <hr> <h2>Recognition Track (22nd, Silver medal) – margin scheduling</h2> <p>I realized that I've been spamming the Discussion section a lot, so I'll keep this short:</p> <ul> <li><p>I trained a <a href="https://www.tensorflow.org/api_docs/python/tf/keras/applications/ResNet152V2" target="_blank">ResNet152V2</a> with <a href="https://arxiv.org/abs/1711.02512" target="_blank">GeM</a> (p=3) + <a href="https://arxiv.org/abs/1801.07698" target="_blank">ArcFace</a> and a <a href="https://github.com/qubvel/efficientnet" target="_blank">EffNetB6</a> with GAP + <a href="https://arxiv.org/abs/1801.07698" target="_blank">ArcFace</a> global descriptors on Cleaned GLDv2. Didn't have time to train to full convergence ☹️☹️☹️ </p></li> <li><p>For <a href="https://arxiv.org/abs/1801.07698" target="_blank">ArcFace</a>, I started with a small margin (i.e. <code>1e-3</code>), and gradually increased it at the end of every period of Cosine LR, up to <code>0.31</code>. It was harder for me to train with a fixed margin.</p></li> <li><p>Training hardware: Colab Pro only!</p></li> <li><p>I simply used a publicly available object detector <a href="https://tfhub.dev/google/faster_rcnn/openimages_v4/inception_resnet_v2/1" target="_blank">FastRCNN+InceptionResNetV2</a> trained on <a href="https://ai.googleblog.com/2020/02/open-images-v6-now-featuring-localized.html" target="_blank">Open Images V4</a> for non-landmark removal. This gave a boost of around <strong>+0.005</strong> on pub. LB.</p></li> <li><p>Because I started late (~2 weeks before the end) and didn't had enough time to experiment around, I used <a href="https://arxiv.org/abs/1907.05550" target="_blank">Data Echoing</a> technique to speed up training <strong>by ~20%</strong>.</p></li> <li><p>Standard re-ranking: Retrieval step (using KNN) + Non-Landmark Removal (as described above) + Local Descriptors extraction (using baseline DELG model) + RANSAC.</p></li> <li><p>During inference, I used index embeddings only! I did not have time to generate embeddings for training samples.</p></li> </ul> <p>What I didn't have time to finish:</p> <ul> <li>Local descriptors. I only implemented the local descriptors <a href="https://www.kaggle.com/c/landmark-recognition-2020/discussion/187344" target="_blank">36 hours before the end</a>.</li> <li>Multi-Gradient Descent (<a href="https://papers.nips.cc/paper/7334-multi-task-learning-as-multi-objective-optimization.pdf" target="_blank">MGDA-UB</a>). I figured this could allow the local descriptor to train alongside with the global ones without <code>stop_gradient</code>.</li> <li>Pre-computed embeddings. Ironically, <a href="https://www.kaggle.com/c/landmark-recognition-2020/discussion/176697" target="_blank">I was the first who have asked if this is legal</a>.</li> </ul> <p>My training code is <a href="https://github.com/hav4ik/google-landmarks-2020" target="_blank">available on Github</a>. I've also published my <a href="https://www.kaggle.com/chankhavu/glob-effb6-e48-rn152-e40-det-frcnn-ss-orig" target="_blank">final submission</a>.</p> <hr> <h2>Fun fact: you could've gotten a Silver medal using just baselines!</h2> <ul> <li><p>Replacing the global descriptor from the <a href="https://www.kaggle.com/paulorzp/baseline-landmark-recognition-lb-0-48" target="_blank">Public Recognition Baseline Example</a> with the model from <a href="https://www.kaggle.com/nvnnghia/main-0806" target="_blank">Public Retrieval Baseline</a> will get you <code>0.4872/0.5081</code>, or a <strong>Bronze</strong> medal.</p></li> <li><p>Adding a simple non-landmark removal with object detectors will boost the above described baseline-based solution to a <strong>Silver</strong> medal.</p></li> </ul> <p>[spoint]: <a href="https://arxiv.org/abs/1712.07629" target="_blank">https://arxiv.org/abs/1712.07629</a><br> [sglue]: <a href="https://arxiv.org/abs/1911.11763" target="_blank">https://arxiv.org/abs/1911.11763</a><br> [fmatches]: <a href="https://local-features-tutorial.github.io/pdfs/Local_features_from_paper_to_practice.pdf" target="_blank">https://local-features-tutorial.github.io/pdfs/Local_features_from_paper_to_practice.pdf</a></p>
SIIM-ISIC Melanoma Classification
157th place solution
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: SIIM-ISIC Melanoma Classification <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Congratulations to all the winners and to everyone who took part in this. It was a great learning experience for me and I'll share what finally worked for me. There is still so much to learn by going through the solution overviews and more discussions/kernels. The best performance I was able to get was public LB: 0.9570, private LB: 0.9403.</p> <h2>Data</h2> <p>My best model is an ensemble (just the mean of the predictions) of 4 models. I am using <a href="https://www.kaggle.com/cdeotte" target="_blank">@cdeotte</a>'s Triple Stratified Split. 3 models were trained on data from 2017 + 2018 + 2020. One of the models was trained on 2017 + 2018 + 2019 + archives + 2020.</p> <h2>Image sizes</h2> <p>3 models were trained on 512x512 images and 1 model on 384x384.</p> <h2>Augmentations</h2> <p>2 models use the following augmentations (using <code>kornia</code>):</p> <pre><code>- name: Rescale params: value: 255. - name: RandomAffine params: degrees: 180 translate: - 0.02 - 0.02 - name: RandomHorizontalFlip params: p: 0.5 - name: ColorJitter params: saturation: - 0.7 - 1.3 contrast: - 0.8 - 1.2 brightness: 0.1 - name: Normalize params: mean: imagenet std: imagenet </code></pre> <p>The meaning of different params can be found from <code>kornia</code>'s <a href="https://github.com/kornia/kornia/blob/master/kornia/augmentation/augmentation.py" target="_blank">documentation</a>.</p> <p>The other 2 models additionally use <code>Cutout</code>:</p> <pre><code>- name: RandomErasing params: p: 0.5 ratio: - 0.3 - 3.3 scale: - 0.02 - 0.1 </code></pre> <h2>Sampling</h2> <p>To iterate faster, instead of upsampling the minority class, I downsample the majority class per epoch. However, to avoid wasting data, I sample different instances from the majority class per epoch.</p> <h2>Network</h2> <p>The same network architecture is used for all the 4 models - EfficientNet-B5 features followed by a Linear layer.</p> <h2>Optimization</h2> <pre><code>Optimizer: AdamW weight decay: 0.1 epochs: 20 LR scheduler: 1cycle with initial LR = 5e-6, max LR = 2e-4 (LR range test) </code></pre> <h2>Things I wanted to try but couldn't</h2> <ul> <li>Train on images of different sizes for the 3 best configs on 512x512 and ensemble</li> <li>Incorporate meta-data by stacking it with the features from the deep model</li> <li>Spend time improving my ensembles</li> <li>More augmentations</li> <li>Custom head</li> </ul>
SIIM-ISIC Melanoma Classification
254th Place Solution
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: SIIM-ISIC Melanoma Classification <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Thanks to the kaggle and the organizers for hosting such an interesting competition. And I like to thank my teammates, brother <a href="https://www.kaggle.com/udaykamal" target="_blank">@udaykamal</a>, and <a href="https://www.kaggle.com/tahsin" target="_blank">@tahsin</a> for the insightful discussion that we've made along with this journey. And last but not least, We're greatly thankful to the <strong>MVP</strong> of this competition, <a href="https://www.kaggle.com/cdeotte" target="_blank">@cdeotte</a> for all the contribution that he's shared from the very beginning of this competition. </p> <p>Our experiment is based on <a href="https://www.kaggle.com/cdeotte" target="_blank">@cdeotte</a> 's strong <a href="https://www.kaggle.com/cdeotte/triple-stratified-kfold-with-tfrecords" target="_blank">baseline starter</a> and we extended it by integrating various types of the modeling approach.</p> <h1>Brief Summary</h1> <ul> <li>All the Base-Models are <code>EfficientNets</code>, and here <strong>E-Net</strong> for short. Total of 20 models only.</li> </ul> <pre><code>- `E-Net B2` (2x) - `E-Net B3` (2x) - `E-Net B4` (3x) - `E-Net B5` (2x) - `E-Net B6` (5x) - `E-Net B7` (6x) </code></pre> <ul> <li>We have used various types of the top model including </li> </ul> <pre><code>- Global Average Pooling (GAP) - Global Max Pooling (GMP) - Attention Weighted Net (AWN) - Generalized Mean Pooling (GeM) - Global Average Attention Mechanism (GAAM, [ours]) </code></pre> <p>Ok, here below are the full details. (<strong>TL,DR</strong>)</p> <hr> <h1>E-Net 2</h1> <table> <thead> <tr> <th>Model</th> <th>Top</th> <th>Seed</th> <th>Data</th> <th>Img</th> <th>Folds</th> <th>CV</th> <th>LB</th> </tr> </thead> <tbody> <tr> <td>a-ENet 2</td> <td>GAP</td> <td>202</td> <td>'20+'18</td> <td>512</td> <td>5</td> <td>0.904</td> <td>0.9345</td> </tr> <tr> <td>b-ENet 2</td> <td>GAP</td> <td>1234</td> <td>'20+'18</td> <td>512</td> <td>5</td> <td>0.907</td> <td>0.9346</td> </tr> </tbody> </table> <p>Next, based on the <strong>CV</strong> score, we took a simple average of them. </p> <pre><code>ENet 2 = (a-ENet 2 + b-ENet 2)/2 </code></pre> <p>The resultant prediction graph as follows: <br> <img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1984321%2Ff107b28e41ce558fa67b26e0abe56730%2F2.png?generation=1597815112995545&amp;alt=media" alt=""></p> <h1>E-Net 3</h1> <table> <thead> <tr> <th>Model</th> <th>Top</th> <th>Seed</th> <th>Data</th> <th>Img</th> <th>Folds</th> <th>CV</th> <th>LB</th> </tr> </thead> <tbody> <tr> <td>a-ENet 3</td> <td>GAAM</td> <td>101</td> <td>'20+'18</td> <td>512</td> <td>5</td> <td>0.890</td> <td>0.9462</td> </tr> <tr> <td>b-ENet 3</td> <td>GAP</td> <td>2020</td> <td>'20+'18</td> <td>512</td> <td>5</td> <td>0.912</td> <td>0.9435</td> </tr> </tbody> </table> <p>Next, based on the <strong>CV</strong> score, we took a simple weighted average of them. </p> <pre><code>ENet 3 = (a-ENet 3*1 + b-ENet 3*2)/3 </code></pre> <p>The resultant prediction graph as follows:<br> <img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1984321%2F4e767d1caa113e72e38aafcce541f403%2F3.png?generation=1597815707202196&amp;alt=media" alt=""></p> <h1>E-Net 4</h1> <table> <thead> <tr> <th>Model</th> <th>Top</th> <th>Seed</th> <th>Data</th> <th>Img</th> <th>Folds</th> <th>CV</th> <th>LB</th> </tr> </thead> <tbody> <tr> <td>a-ENet 4</td> <td>GAP + AWN</td> <td>786</td> <td>'20+'18</td> <td>512</td> <td>5</td> <td>0.9120</td> <td>0.9334</td> </tr> <tr> <td>b-ENet 4</td> <td>GAP</td> <td>786</td> <td>'20+'18</td> <td>512</td> <td>5</td> <td>0.9250</td> <td>0.9454</td> </tr> <tr> <td>c-ENet 4</td> <td>M</td> <td>999</td> <td>'20+'18+'19+Upsampled</td> <td>768</td> <td>1</td> <td>0.9320</td> <td>0.9326</td> </tr> </tbody> </table> <p>Here, M = <strong>[GAP + GeM+AWN + GMP]</strong></p> <p>Next, based on the <strong>CV</strong> score, we took a simple weighted average of them. </p> <pre><code>ENet 4 = (a-ENet 4*1 + b-ENet 4*2 + c-ENet 4*2)/5 </code></pre> <p>The resultant prediction graph as follows:<br> <img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1984321%2Fb70062f56a279740e23d527f38f31831%2F4.png?generation=1597816112525326&amp;alt=media" alt=""></p> <h1>E-Net 5</h1> <table> <thead> <tr> <th>Model</th> <th>Top</th> <th>Seed</th> <th>Dat</th> <th>Img</th> <th>Fold</th> <th>CV</th> <th>LB</th> </tr> </thead> <tbody> <tr> <td>a-ENet 5</td> <td>GAP + AWN</td> <td>101</td> <td>'20+'18</td> <td>384</td> <td>5</td> <td>0.908</td> <td>0.9442</td> </tr> <tr> <td>b-ENet 5</td> <td>M</td> <td>786</td> <td>'20+'18</td> <td>512</td> <td>3</td> <td>0.884</td> <td>0.9491</td> </tr> </tbody> </table> <p>Here, M = <strong>[GAP + GMP + AWN]</strong></p> <p>Next, based on the <strong>CV</strong> score, we took a simple weighted average of them. </p> <pre><code>ENet 5 = (a-ENet 5*2 + b-ENet 5*1)/3 </code></pre> <p>The resultant prediction graph as follows:<br> <img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1984321%2F5a468bba3f008360fa58b416f70019e3%2F5.png?generation=1597816460348906&amp;alt=media" alt=""></p> <h1>E-Net 6</h1> <p>Basically <code>E-Net 6</code> was our first modeling approach. So, initially, we kept the validation set the same (seed <code>42</code>) and experimented in the following way.</p> <table> <thead> <tr> <th>Model</th> <th>Top</th> <th>Seed</th> <th>Data</th> <th>Img</th> <th>Fold</th> <th>CV</th> <th>LB</th> </tr> </thead> <tbody> <tr> <td>a-ENet 6</td> <td>GAP</td> <td>42</td> <td>'20 + '18</td> <td>384</td> <td>5</td> <td>0.904</td> <td>0.9454</td> </tr> <tr> <td>b-ENet 6</td> <td>GAP + AWN</td> <td>42</td> <td>'20+'18</td> <td>512</td> <td>5</td> <td>0.912</td> <td>0.9422</td> </tr> <tr> <td>c-ENet 6</td> <td>AWN</td> <td>42</td> <td>'20+'18-</td> <td>512</td> <td>5</td> <td>0.918</td> <td>0.9431</td> </tr> <tr> <td>d-ENet 6</td> <td>GeM</td> <td>42</td> <td>'20+'18</td> <td>512</td> <td>5</td> <td>0.905</td> <td>0.9405</td> </tr> <tr> <td>e-ENet 6</td> <td>GAAM</td> <td>42</td> <td>'20+'18</td> <td>512</td> <td>5</td> <td>0.925</td> <td>0.9458</td> </tr> </tbody> </table> <p>Next, as the above 6 submissions came from the same validation split, we further tried to find the best weights that will maximize the <strong>OOF</strong> validation score max. </p> <table> <thead> <tr> <th>-</th> <th>SimpleAvg</th> <th>PowerAvg</th> <th>RankAvg</th> <th>BaysianOpt</th> <th>L-BFGS-B</th> </tr> </thead> <tbody> <tr> <td>CV</td> <td>0.9319</td> <td>0.9312</td> <td>0.9321</td> <td>0.9322</td> <td>0.9320</td> </tr> <tr> <td>LB</td> <td>0.9487</td> <td>0.9488</td> <td>0.9483</td> <td>0.9490</td> <td>0.9491</td> </tr> </tbody> </table> <p>As we found <code>BaysianOpt</code> gave the maximum CV, so later we chose it for the final blending. I've published a notebook regarding this, showed a comparison between <strong>Bayesian Optimization</strong> and <strong>L-BFGS-B</strong> methods, <a href="https://www.kaggle.com/ipythonx/optimizing-metrics-out-of-fold-weights-ensemble" target="_blank">Optimizing Metrics: Out-of-Fold Weights Ensemble</a></p> <p>The resultant prediction graph as follows:<br> <img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1984321%2Faf77c044bad954675dae053b8419ec80%2F6.png?generation=1597821688482478&amp;alt=media" alt=""></p> <h1>E-Net 7</h1> <table> <thead> <tr> <th>Model</th> <th>Top</th> <th>Seed</th> <th>Data</th> <th>Img</th> <th>Fold</th> <th>CV</th> <th>LB</th> </tr> </thead> <tbody> <tr> <td>a-ENet 7</td> <td>GAP</td> <td>101</td> <td>'20+'18</td> <td>256</td> <td>5</td> <td>0.910</td> <td>0.9307</td> </tr> <tr> <td>b-ENet 7</td> <td>GAP</td> <td>42</td> <td>'20+'18</td> <td>256</td> <td>5</td> <td>0.910</td> <td>0.9312</td> </tr> <tr> <td>c-ENet 7</td> <td>GAP</td> <td>42</td> <td>'20+'18</td> <td>384</td> <td>4</td> <td>0.923</td> <td>0.9389</td> </tr> <tr> <td>d-ENet 7</td> <td>M</td> <td>2020</td> <td>'20 + '18 + '19 + Upsampled</td> <td>768</td> <td>1</td> <td>0.928</td> <td>0.9479</td> </tr> <tr> <td>e-ENet 7</td> <td>M</td> <td>1221</td> <td>'20 + '18 + '19 + Upsampled</td> <td>512</td> <td>5</td> <td>0.922</td> <td>0.9442</td> </tr> </tbody> </table> <p>Here, M = <strong>[GAP+GeM+GMP+AWN]</strong></p> <p>Next, based on the <strong>CV</strong> score, we took a simple weighted average of them. </p> <pre><code>ENet 7 = (a-ENet 7*1 + b-ENet 7*1 + c-ENet 7*2 + d-ENet 7*2 + e-ENet 7*2)/8 </code></pre> <p>The resultant prediction graph as follows:<br> <img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1984321%2Fb428333f2381ff3dba527e031e401985%2F7.png?generation=1597817972968820&amp;alt=media" alt=""></p> <h1>Whole Data Training, 2020 SIIM Comp.</h1> <p>Maybe it's not full ideal but we did four experiments, inspired by <a href="https://www.kaggle.com/agentauers" target="_blank">@agentauers</a> 's awesome <a href="https://www.kaggle.com/agentauers/incredible-tpus-finetune-effnetb0-b6-at-once" target="_blank">kernel</a>. We didn't take any validation set, this was done before 2/3 weeks of the competition end. </p> <table> <thead> <tr> <th>Model</th> <th>Top</th> <th>Seed</th> <th>Data</th> <th>Img</th> <th>LB</th> </tr> </thead> <tbody> <tr> <td>ENet 3+4+5</td> <td>GAP</td> <td>101</td> <td>'20</td> <td>256</td> <td>0.9384</td> </tr> <tr> <td>ENet 3+4+5</td> <td>GAP</td> <td>42</td> <td>'20</td> <td>384</td> <td>0.9470</td> </tr> <tr> <td>ENet 3+4+5</td> <td>GAP</td> <td>786</td> <td>'20</td> <td>512</td> <td>0.9438</td> </tr> <tr> <td>ENet 3+4+5</td> <td>GAP</td> <td>202</td> <td>'20</td> <td>768</td> <td>0.9385</td> </tr> </tbody> </table> <p>Next, we took a simple average of these four, which leads <code>LB</code>: <strong>94.8</strong>.</p> <h1>Final Blends</h1> <p>We couldn't give enough time for metal features. So, we've used a public meta submission form <a href="https://www.kaggle.com/datafan07/eda-modelling-of-the-external-data-inc-ensemble" target="_blank">here</a>. And gave <code>0.1</code> to the meta-features in the final blending.</p> <p>The final blending took all the submission of <code>EfficientNets B2 to 7</code> and Meta features and combined training on the whole data set of 2020. After the generate single submission from <code>E-Net B2 to 7</code> and metal features (<code>0.1</code>), further, we did rank ensemble with combined submission. It leads the Public LB: <strong>0.9554</strong>, and Private <strong>0.9383</strong>.</p> <hr> <h2>Generalized Mean Pooling (GeM)</h2> <pre><code>class GeneralizedMeanPooling2D(tf.keras.layers.Layer): def __init__(self, p=3, epsilon=1e-6, name='', **kwargs): super(GeneralizedMeanPooling2D, self).__init__(name, **kwargs) self.init_p = p self.epsilon = epsilon def build(self, input_shape): if isinstance(input_shape, list) or len(input_shape) != 4: raise ValueError('`GeM` pooling layer only allow 1 input with 4 dimensions(b, h, w, c)') self.build_shape = input_shape self.p = self.add_weight( name='p', shape=[1,], initializer=tf.keras.initializers.Constant(value=self.init_p), regularizer=None, trainable=True, dtype=tf.float32 ) self.built=True def call(self, inputs): input_shape = inputs.get_shape() if isinstance(inputs, list) or len(input_shape) != 4: raise ValueError('`GeM` pooling layer only allow 1 input with 4 dimensions(b, h, w, c)') return (tf.reduce_mean(tf.abs(inputs**self.p), axis=[1,2], keepdims=False) + self.epsilon)**(1.0/self.p) </code></pre> <h3>Attention Weighted Network (AWN)</h3> <p>From <a href="https://www.kaggle.com/c/human-protein-atlas-image-classification/discussion/77269#454482" target="_blank">here</a>. Thanks to <a href="https://www.kaggle.com/wowfattie" target="_blank">@wowfattie</a> </p> <pre><code>class AttentionWeightedAverage2D(Layer): def __init__(self, **kwargs): self.init = initializers.get('uniform') super(AttentionWeightedAverage2D, self).__init__(** kwargs) def build(self, input_shape): self.input_spec = [InputSpec(ndim=4)] assert len(input_shape) == 4 self.W = self.add_weight(shape=(input_shape[3], 1), name='{}_W'.format(self.name), initializer=self.init) self._trainable_weights = [self.W] super(AttentionWeightedAverage2D, self).build(input_shape) def call(self, x): logits = K.dot(x, self.W) x_shape = K.shape(x) logits = K.reshape(logits, (x_shape[0], x_shape[1], x_shape[2])) ai = K.exp(logits - K.max(logits, axis=[1,2], keepdims=True)) att_weights = ai / (K.sum(ai, axis=[1,2], keepdims=True) + K.epsilon()) weighted_input = x * K.expand_dims(att_weights) result = K.sum(weighted_input, axis=[1,2]) return result def get_output_shape_for(self, input_shape): return self.compute_output_shape(input_shape) def compute_output_shape(self, input_shape): output_len = input_shape[3] return (input_shape[0], output_len) </code></pre> <h3>Global Average Attention Mechanism</h3> <p>The main idea of this mechanism is from <a href="https://www.kaggle.com/kmader" target="_blank">K Scott Mader</a>, currently working in Apple as ML Eng. However, you can find the vanilla implementation of the mechanism from his work (kernel). Here is one <a href="https://www.kaggle.com/hiramcho/melanoma-efficientnetb6-with-attention-mechanism" target="_blank">public kernel</a> of it. And <a href="https://www.kaggle.com/datafan07" target="_blank">@datafan07</a> also used it to his pipeline, great.</p> <hr> <p>Lastly, we like to mention some work that we've published for this competition, hope it may come helpful for future readers.</p> <ul> <li><a href="https://www.kaggle.com/ipythonx/tf-keras-melanoma-classification-starter-tabnet" target="_blank">TF.Keras: Melanoma Classification Starter, TabNet</a><ul> <li><a href="https://www.kaggle.com/ipythonx/optimizing-metrics-out-of-fold-weights-ensemble" target="_blank">Optimizing Metrics: Out-of-Fold Weights Ensemble</a></li> <li><a href="https://www.kaggle.com/ipythonx/training-cv-melanoma-starter-ghostnet-tta" target="_blank">PyTorch: [Training CV] Melanoma Starter. GhostNet + TTA</a></li> <li><a href="https://www.kaggle.com/ipythonx/tresnet-hp-gpu-dedicated-net-grad-accumulation-tta" target="_blank">PyTorch: TResNet:HP-GPU Dedicated Net+Grad-Accumulation+TTA</a></li></ul></li> </ul>
Cornell Birdcall Identification
39th place solution [top1 at public]
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Cornell Birdcall Identification <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><h2>Summary</h2> <ol> <li>Noise is the key</li> <li>Test might be recorded with 16 kHz sampling rate</li> <li>Sequence-wise predictions transformed into global and 5s chunk predictions with logsumexp pooling (training on 20-40s segments, inference on full files)</li> <li>Multi-head self-attention applied to entire sequences</li> </ol> <p>Congratulations to all participants and thanks to organizers for making this competition possible. Also, I would like to express my gratitude to my teammates for working together with me on this challenge. Below I will share some ideas used in our solution. Since I have been using quite a different approach from most of people in this competition, I decided to prepare a write-up regarding my part. </p> <h2>Look into data</h2> <p>It's probably the most important thing, especially for a competition like this.<br> <strong>Test might be recorded with 16 kHz sampling rate</strong>. Look at the example of test data:<br> <img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1212661%2F542dd41d9abe4e1d884a4a2453ec0cd6%2Ftest_spectrogram.png?generation=1600220233763583&amp;alt=media" alt=""><br> There is a frequency gap above 8 kHz that could suggest either that the data is recorded with 16 kHz sampling rate and then up-sampled to 32 kHz or that there is some noise filter used (which would be quite unlikely). Meanwhile below 1 kHz the noise it too high to recognize anything. Therefore, I've chosen <strong>1-8 kHz range</strong> for mel spectrograms using 128 mels. Based on CV drop, frequencies above 8 kHz might be important, but they are not present in test data, and high CV may be misleading. Also models may learn features not present in test if frequencies above 8 kHz are used.</p> <p><strong>Noise is the key</strong>. The test data depicted above is quite noisy and the overall level of signal is weaker than one in train (meanwhile while noise+signal is similar in train and test). So several things were used: adding white noise and taking test noise extracted by <a href="https://www.kaggle.com/theoviel" target="_blank">@theoviel</a> and posted <a href="https://www.kaggle.com/theoviel/bird-backgrounds" target="_blank">here</a>. In the second case the train signal is multiplied by an exponential random variable with lambda 0.25 limited at [0.1,1] and added to a randomly selected test noise chunk from concatenated noise array.<br> <img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1212661%2F76f6605687ce4c594ea9542e4445c07e%2Fnoise.png?generation=1600221824043141&amp;alt=media" alt=""><br> The produced train example looks quite similar (lower image) to test examples. Meanwhile, the original train data (upper image) has many features that could not be recognized at a high level of noise, and facilitates creation of a model that is good at CV but bad at test. Even training for several epochs with noise substantially improves the quality of the model, so top 5 predictions on test examples start making sense:<br> <img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1212661%2Fde0513d3685be301d6474e6e7ca0615f%2Fnoise1.png?generation=1600225333219466&amp;alt=media" alt=""></p> <h2>Model</h2> <p>I used a quite different approach from most of participants, which I schematically depict below:<br> <img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1212661%2F38e2de03b6065918c872efe81adf4e13%2Fmodel.png?generation=1600223467234638&amp;alt=media" alt=""><br> Instead of working with 5s segments, I worked with sequences: 20 and 40s for training and entire audio for inference. I collapse the frequency domain into dim of size 1 and then consider the produced tensor as a sequence and apply multi-head self-attention blocks to it, like in transformers. The produced output with stride of ~0.3s is merged with logsumexp pooling to produce the prediction for the entire audio segment or 5s intervals when run prediction on the test. During training the loss is computed based on global labels. I attached several examples below showing the prediction for top5 classes over time of my best model for first 40s of both test examples.<br> <img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1212661%2Ff5a60d9929f97f4d7caa2af4572ce615%2Fbest.png?generation=1600225290412477&amp;alt=media" alt=""><br> The spikes coincide with birdcalls, and if organizers provided more time resolved examples, sufficient at least to properly initialize the model, this method would be performing even better.<br> Training on 20 and 40s intervals is chosen to mitigate the possibility of having nocall in a sampled train chunk. In addition, consideration of an entire sequence during inference utilizes global attention, so the model is capable to incorporate knowledge about noise characteristics and different calls of the same bird when generate the predictions. Also, it naturally produces global predictions used for site_3. <br> The basic kernel showing training on 5s chunks and reaching 0.65 CV in 16 epochs is posted <a href="https://www.kaggle.com/iafoss/cornell-birdcall" target="_blank">here</a>. It provides the details of implementation of the above approach.<br> The performance of the best single model is <strong>0.622/0.588</strong> private/public LB. Ensemble of my models with more traditional models trained by my teammates (prediction based on 5s chunks with a number of additional tricks) boosted our public LB to 0.628 within last several days but unfortunately only slightly improved private LB, giving 0.622.</p> <p><strong>Additional details:</strong><br> Backbone: ResNeXt50<br> Loss: Focal loss, corrected to be suitable for soft labels<br> Augmentation: MixUp, white and test noise, stretch, temporal dropout.<br> External data: images beyond 100 examples<br> Use secondary labels with 0.1 contribution</p> <p><strong>Postprocessing</strong>: I have been using quite a complex pipeline finetuned on test examples: in this competition I made only ~15 subs. First, I generate global predictions above the threshold, based on logsumexp of the predicted sequence, and selecte top3 or top4 of them if their number is large. Next, I compute predictions for 5s chunks (using logsumexp of parts of the predicted sequence), selected ones that are above a particular threshold in comparison with their average value, and dropped all of predictions not listed in global ones. Finally, as suggested by my teammate <a href="https://www.kaggle.com/kirillshipitsyn" target="_blank">@kirillshipitsyn</a> , if both neighboring chunks have the same bird predicted I added this bird as a prediction, which gave 0.001+ boost. </p> <p>Some words about validation. I mostly considered test examples as a way to assess how good it the model. In my nearly first attempt I got ~0.80 CV (computed for the best threshold based on 4 fold train/val split) when trained on 20s chunks and ~0.83 CV when continued training on 40s chunks. However, when I checked the performance of the model on test examples, I realized that it predicts nearly nothing. Moreover, even top predictions are quite different from that should be. So I started adding such tricks as noise and 1-8kHz frequency range, which reduce CV but improve the model performance at test examples and LB. A good way to perform CV in this competition would be generating a val set based on train data with adding noise and excluding frequencies beyond 8 kHz, to make sure that it is as similar as possible to test examples. But I realize it nearly at the end of the competition. If I joined it not just 2-3 weeks before the deadline, probably, I could have more time to explore and fully handle the above ideas, and hopefully get better score at LB.</p>
Google Landmark Recognition 2020
31st place solution - single DELG model.
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Google Landmark Recognition 2020 <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>31 place model:<br> I only used a single DELG model and with no extra training just the pre-trained weights with extra parameters tuning and post/pre-processing like e.g. below.<br> <strong>RANSAC Parameters</strong></p> <p>This was a new area for me, not much of experience, so started to read a lot, posted some finding in forum with topic The world of RANSAC <a href="https://www.kaggle.com/c/landmark-recognition-2020/discussion/180921" target="_blank">https://www.kaggle.com/c/landmark-recognition-2020/discussion/180921</a></p> <p><strong>RANSAC Parameters</strong><br> <strong>MAX_INLIER_SCORE</strong></p> <p>Here I tested some values and a value of 20 had best result in the beginning but saw in the papers that a value of 70 was used, I ended up with a value in between to be safe. Couldn’t see that this was a part of the original ransac implementation, nor finding any papers on the subject, so didn’t gave it so much time. I also started using the DELG_SCORE_THRESHOLD_TENSOR and didn’t want to limit the data too much.</p> <p><strong>RANSAC Parameters</strong><br> <strong>MAX_REPROJECTION_ERROR, MAX_RANSAC_ITERATIONS, HOMOGRAPHY_CONFIDENCE</strong></p> <p>I had the following research paper as a code reference on the subject. “Image Matching Across Wide Baselines: From Paper to Practice” from 17 aug <a href="https://arxiv.org/pdf/2003.01587.pdf" target="_blank">https://arxiv.org/pdf/2003.01587.pdf</a> and also the Github <a href="https://github.com/ducha-aiki/pydegensac" target="_blank">https://github.com/ducha-aiki/pydegensac</a> </p> <blockquote> <p>“As usual, you may set pixel threshold for point to could as inlier, max_iters and confidence Besides this, there are following options:<br> laf_consistensy_coef. If &gt; 0, it means that scale and orientation of the feature will be checked for consistency with the far-the-best found model. The threshold for checking px_th * laf_consistensy_coef. Becayse they are usually less precise that keypoint center, it is recommended toset laf_consistensy_coef &gt; 1, e.g. 3.<br> error_type. The measure of the correspondence quality. Can be 'sampson', 'symm_sq_max', 'symm_max', 'symm_sq_sum', 'symm_sum'. For precise definition, please take a look to Chapter 4.2 Hartley and Zisserman "Multi View Geometry.pdf)"<br> symmetric_error_check If one should perform the additional check of the inliers with 'symm_max' error type"</p> </blockquote> <p>I tested many of the other included PyRANSAC options Symmetric_error_check, Error_type , laf_consistensy_coef, but didn’t changed the score to the better, default parameters Pixel Threshold, Max_iters and Conf worked best for this problem.</p> <p>From the paper I saw that for PyRANSAC a <strong>MAX_REPROJECTION_ERROR</strong> of 0.1-20 was used and they had the best threshold between 0.24-2.0, the baseline kernel had 4.0, for this Landmark problem I found with local validation that a value of 12 work best but used a value of 13 in the final model since it had a better Competition score.</p> <p>For <strong>max iterations</strong> they wrote in the paper:</p> <blockquote> <p>We summarize the optimal hyperparameters – the maximum number of RANSAC iterations η and the ratio test threshold r – for each combination of methods. The number of RANSAC iterations Γ is set to 250k for PyRANSAC, 50k for DEGENSAC, and 10k for both GC-RANSAC and MAGSAC</p> </blockquote> <p>And many public kernel used much higher iterations and they reported good results within that interval. In the DELG paper 1k was used for validation and same in the baseline. I could also see in my study of this parameter that the number of Iteration are related to number of outliner ratio, well described in this video <a href="https://youtu.be/5E5n7fhLHEM" target="_blank">https://youtu.be/5E5n7fhLHEM</a>. My conclusion was that an iteration of 5k was enough to fit the inference limit and the problem, and I also finally used 5k after some interval testing.</p> <p>In the same paper the <strong>confidence level</strong> was discussed,</p> <blockquote> <p>“All methods considered in this paper have three parameters in common: the confidence level in their estimates, τ ; the outlier (epipolar) threshold, η; and the maximum number of iterations, Γ. We find the confidence value to be the least sensitive, so we set it to τ = 0.999999”</p> </blockquote> <p>I kept the baseline value of 0.99 as it had not much effect of the outcome, had already tweaked the kernel into outer space at this time.</p> <p><strong>Max_distance</strong></p> <p>I left the max_distance to 0.85 even though in some paper the value 0.8 are used and I could also see better result with higher value, so here we had an interval of choices, but finally left the default value, too much tweaking had already been done.</p> <p><strong>Other notes:</strong></p> <p>In baseline code I think removing the pre_verification_predictions part will make the inference quicker as it only use the post_verification_predictions part.</p> <p>I tried the last days to cast with float16 and bigger batch size to speed up the inference, didn’t though time the inference, maybe it can help to fit more expensive settings or ensemble.</p> <p><strong>Other models:</strong><br> I trained my own model as well but did not have time to train it better.</p> <p>This was my first Landscape Recognition competition, so many new areas, ideas and valuable time trying to solve the problem.<br> A started to look at some of the previous competitions write-ups, research papers about the techniques and math’s used in the area, and also studied information from TF/DELG-sites, just to mark some for further reading and testing, it became a long list but a great driving license.</p> <p><a href="https://www.kaggle.com/c/landmark-retrieval-2019" target="_blank">https://www.kaggle.com/c/landmark-retrieval-2019</a><br> <a href="https://www.kaggle.com/c/landmark-recognition-2019" target="_blank">https://www.kaggle.com/c/landmark-recognition-2019</a><br> <a href="https://www.kaggle.com/c/landmark-retrieval-2020" target="_blank">https://www.kaggle.com/c/landmark-retrieval-2020</a></p> <p>I could see that using EfficientNets would be good strategy but would take some time to finish.<br> First though I started with instead using the baseline and DELG-models, as stated in the papers a single model could compete in the top-3 segment, good track record to follow. I should also have started train the Efficientnets directly and not in the middle of the competition, but now this was the case this time, and using ifs and buts is not a delicate approach.</p> <p><strong>Competition score and local validation ratio</strong></p> <p>After looking at the past Landmark competitions I saw that it where a minimal to non-shake-ups, so fitting and rely on the leaderboard score should be save.</p> <p><strong>EfficientNets</strong></p> <p>First a quick recap of the training of my own model.<br> Starting kernel <a href="https://www.kaggle.com/ragnar123/efficientnetb3-data-pipeline-and-model" target="_blank">https://www.kaggle.com/ragnar123/efficientnetb3-data-pipeline-and-model</a>, excellent work and all credit to <a href="https://www.kaggle.com/ragnar123" target="_blank">@ragnar123</a> and I had a plan to follow this great winning solution <a href="https://arxiv.org/abs/2009.05132" target="_blank">https://arxiv.org/abs/2009.05132</a>.<br> Trained a couple of EffNets 4-7, but with the limit of 40h/week on Kaggle TPU and 6h/day on Colab TPU, I should started the training much earlier in the competition to use them in final ensemble, Again - using ifs and buts is not delicate approach.<br> Best single model:<br> EffB7ns with GEM(3), ArcFace(0.1), No DropOut, 512Dim, SGDM, SyncBatchNormalization, weight average of 6 last epochs, no scheduler.</p> <p>Switched from 384 to 512 before it converged when I saw it shouldn’t converge before competition deadline. With the colab limit of 6h I had to split the training data to half to train them in different epochs, to fit the limit, not the best situation, maybe I could have done a better solution.<br> Trained with random_flip_left_right and used TTA flip_left_right in Inference, increased the score.</p> <p>Also used XLA and TensorFlow Auto Mixed Precision, the XLA part help to speed up the training but every attempt using mixed precision with TPU failed, could though start the training with 2x batch size but gave NAN loss after a while(?), even tried LossScaleOptimizer.<br> Ended up with Public 0.4924 Private 0.4721 – and not close to global minimum/maximum.</p> <hr> <p>That's all ! 🙂 And it gave me my first silver medal! 🙂<br> With this competition it's also time celebrate one year with Kaggle🎉, and with almost different challenges/problems every time I hope some will return my 2nd year, facing the competitions even better the second time with some experience :)</p>
OSIC Pulmonary Fibrosis Progression
34th place solution - Using CT Scans (+ Code)
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: OSIC Pulmonary Fibrosis Progression <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>I did not expect to win this comp so I was not immediately prepared with my solution or the code. I have made my code available here: <a href="https://github.com/GreatGameDota/OSIC-Pulmonary-Fibrosis-Prediction" target="_blank">https://github.com/GreatGameDota/OSIC-Pulmonary-Fibrosis-Prediction</a></p> <p>As always I want to thank Kaggle for another amazing competition as well as the hosts for putting this together!</p> <p>This was an interesting competition for me because I saw that everyone else were only using the tabular data. I have no experience at all with tabular data comps and I like CV so I was stubborn and forced myself to use the CT scans. I was discouraged by my poor LB score but I keep pushing and it turned out to be the correct decision!</p> <p>Anyway on to the solution:</p> <h2>Models</h2> <ul> <li>Resnet50</li> </ul> <h2>Dataset</h2> <p>Image resolution: 512x512<br> For each scan I loaded in all the dicom files then converted them to HU. I then cropped all the images and reshaped them to the size 50x512x512. After doing that I then windowed each image into three parts. For a detailed explanation of the windowing take a look at <a href="https://www.kaggle.com/c/rsna-str-pulmonary-embolism-detection/discussion/182930" target="_blank">this</a> post (I used the same function and window values as shared there, thanks so much Ian Pan!). After I got the three windowed images I simply saved them as pngs.<br> Each image looked similar to this:<br> <img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F3543139%2F3b1f2461da6d31658806e1ace841dd5f%2Flung.png?generation=1602033034958099&amp;alt=media" alt=""></p> <p>I made the dataset I used public here: <a href="https://www.kaggle.com/greatgamedota/osic-windowed-lung-images" target="_blank">https://www.kaggle.com/greatgamedota/osic-windowed-lung-images</a></p> <p>For meta data I used the same meta data from <a href="https://www.kaggle.com/ulrich07" target="_blank">@ulrich07</a> 's <a href="https://www.kaggle.com/ulrich07/osic-multiple-quantile-regression-starter" target="_blank">baseline kernal</a> except I only used the base Percent value as it increased my CV to LB to PB correlation.</p> <h2>Augmentation</h2> <ul> <li>Coarse dropout</li> <li>SSR</li> <li>Horizontal + Vertical flip</li> <li>For one model: Random Saturation and Brightness</li> </ul> <p>No tabular/meta augmentation</p> <h2>Training</h2> <ul> <li>Adam optimizer with Reduce on Plateau scheduler</li> <li>Trained with an LR of .003 for 30 epochs</li> <li>Batch size of 16 (bs of 4 for one model)</li> <li>Trained using Quantile Regression with .8 qloss + .2 metric loss (same as Ulrich's kernal)</li> <li>Trained 5 fold for every model</li> <li>Didn't use any batch accumulation or mixed precision</li> <li>Saved checkpoint based on best validation score (all weeks)</li> </ul> <p>For training I removed 6 entire patients because their CT scans were broken. I then split each patient into a fold by randomly shuffling them then using GroupKFold.<br> <img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F3543139%2F69a1967fbe3f4067d7fd9f6e5e91350c%2Ffolds.png?generation=1602036568284315&amp;alt=media" alt=""></p> <p>Then while training I pick a random unique patient and randomly select an image from 10-40 (since the first and last 10 images don't contain any lung info). I then made it so that each iteration lasted 4 * amount of patients. For validation I only picked the 15th image since it was the middle image that usually contains the most information.</p> <h2>Ensembling/Blending</h2> <p>Simple mean average of their FVC predictions and confidence</p> <h2>Final Submission</h2> <p>My final submission was a blend of 3 Resnet50 models:<br> <img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F3543139%2F773b5cc6fdf39b2fe77ec08d4b295684%2Ffinal%20sub.png?generation=1602040599569002&amp;alt=media" alt=""><br> And another point is that the single model that would have scored gold had the same training parameters as the other models except the added brightness/saturation augmentation</p> <h2>What didn't work</h2> <ul> <li>3d resnets (I tried for at least a month with these)</li> <li>Linear Decay Regression</li> <li>Any other type of model besides Resnets and Efficientnets (determinism issues)</li> <li>Efficientnets</li> <li>Simple meta data head (just concat)</li> <li>Random erase augmentation</li> </ul> <h2>Final Thoughts</h2> <p>I want to say again that this was an awesome comp that I am so glad I participated in!! Very glad to get my third medal and second silver medal! :D</p> <h2>Some helpful links</h2> <p>Inference notebook: <a href="https://www.kaggle.com/greatgamedota/osic-inference2?scriptVersionId=44254523" target="_blank">https://www.kaggle.com/greatgamedota/osic-inference2?scriptVersionId=44254523</a></p>
SIIM-ISIC Melanoma Classification
Justification and 4th place Solution Overview
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: SIIM-ISIC Melanoma Classification <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>First of all, thanks to the Kaggle community and the organizers.<br> I learned a lot through the competition.</p> <p>Some people suspect me to be a bot, so I will provide 4th place solution.<br> Certainly, I can't hide my surprise at this result.<br> But I'm a little disappointed with the skepticism of the competition itself.<br> I hope the contest is held in our good faith.</p> <p>I could not submit it many times, of course, because the participation period was not long.<br> In addition, the model was selected based on the CV results.<br> CV was done with multiple resolutions, and 384*384 was the best.<br> Also, When ensemble with the best scoring model,<br> I was able to efficiently raise the score by performing the ensemble at the rate that the difference from the result after the ensemble became the minimum.<br> By using this method, we were able to exclude the ones with very bad differences.<br> However, this method also carries the risk of overfitting public data.<br> I think there is also a risk in ignoring CV results and increasing the number of applications and raising the score.<br> In fact, the 4th private score I got wasn't the best model in public.</p> <p>And I think the main factors to win are:<br> I have found that some of the prediction results of the CV model predict a high positive rate, whereas many kernels predict a low positive rate.<br> I thought this was a false negative in many published models.</p> <p>I finally submitted the following 3 models.<br> (1) Best score<br> (2) Ensemble with best score and model considered in CV<br> (3) Due to risk of overfitting, ensemble with model other than the best score and model considered in CV </p> <p>As a result, Model (3) was the 4th place result. and, (1) was the worst.<br> From this result, the following can be said.<br> Like many kernel predictive models, the best-scoring model are also models with low sensitivity and is more likely to predict false negatives.<br> The highest scoring model fits public data too much.</p> <p>I think the following are valid:<br> Trust CV as many claims show<br> We also observe trends by comparing with the results of many models that have a low correlation with the results examined in CV.</p> <p>Of course, it is very lucky that the model (3) got the 4th place result.</p> <p>I am aware of my lack of skills. However, I've found the fun of kaggle.<br> I will continue to deepen my learning through other contests.</p> <p>Best Regards</p>
OSIC Pulmonary Fibrosis Progression
An efficient solution to Lung function decline prediction
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: OSIC Pulmonary Fibrosis Progression <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Hi, You can check out this notebook for an efficient solution to this competition.<br> Notebook link: <a href="https://www.kaggle.com/alifrahman/osic-pulmonary-fibrosis-progression-submission" target="_blank">OSIC Pulmuonary Fibrosis Progression</a></p> <p>Thank you for your time!😊</p>
SIIM-ISIC Melanoma Classification
1868th place in 1st competition!
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: SIIM-ISIC Melanoma Classification <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>I joined the competition very late, just 10 days ago. So, I forked a notebook: <a href="https://www.kaggle.com/niteshx2/full-pipeline-dual-input-cnn-model-with-tpus" target="_blank">https://www.kaggle.com/niteshx2/full-pipeline-dual-input-cnn-model-with-tpus</a> </p> <p>So, what did I do differently? I tried changing epochs, not using coarse drop out, removing duplicates and finally I used a trick that gave a 0.007 improvement. The trick was to take max of past 2 predictions. </p>
Google Landmark Recognition 2020
1st Place Solution
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Google Landmark Recognition 2020 <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Thanks to google and kaggle for hosting this yearly competition. It was a lot of fun exploring and learning all about global, local descriptors and algorithms to match similar images.</p> <h3>Brief Summary</h3> <p>Our solution is an ensemble of 7 global descriptor only models trained with arcface loss. We classify landmarks by KNN on an extended version of the train dataset and efficiently rerank predictions and filter noise using cosine similarity to non-landmark images. We did not use any local descriptors.</p> <h3>Detailed Summary</h3> <p>Below we give a detailed description of our solution of which architecture is only a small part.<br> Video content of us presenting the solution is available under:</p> <p>NVIDIA Grandmaster Series Ep2 <a href="https://youtu.be/VxNDH6qLZ_Q" target="_blank">https://youtu.be/VxNDH6qLZ_Q</a><br> Chai Time Data Science <a href="https://youtu.be/NRl3lMlixPc" target="_blank">https://youtu.be/NRl3lMlixPc</a></p> <h4>Pipeline</h4> <p>We wanted to use this competition as a chance to improve our pipeline and coding skills. While in past competitions we mainly used jupyter notebooks locally, we switched to a collaborative approach using scripts with github versioning for this one. After some acclimatization we clearly saw a benefit of our pipeline consisting of the following tools</p> <p>Github: Versioning and code sharing<br> Neptune: logging and visualisation<br> Kaggle API: dataset upload/ download<br> GCP: data storage</p> <p>So in practice we downloaded preprocessed data from google storage, trained our models using pytorch lightning where we logged with neptune and uploaded the latest version of our git repo and model weights to a kaggle dataset to use it in our inference kernel. This allowed us to experiment and iterate quickly.</p> <p>We are planning to release our code on github soon after some clean up.</p> <h4>Architectures</h4> <p>Our ensemble consists of 7 models using the following backbones available in the timm repository. Instead of much augmentation we trained our models on different image scales using albumentations.</p> <ul> <li>2x seresnext101 - SmallMaxSize(512) -&gt; RandomCrop(448,448)</li> <li>1x seresnext101 - Resize(686,686) -&gt; RandomCrop(568,568)</li> <li>1x b3 - LongestMaxSize(512) -&gt; PadIfNeeded -&gt; RandomCrop(448,448)</li> <li>1x b3 - LongestMaxSize(664) -&gt; PadIfNeeded -&gt; RandomCrop(600,600)</li> <li>1x resnet152 - Resize(544,672) -&gt; RandomCrop(512,512)</li> <li>1x res2net101 - Resize(544,672) -&gt; RandomCrop(512,512)</li> </ul> <p>We normalize the images by the mean and std of the imagenet dataset before feeding them into a pretrained backbone. All models use GeM pooling for aggregating backbone outputs. We use a simple Linear(512) + BN + PReLU neck before feeding into an arc margin head with m ranging from 0.3 to 0.4 predicting one of the 81313 landmarks. We use the 512 dimensional output of the neck as the image embedding (= global descriptor) The following illustrates our setup for a SEResnext101 backbone.</p> <p><img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1424766%2F6872393fee6bc154a4bf7d0127b62061%2FScreenshot%202020-09-30%20at%2013.30.05.png?generation=1601467910231165&amp;alt=media" alt=""></p> <h4>Training strategy/ schedule</h4> <p>We train all our models on gldv2 clean data only. Each model is trained for 10 epochs with a cosine annealing scheduler having one warm-up epoch. We use SGD optimizer with maximum lr of 0.05 and weight decay of 1e-4 across all models.</p> <h4>Ranking post-processing</h4> <p>As previous editions of this competition have shown, properly ranking and re-ranking predictions is crucial to improve the GAP metric at hand that is sensitive to how landmarks and non-landmarks are ranked respectively. So one major aspect is to specifically penalize non-landmarks that constitute a large portion of the test set. We always tracked both overall GAP as well as landmark-only GAP separately and evaluated all ranking experiments on our validation set that resembled the test set quite well. There are quite different ways to approach this ranking problem, and different ways can lead to success, but here is what we found to work extremely well.</p> <p>In the following graphic we visualize the main concepts of our ranking process. Test refers to the test set on the leaderboard, so the images we need to rank. Train refers to the candidate images we can use to determine the labels and the confidence. One important thing here is that we increased this set of images by all available images for the classes from gldv2_clean from gldv2_full. The 3rd place solution [1] notes that extending the dataset to include also these images improves their training, but what we found is that this is even more useful to be included in the inference process, which makes sense as there are more images to choose from. This also worked well on CV which is how we found it. And finally, Non-landmark includes all non-landmark images from the gldv2 test set. We then calculate all-pairs similarity between all of these sets. A measures the similarity to all available landmarks and their confidence. B measures the similarity of all train images to all non-landmark images and C does the same for the test images. </p> <p>The core idea is now to penalize A by B and C, so to penalize images that are similar to the non-landmark images. A is calculated between each test image and each train image. B and C are calculated by the mean similarity between the image and the top-5 (or 10) most similar non-landmark images.</p> <p>Then, the first step is to penalize A_ij by B_j, pick the top-3 most similar images, and sum the confidence for the same label and then pick the highest. Afterwards, this score is further penalized by C_i. Actually, using both B and C for penalization is a bit redundant, and just using either of those brings good improvements, with just using B is better than just using C.</p> <p><img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1424766%2F1e262e5afd63136dec8bc07e686a365a%2FScreenshot%202020-09-30%20at%2014.13.22.png?generation=1601468018948485&amp;alt=media" alt=""></p> <p>This whole procedure helps us to boost the actual landmarks to higher ranks and to penalize non-landmarks and rank them lower. Specifically B helps us to eliminate noise from the Train images. This gave both impressive boosts on CV and LB. <br> One more important thing to note here is that when calculating cosine similarity between different sets, the similarity metric benefits from similarly scaled vectors. So what we do is that we fit a QuantileTransformer (other scalers work similarly well) on the test set, and apply them on the train and non-landmark datasets. This makes the scores way more stable and we assume that this also adjusts differently sized images better.</p> <h4>Blending</h4> <p>For blending our various models, we first l2-normalize them separately and concatenate them and apply above mentioned quantile transformer on each feature. We then calculate for each model separately the top 3 scores from above and then sum the same labels across all top 3 scores from all models and select the maximum label. For calculating C, we use the concatenated embeddings. This procedure is a bit more robust compared to just using the concatenated embeddings, but for simplicity one can also rely on that approach as it produces very similar rankings.</p> <h4>A word on local descriptors</h4> <p>We tried hard getting something out of local descriptors. For that we tried DELG as well as superpoint.<br> DELG: first we tried to port the pretrained DELG to pytorch but gave up after struggling for a day with tf1 and tf2.0 mixups in the original implementation. Instead we extracted local features using the tf implementation directly as done in the public baseline. <br> Superpoint: We extracted local descriptors using the pretrained superpoint net, which is very fast.<br> We matched keypoints straight forward and applied RANSAC after. However the improvement even when using different image scales etc. was very small for both, DELG and Superpoint, and computational time for extracting and matching keypoints (especially when using DELG) was very high. Hence we did not use local descriptors in our final submissions.</p> <h4>What did not work</h4> <ul> <li>Training together with gldv1</li> <li>Training together with gldv2 full</li> <li>Using index dataset 2019</li> <li>Using test set from 2019 stage1 </li> <li>Hyperbolic image embeddings</li> <li>Superglue</li> <li>Deformable Grid</li> <li>1000 other things</li> </ul> <p>Thanks for reading. Questions welcome.</p> <p>[1] <a href="https://www.kaggle.com/c/landmark-recognition-2020/discussion/187757" target="_blank">https://www.kaggle.com/c/landmark-recognition-2020/discussion/187757</a></p> <p>update:<br> paper: <a href="https://arxiv.org/abs/2010.01650" target="_blank">https://arxiv.org/abs/2010.01650</a><br> code: <a href="https://github.com/psinger/kaggle-landmark-recognition-2020-1st-place" target="_blank">https://github.com/psinger/kaggle-landmark-recognition-2020-1st-place</a></p>
OSIC Pulmonary Fibrosis Progression
4th Place Solution
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: OSIC Pulmonary Fibrosis Progression <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>This moment seems to be magical, a 4th place finish. In my first two competitions(Trends and SIIM Melanoma), I ended with top 12% and 8% rank on final LB. I did not win big in those competitions but learnt a lot. </p> <p>In this competition, I believe that the tissue segmentation and other features extracted from CT scans made the difference. So what worked for us?</p> <ul> <li>Robust CV</li> <li>Good quality lung and tissue segmentation</li> <li>Rich features extracted from CT scans</li> <li>Ensemble of 10 models</li> <li>A lot of courage to not get baffeled by LB scores</li> </ul> <p>Tissue segmentation can be found <a href="https://www.kaggle.com/abhishekgbhat/tissue-segmentation-used-in-4th-place-solution" target="_blank">here</a><br> Feature Extraction and the entire data processing and inference pipeline can be found <a href="https://www.kaggle.com/abhishekgbhat/quantreg-linear-decay-efficientnet-b1-su" target="_blank">here</a></p> <p>It would be totally unfair if I dont thank the Kaggle community for selfless sharing of ideas and approaches on discussion forums and in the form of notebooks. Our solution is built on the amazing work done by other kagglers in this competition.</p> <p>I'd specially like to thank:</p> <ul> <li><a href="https://www.kaggle.com/andradaolteanu" target="_blank">@andradaolteanu</a> for her lung segmentaion notebook. This served as a base for our lung segmentation. With a few tweaks we could improve the lung segmentation and further add tissue segmentation as well.</li> <li><a href="https://www.kaggle.com/miklgr500" target="_blank">@miklgr500</a> for sharing Linear Decay notebook</li> <li><a href="https://www.kaggle.com/ulrich07" target="_blank">@ulrich07</a> for the Quant Reg notebook</li> </ul> <p>Thanks Everyone!</p>
OSIC Pulmonary Fibrosis Progression
My first Silver Medal on Kaggle! (65th on Private LB)
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: OSIC Pulmonary Fibrosis Progression <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>My hearty congratulations to all the winners of this competition. Quite honestly I have to admit that I gave up any hopes of winning this competition. I simply tried tinkering around with models &amp; ideas. And when I found that I had secured my first silver at my first ever serious kaggle competition, my joy knew no bounds! I had a public LB rank of 1480, the last time I checked, and I woke up to find a rank of 65. </p> <p>Here's a link to my quick inference Notebook: <a href="https://www.kaggle.com/doctorkael/osic-inference?scriptVersionId=44167954" target="_blank">https://www.kaggle.com/doctorkael/osic-inference?scriptVersionId=44167954</a></p> <p>My winning solution can be summarized as follows:</p> <p><strong>1. Perform data augmentation:</strong> Create synthetic week FVC from other patients data who have similar <em>cosine similarity</em>. For this purpose, we calculate the various features to ensure that augmented data is as similar as possible to the actual patients data. I also tried another type of augmentation with simple interpolation methods such as akima, linear, slinear, etc and used cross validation to see which performed the best at run time and use it to create models which would make the test predictions. </p> <p><strong>2. Some more augmentations</strong> (sort of): We treat each week's FVC and Percent as <em>Baseline</em> values from which we try to predict data for other weeks. This idea was borrowed from <a href="https://www.kaggle.com/yasufuminakama/osic-lgb-baseline" target="_blank">here</a>. It helps creating models that are more robust and helps when we have to predict for weeks -12 and the like when all the model would have seen otherwise is week -5. Using <code>Week_Offset</code> as feature instead of <code>Weeks</code> really helped here.</p> <p><strong>3. The model:</strong> The secret sauce was to use a simple Gradient boosting regressor to predict the confidence intervals. Methods on how to accomplish this can be found <a href="https://scikit-learn.org/stable/auto_examples/ensemble/plot_gradient_boosting_quantile.html#sphx-glr-auto-examples-ensemble-plot-gradient-boosting-quantile-py" target="_blank">here</a>. Choosing an <code>alpha</code> value of 0.75 worked best. We create models on all the different augmented data samples, cross validate them to see which perform best with least error in patient scores (since we only have 3 final predictions which would actually count in scoring, we need to minimize this).</p> <p><strong>4. Making Predictions:</strong> The maximum (for upper bound) and minimum (for lower bound) of all the predictions made for that particular patient and week is calculated, subtracted to obtain the the <code>Confidence</code> values.</p> <p>I would soon publish my notebook containing all the ideas I tinkered around with soon as it is still in an unedited format. </p>
Google Landmark Recognition 2020
7th place solution (with inference kernel + training code)
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Google Landmark Recognition 2020 <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Firstly, I want to thank my teammates <a href="https://www.kaggle.com/aerdem4" target="_blank">@aerdem4</a> and <a href="https://www.kaggle.com/dattran2346" target="_blank">@dattran2346</a> for their hard work. In this comp., they focused on improving global models so that I could spend time on local part.</p> <p>Our best sub. was geometric mean of similarities from 4 models (2 backbones SEResNext101+ResNext101-32x4d at 512x512 and 736x736 image sizes) + re-ranking by SuperPoint + SuperGlue. We pre-computed 1.6m train embeddings for 4 models, added them as ext. data and simply filtered for the relevant private image ids (100k) for inference.</p> <p><strong>1. Global models</strong><br> We continued training from our best checkpoints from retrieval challenge (<a href="https://www.kaggle.com/c/landmark-retrieval-2020/discussion/176151)" target="_blank">https://www.kaggle.com/c/landmark-retrieval-2020/discussion/176151)</a>. Our models were originally trained with focal smoothing loss with a tweak to work nicely with CosFace (thanks to Ahmet) on GLv2 clean dataset. For this comp., we used all the remaining train images from 81k classes (3.2m images) for re-training. We also came across the seesaw loss paper (<a href="https://arxiv.org/abs/2008.10032" target="_blank">https://arxiv.org/abs/2008.10032</a>) and decided to give it a try (thanks to Dat).<br> Model architecture was just simply CNN + GEM + Linear + BN + CosFace, like many other teams. <br> Our 2 models were then re-trained with these two losses as following:</p> <ul> <li>Stage 1: 20 epochs at size 512x512</li> <li>Stage 2: froze batchnorm layers, then fine-tuned at size 736x736 for 2 epochs.<br> Compared to the retrieval comp., our local validation scores were boosted by 5% and correlated well with the LB. From our estimates, 3% was due to adding extra data, 1% from the seesaw loss and 1% from larger image size.</li> </ul> <p><strong>2. Local model</strong><br> After obtaining the top-k nearest train ids for each test image, we used SuperPoint + HRNetv2 pre-trained on ADE20k dataset to filter predicted keypoints on sky/person/flowers/tree classes + SuperGlue (copied from the winning sol. at CVPR this year) to calculate the number of inliers between each image pair. Local score was then obtained using the formula provided by the host team (with max_num_inliers=200) and then multiplied with global score to get final score. This post-processing step gave a very strong boost (4-6% in public LB to our above global models). However, we noticed that the better the global models were, the less improvement this local re-ranking step gave us. In addition, we couldn't come up with a reliable strategy to evaluate SuperPoint+SuperGlue when integrating with global models locally. Relying solely on LB was pretty dangerous and we were lucky to stay at 7th 😅.<br> I also tried to re-train SuperPoint and SuperGlue on a subset of 200k clean train images but couldn't obtain any positive improvement.</p> <p>Our kernel + training code + model checkpoints were here: <a href="https://www.kaggle.com/andy2709/fork-of-recognition-notebook-16367c-511fa4-95d3bf?scriptVersionId=43685736" target="_blank">https://www.kaggle.com/andy2709/fork-of-recognition-notebook-16367c-511fa4-95d3bf?scriptVersionId=43685736</a>. </p> <p>P/s: The DELG weights + training config. files for 3 different backbones (res50, res101 and seres101) will be uploaded soon 😃. They were all trained with 512x512 images for 10 epochs with AdamW and cosine scheduler. In retrieval challenge, res50's perf was 0.299/ 0.268 (public/ private); others were higher so I'm quite confident in the implementation correctness. </p>
OSIC Pulmonary Fibrosis Progression
5th place solution
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: OSIC Pulmonary Fibrosis Progression <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>First of all, congratulations to the winners and thanks to kaggle and the hosts for this competition. Special thanks to <a href="https://www.kaggle.com/LukeReijnen" target="_blank">@LukeReijnen</a> for being an awesome teammate. I would also like to thank the community for sharing their ideas on what worked and did not work and for reinforcing the idea to trust your cv. </p> <h5>Model:</h5> <p>Now to the model. We used a small network with only tabular data. It had the following input features: <code>[WeekInit, WeekTarget, WeekDiff, FVC, Percent, Age, Sex, CurrentlySmokes, Ex-smoker, Never Smoked]</code>. These were followed by two dense hidden layers of each 32 nodes with the swish activation function. The output consisted of a node for the FVC prediction and a node for the direct prediction of sigma. To make the network predict values between 0 and 1, the outputs were multiplied by 5000 and 500 respectively.</p> <h5>Loss function:</h5> <p>We initially used the competition metric. However as we wanted a higher emphasis on MAE we used the loss function:<br> $$\frac{\sqrt2 \Delta}{70} + \frac{\sqrt2 \Delta}{\sigma_{clipped}} + \ln(\sqrt2 \sigma_{clipped})$$</p> <h5>Validation:</h5> <p>As validation technique, we used group K-fold. We split the patients into 5 folds of roughly equal size. As train and validation set we used all combinations of data for each patient with <code>WeekTarget &gt; WeekInit</code>. In other words, given a measurement of a patient, we trained on predicting all future measurements.</p> <h5>Data augmentation:</h5> <p>On the training set, we added Gaussian noise to the input. For FVC we used a rather big standard deviation of 500 mL. However, as we added the same noise to the target FVC that was to be predicted this turned out to work great. To change the percent feature accordingly, we added <code>Percent*FVC_noise/FVC</code> to it on top of the noise on percent. Finally, we normalized the input to lie roughly between 0 and 1.</p> <p>As prediction, we used the average of the FVC predictions across folds. For sigma, we used the quadratic mean of the predicted sigmas across folds.</p> <p>This was an interesting competition from which I learned a lot. We tried a lot of techniques that did not work out in the end but were fun implementing anyways. It was tempting to look at the public leaderboard score but we had often reminded ourselves to trust our CV. With a jump of ~1500 from the public LB that seems to have paid off. We are very pleased with the results and enjoyed this competition.</p>
OSIC Pulmonary Fibrosis Progression
Surrogate loss for modified Laplace log likelihood (79th solution)
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: OSIC Pulmonary Fibrosis Progression <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Congrats to all the winners and all those who survived the shakeup!</p> <p>I wasn't really present in the last month of this competition since I was moving house and my computer is in a shipping container somewhere on the sea, but I thought I'd share the loss function I made that served as a pretty good surrogate for the competition metric (in PyTorch). The predictions should be a tensor of shape (N, 2) where the first column is the FVC prediction, and the second is the confidence.</p> <pre><code>class LaplaceLogLikelihood(nn.Module): def __init__(self): super(LaplaceLogLikelihood, self).__init__() self.l1_loss = nn.SmoothL1Loss(reduction="none") self.lrelu = nn.RReLU() self.root2 = torch.sqrt(torch.tensor(2, dtype=torch.float, requires_grad=False)) def forward(self, predictions, target, clamp=False): delta = self.l1_loss(predictions[:, 0], target) if clamp: delta = torch.clamp(delta, max=1000) sigma = torch.clamp(predictions[:, 1], min=70) # clip sigma without destroying gradient else: sigma = self.lrelu(predictions[:, 1] - 70) + 70 laplace_ll = -(self.root2 * delta) / sigma - torch.log(self.root2 * sigma) laplace_ll_mean = torch.mean(laplace_ll) return -laplace_ll_mean </code></pre> <p>The delta part of the metric was easy - we can just use <code>L1Loss</code> or <code>SmoothedL1Loss</code> as I have.</p> <p>The tricky part was the <code>max(sigma, 70)</code> for the clipping of confidence. For this, I used a leaky ReLU so that we could do something similar without killing the gradient.</p> <p>My best private LB score was <strong>-6.8383</strong> (gold) using tabular only but of course, I chose the wrong version ☹️. I'm not going to make excuses, and there were people who had worked harder than me who deserved it more. I would say though a) trust your CV and b) annotate/track your notebooks clearly to make picking submissions easy for yourself</p> <p>Here's the complete code: <a href="https://www.kaggle.com/anjum48/fully-connected-custom-loss-private-6-8383" target="_blank">https://www.kaggle.com/anjum48/fully-connected-custom-loss-private-6-8383</a></p>
OSIC Pulmonary Fibrosis Progression
Making my (not submitted) 5th place solution public
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: OSIC Pulmonary Fibrosis Progression <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Hi everyone!</p> <p>This has been a very thrilling competition and I've learned a lot from it. Sadly I came late to properly implementing cross-validation and good tests, so I overlooked <a href="https://www.kaggle.com/dcasbol/osic-my-best-solution-6-8348?scriptVersionId=44213715" target="_blank"><strong>this solution</strong></a> I made some weeks ago. Anyway, I'm very happy with my 38th place 😁 and I hope someone can learn from what I wrote.</p> <p>This is a quick-release, but soon I will update it with proper balanced tests and so.</p>
Google Landmark Recognition 2020
6th place solution
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Google Landmark Recognition 2020 <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>We thank all organizers for this very exciting competition. <br> Congratulations to all who finished the competition and to the winners.</p> <h2>Summary</h2> <ul> <li>kNN based on global descriptor</li> <li>Non-landmark filtering with similarity between test set and GLDv2 test set</li> <li>We tried local descriptor methods but they were not used in our final submission</li> </ul> <h2>Model Details</h2> <p>We trained CosFace based global features models. <br> The settings are almost the same as our models in the retrieval2020 (See <a href="https://www.kaggle.com/c/landmark-retrieval-2020/discussion/175472" target="_blank">https://www.kaggle.com/c/landmark-retrieval-2020/discussion/175472</a>)</p> <ul> <li>Backbones: Ensemble of ResNeSt101, ResNeSt101, ResNeSt200</li> <li>Pooling: GeM (p=3) (Replace GeM p=3 with p=4 in testing)</li> <li>Head: FC-&gt;BN-&gt;L2</li> <li>Loss: CosFace with Label Smoothing</li> <li>Data Augmentation: HorizontalFlip, RandomResizedCrop, Rotation, RandomGrayScale, ColorJitter, GaussianNoise, Normalize, and GridMask</li> <li>LR: Cosine Annealing LR with warmup, training for 30 epochs + refine 5epochs</li> <li>Input image size in training: 352 (in refine: 640)</li> <li>Adding 600 non-landmark images sampled from the test set of the last year's recognition competition in training (this made the total 81,314 classes).</li> </ul> <p>Additionally, we tried "Inplace Knowledge Distillation" by MutualNet paper (<a href="https://arxiv.org/pdf/1909.12978.pdf" target="_blank">https://arxiv.org/pdf/1909.12978.pdf</a>) to train multi-scale image features efficiently. <br> It has been adopted for all models.</p> <h2>HOW descriptor based ASMK similarity</h2> <p>We tried HOW descriptor (<a href="https://arxiv.org/pdf/2007.13172.pdf" target="_blank">https://arxiv.org/pdf/2007.13172.pdf</a>) as an alternative of the global feature model. <br> HOW aggregates CNN based local descriptors into a single global descriptor with ASMK. <br> We trained a ResNet50-based HOW descriptor model (our pytorch implementation) and got public score = 0.5284 (private = 0.5044). <br> One of our final submission was based on blending between global cosine similarity and ASMK similarity, that achieved the best public score = 0.6298. However, the other global-feature-only approach achieved the better private score.</p> <table> <thead> <tr> <th>Final submissions</th> <th>Private</th> <th>Public</th> </tr> </thead> <tbody> <tr> <td>Global features</td> <td>0.5983</td> <td>0.6271</td> </tr> <tr> <td>Global + HOW ASMK</td> <td>0.5960</td> <td>0.6298</td> </tr> </tbody> </table> <h2>What did not work</h2> <ul> <li>Reranking top-k with HOW ASMK similarity (Blending similarity was better)</li> <li>Reranking top-k with DELG local descriptors</li> <li>DBA</li> <li>Replacing the private train set with GLDv2clean<ul> <li>Undersampling up to 350 images per class</li> <li>Removing classes that do not exist in the private train set</li></ul></li> </ul>
OSIC Pulmonary Fibrosis Progression
23rd Place Solution - Single Tabnet model
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: OSIC Pulmonary Fibrosis Progression <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>This was my first Kaggle silver medal, super happy about that 😄 This was a great learning experience for me. Kudos to all the winners and thanks to the entire Kaggle ecosystem.</p> <h3><strong>Solution Overview</strong></h3> <p>Tabular features and features obtained from CT scans were used in a <a href="https://github.com/dreamquark-ai/tabnet" target="_blank">Tabnet model</a>, trained with pinball loss. As a form of data augmentation, every FVC score available for each person was assumed to be the first FVC test score, and other features were built accordingly.</p> <p><strong>Training Notebook</strong> - <a href="https://www.kaggle.com/gautham11/quantile-regression-pytorch-lightning-training?scriptVersionId=44239361" target="_blank">https://www.kaggle.com/gautham11/quantile-regression-pytorch-lightning-training?scriptVersionId=44239361</a></p> <p><strong>Inference Notebook</strong> - <a href="https://www.kaggle.com/gautham11/quantile-regression-pytorch-lightning-inference/data?scriptVersionId=43574381" target="_blank">https://www.kaggle.com/gautham11/quantile-regression-pytorch-lightning-inference/data?scriptVersionId=43574381</a></p> <h3><strong>Tabular Features</strong></h3> <p>This is fairly straightforward.</p> <p><code>first_test_fvc</code> - FVC score of the assumed first visit<br> <code>predict_week</code> - Weeks from the CT scan, <code>Week</code> feature from the train data<br> <code>weeks_from_first_visit</code> - number of weeks from the first FVC test.<br> <code>expected_fvc</code> - <code>fvc * percent</code> this is a constant for each patient.<br> <code>percent</code> - Percent of the <code>first_test_fvc</code> when compared to the <code>expected_fvc</code><br> <code>age</code> - Age of the patient</p> <p>One-hot encoded values of <code>Sex</code> and <code>SmokingStatus</code></p> <h3><strong>CT Scan Features</strong></h3> <p>3D rescaled segmented lung model was generated for each patient from which the image features were obtained.</p> <p><strong>Segmentation</strong> - The lung segmentation was performed using <a href="https://www.kaggle.com/aadhavvignesh/lung-segmentation-by-marker-controlled-watershed" target="_blank">Marker-controlled watershed segmentation</a>, thanks to the amazing work by <a href="https://www.kaggle.com/aadhavvignesh" target="_blank">Aadhav Vignesh</a></p> <p><strong>Rescaling the voxel pixels</strong> - The rescaling was done using the <code>resample</code> method from <a href="https://www.kaggle.com/allunia/pulmonary-dicom-preprocessing" target="_blank">Pulmonary Dicom Preprocessing</a>. Thanks <a href="https://www.kaggle.com/allunia" target="_blank">Laura Fink</a> for the great kernel.</p> <p>The only issue I faced with this approach was to stay within the 4 hours submission runtime while generating the 3D models for private dataset in the inference notebook. I was able to overcome this by switching <code>scipy.ndimage.zoom</code> in <code>resample</code> function with <code>torch.nn.functional.interpolate</code>, which was much faster.</p> <p><strong>Image features notebook</strong> - <a href="https://www.kaggle.com/gautham11/lung-volume-lung-height-hu-values-image-features" target="_blank">https://www.kaggle.com/gautham11/lung-volume-lung-height-hu-values-image-features</a></p> <p><strong>train Image features dataset</strong> - <a href="https://www.kaggle.com/gautham11/lung-image-features" target="_blank">https://www.kaggle.com/gautham11/lung-image-features</a></p> <p>Image features generated are</p> <p><code>lung_volume_in_liters</code> - Number of segmented lung voxel pixels in 3d model / 1e6.<br> <code>lung_height</code> - Difference between the first and last slice with more that 1000 lung voxel pixels.<br> <code>lung_mean_hu</code> - Mean of the HU values.<br> <code>lung_skew</code> - skew of the HU values.<br> <code>lung_kurtosis</code> - Kurtosis of the HU values.</p> <p>And histogram bin values of the HU values in the 3D model were used as features - <code>bin_-900</code>, <code>bin-800</code>…<code>bin_200</code>.</p> <p>The inspiration for most of these features was from the <a href="https://www.kaggle.com/c/osic-pulmonary-fibrosis-progression/discussion/165727" target="_blank">Domain expert's insights</a> post by <a href="https://www.kaggle.com/sandorkonya" target="_blank">Dr. Konya</a></p> <p>These features gave me a good improvement in my CV score.</p> <h3><strong>Model Training</strong></h3> <p>The data was min-max scaled. The data was split into 5 folds, stratified on the <code>expected_fvc</code>, intuition being that split could be based on the Patients' characteristics, not sure if this was the best method. For each split, the Tabnet model was trained with <code>SGD</code> optimizer and One-cycle LR scheduler for 350 epochs.</p> <p><strong>Model weights dataset</strong> - <a href="https://www.kaggle.com/gautham11/gautham-quantmodel" target="_blank">https://www.kaggle.com/gautham11/gautham-quantmodel</a></p> <p>I gave Pytorch-Lightning a try for the first time in this competition, and I'm fairly certain that I'll use it in every project from here on.</p> <p>Finally, on selecting my submission, I selected my best CV score model and my best Public LB model. In retrospect, selecting the best Public LB model was a poor decision because it got a bad score in private LB, all the more affirmation to always <strong>trust the CV</strong></p>
Cornell Birdcall Identification
8th Place Solution
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Cornell Birdcall Identification <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Thanks to the competition host and kaggle teams for holding this competition and congratulations to all winners. And thanks <a href="https://www.kaggle.com/ttahara" target="_blank">@ttahara</a> for providing resampled train data and <a href="https://www.kaggle.com/rohanrao" target="_blank">@rohanrao</a> for external data. Also thanks <a href="https://www.kaggle.com/hidehisaarai1213" target="_blank">@hidehisaarai1213</a> for providing a good baseline and introduction to SED. I am excited to get my solo gold.</p> <h4>Train</h4> <p>The labels provided by competition host is super noisy. There is even a 40 minute audio with a single label. I think how to use the secondary label is vital in this competition. In my test, using only primary labels will only predict very view bird calls and get many nocalls. </p> <p><strong>Mix sound</strong></p> <p>In order to generate more samples and get clips with more than one bird(with good labels), I choose to mix the clips from audios with no secondary labels. I use an or operation to generate the labels for mixed clips and mix sound like this:</p> <pre><code>mixed_sound=sound1*uniform(0.8,1.2)+sound2*uniform(0.8,1.2)+sound3*uniform(0.8,1.2) </code></pre> <p><strong>Generate pseudo strong labels</strong></p> <p>I tried to generate pseudo strong labels with a SED method. I train SED models with 10s clips and make prediction on whole audios. However, the generated pseudo labels are still noisy and unreliable,there is too many false positives. Finally, I used them to fix labels for audios with secondary labels. </p> <p><strong>Train Detail</strong></p> <p>I used logmel spectrogram as input and randomly crop 5s clips from that. Then mixed sound augmentations will be applied to audios with no secondary labels, labels for audio with secondary labels will be adjusted according to pseudo strong labels. </p> <p>Making a good validation is very difficult in this competition, since there are no reliable nocall samples and a single clip can contain multiple bird calls. I chose to use a similar mechanism with site_3 audios in testset and calculated record-wise F1 scores. </p> <p>Preprocessing: MelSpectrogram-&gt; ToDB -&gt; Normalize -&gt; Resize</p> <p>DataAugmentation: GaussianNoise, BackgroundNoise, Shift, Drop, Clipping,</p> <p>Backbones: Resnest50, Regnety_040</p> <p>Single fold Score: 0.654/0.591/CV 0.75</p> <h4>Ensemble and TTA</h4> <p>In my best submission, the models are 5fold resnest50d(256x512) + 5fold resnest50d(320x768)+ 4fold regnety_040 (224x512).</p> <p>I used two shifted versions of sound clip as TTA, both with half hop length. However, they make no difference on LB as well as on my CV.</p> <h4>What works</h4> <p>Using secondary labels, record-wise F1 increases, but clip-wise F1 decreases. </p> <p>Train longer make result stable. Train with 40 epochs can also get decent scores, but the score is varying a lot. Training 80 epochs results in higher CV and stable scores in LB.</p> <h4>What doesn't work</h4> <p>Simulate nocall sound and train a binary classifier. There is a huge domain gap between simulated ones and real ones. The classifier just finds a shortcut. My classifier prediction is nearly all positive on competition data. </p> <p>It seems there is an additional mp3 compression for testset. I tried to finetune on compressed audios. It improves some score on public LB but not on private LB.</p> <p>Mixup make my result worse.</p> <p>Using more mel bins can improve local CV, but hurts LB.</p>
OSIC Pulmonary Fibrosis Progression
1st place "mostly" unpredictable solution
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: OSIC Pulmonary Fibrosis Progression <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Hi all! I am really happy to be among the top scorers of this competition, even though I didn't expect that much. My best solution is heavily based on <a href="https://www.kaggle.com/khoongweihao/efficientnets-quantile-regression-inference" target="_blank">this notebook</a> so kudos to <a href="https://www.kaggle.com/khoongweihao" target="_blank">@khoongweihao</a></p> <p><strong>Introduction</strong></p> <p>You might have noticed that during the competition there were a lot of public notebooks where authors just tuned the hyperparameters of the notebook mentioned above. When I started to solve this competition I noticed some unlogical parts in the notebooks, which for some reason resulted in a high score on the public leaderboard. My initial hypothesis was that on the private leaderboard those notebooks should fail, which turned out to be true. </p> <p>Here are some of the things that I have noticed:</p> <ul> <li>Usage of the "Percent" feature, there were even discussions on the forum about the usefulness of this feature. While it wasn't obvious if it was really useful or not I decided not to use that</li> <li>Strange blending weights for the models. To my mind, it was very illogical to give such a huge weight to the EfficientNet models because of 2 reasons. Firstly, we had only around 200 patients in the training set. Secondly, models were trained on the random slices of the initial 3d CT scans, which isn't a really reliable technique. </li> </ul> <p><strong>Validation</strong></p> <p>I tried different techniques of validation and none of them really correlated with the leaderboard. Finally, I stopped on the following validation scheme:</p> <p><img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F2139711%2Fe2fa663a66bb474595bbeb7b88fd7b7e%2Fscreen1.png?generation=1602065497962232&amp;alt=media" alt=""></p> <p>Even though I didn't notice any correlation with the public lb, I decided that this approach should be close to the one used in this competition for scoring. After creating this validation, if my model scored badly both on my validation and leaderboard - I disregarded it. But in terms of selecting the best submissions, it was still a black box for me.</p> <p><strong>Training, models, and final solution</strong></p> <p>I have tried a lot of things (I will add more about this below), but ironically the backbone to my best solution turned out to be this <a href="https://www.kaggle.com/khoongweihao/efficientnets-quantile-regression-inference" target="_blank">kernel</a> :)</p> <p>Speaking about my final solution, here is what I have done to achieve this score. Firstly, I trained both models (Quantile Regression + EfficientNet b5) from scratch. For both models, I lowered the number of epochs. For effnet I decided to train for 30 epochs and for quantile regression for 600 epochs. Then, I changed the architecture of Quantile Regression a bit, because on validation my architecture worked better. Apart from that, I removed all the "Percent" related features for both models, it turned out that it gave a huge boost on private lb for me. The hardest decision was how to choose the weights for the blend. Well, I just decided to give a slightly higher weight to Quantile Regression because for me it seemed to work better. Finally, I did some more improvements for the backbone notebook, for example, there was a part with the quantile selection based on the best loglikelihood score for the EfficientNet models. This part took ages to finish and moreover, for me, it looked like not a good decision, so I have just set the quantile to 0.5 and didn't select anything, this allowed my Inference notebooks to run in just 3 minutes total.</p> <p>Also, I would like to give a small tip, on how I tend to select submissions and verify the prediction correctness, in general, this helps me a lot. When I have trained the new model and receive the submission file, I always draw distribution plots of prediction values, along with plots for predictions themselves. Here is how they look like:</p> <p><img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F2139711%2Fdb8ced80a746d1946238e60ba981273a%2FUntitled.png?generation=1602065623926772&amp;alt=media" alt=""></p> <p>These are plots for the test set "Confidence" for a subset of my models, sometimes by looking at those plots you can identify strange model behavior and find a bug. In general, I always analyze the predictions really carefully and build a lot of graphs</p> <p><strong>What didn't work</strong></p> <p>As I have said I have tried a lot of stuff, but it almost always worked badly both on LB and CV. Here are a few things:</p> <ul> <li>Calculated lung volume with methods from the public notebooks and passed it as features for both models</li> <li>Tested other models, XGBoost, Log Regressions on tabular data. Thanks to my CV it immediately turned out that trees do not work here, so I didn't do anything with trees since the beginning of this competition.</li> <li>Since I was testing simple models, my 2nd selected submission was a really simple logistic regression model, which by the way landed in the bronze zone</li> <li>Augmentations for the CT scans worked bad, maybe I should have spent more time testing them</li> <li>Histogram features of the image didn't work either</li> <li>If you have analyzed model outputs, you might have noticed those spikes (both for Confidence and FVC)</li> </ul> <p><img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F2139711%2Fd0538eb2a86d7017f0042c79694ac4de%2FUntitled%20(1).png?generation=1602065688923432&amp;alt=media" alt=""></p> <p>It made total sense to remove them, but it didn't work on my validation, so I left it as is. It turned out it wasn't working on the private test set as well. Though, I am still confused about the reason why it happened.</p> <p><strong>Final words</strong></p> <p>This is my first gold on Kaggle and I am really happy about that. I am also happy about this huge shake-up which helped me land in the first place, which I wasn't expecting. I would like to thank all the Kaggle community for making so many notebooks public and being active on the forum! Without you guys, I wouldn't have learned that much during this competition and all other previous ones.</p> <p>And one last thing, don't ever track your public LB score, this mostly helps ;)</p> <p>Below I will attach links to my final submission notebooks, along with Medium writeup and Github repo.</p> <p><a href="https://www.kaggle.com/artkulak/inference-45-55-600-epochs-tuned-effnet-b5-30-ep" target="_blank">1st Place notebook</a></p> <p><a href="https://www.kaggle.com/artkulak/simple-logreg?scriptVersionId=44081090" target="_blank">Bronze zone very simple solution</a></p> <p><a href="https://medium.com/@artkulakov/how-i-achieved-the-1st-place-in-kaggle-osic-pulmonary-fibrosis-progression-competition-e410962c4edc" target="_blank">Medium writeup</a></p> <p><a href="https://github.com/artkulak/osic-pulmonary-fibrosis-progression" target="_blank">Github repository</a></p>
Cornell Birdcall Identification
33rd Place Solution
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Cornell Birdcall Identification <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>First of all thanks to competition organizer and Kaggle to host such interesting competition. For the first time I learned about audio features and how ML is applied on them. Quite a learning.</p> <p>Whatever improvement I got is during last 4 days.<br> Previous to that I struggled to match the best public kernel.<br> Anyways the score is of single fold Resnest50 as shared in public kernel.</p> <h1>Training process: key points</h1> <p>Extracted nocall (duration for which no labels are present) from example_test_audio and BIRDCLEF 2020 data and used as noise as well as extra nocall class.<br> As ResNet50 expect images with 3 channel and MelSpectrogram gives single channel I stacked three different Melspectrogram with window size of 1024,1536 ans 2048. Not sure is it a good technique as I have not evaluated the same model and training process with same channel duplicated.</p> <h1>Inference:</h1> <p>Same as available in public kernel with threshold of 0.5</p> <h1>Lots of areas for improvement</h1> <p>One idea was to select sample from competition training data based on available metadata like rating, duration, background birds.<br> Training more models and ensemble.</p> <p>At the end local CV (CV of random clips from validation data) matches the private leaderboard.<br> Also I think I am bit lucky as I see quite a lot pvt leaderboard shakeup.</p>
Halite by Two Sigma
Raine Force writeup (2nd place solution)
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Halite by Two Sigma <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>NOTE: Despite my team name "Raine Force" looks like using reinforcement learning, my agents are 100% rule based.</p> <p>Hi! I really enjoyed the halite competition. Thank Kaggle and Two Sigma staffs. In the kaggle-environments, helpers.py is really helpful for me. Also, thank competitors. Various strategies are interesting to watch replays.<br> Congratulations Tom! I think a reason that I reached such a great place is that my conversion strategy luckily had some amount of immunity against Tom's smart harass strategy. In fact, lose count of my best 5 agents is nearly equal to or greater than win count of them against best 5 agents of convexOptimization, Uninstall LoL, mzotkiew and KhaVo Dan Gilles Robga Tung.</p> <p><img src="https://github.com/viewlagoon/HaliteRaineForce/blob/main/images/table_Raine_Force.PNG?raw=true" alt="Raine Force vs top teams"></p> <p>However, win rate against Tom was different from top competitors (my best 5 agents got roughly 40% win rate against Tom's best 5 agents).</p> <p><img src="https://github.com/viewlagoon/HaliteRaineForce/blob/main/images/table_Tom_Van_de_Wiele.PNG?raw=true" alt="Tom Van de Wiele vs top teams"></p> <p>A notebook that I created the tables is <a href="https://www.kaggle.com/viewlagoon/halite-iv-count-win-or-lose-for-each-team" target="_blank">here</a></p> <hr> <p>Since other teams have already submitted good discussions, I mainly focus on Raine Force specific implementation in this discussion.</p> <ul> <li>Official rules are <a href="https://www.kaggle.com/c/halite/overview/halite-rules" target="_blank">here</a></li> <li>Collections of Post-mortems &amp; Bot Source Codes are <a href="https://www.kaggle.com/c/halite/discussion/186290" target="_blank">here</a> or <a href="https://www.kaggle.com/c/halite/discussion/184028" target="_blank">here</a></li> </ul> <hr> <h2>Stateful, Long term Decision Making</h2> <p>I call my high-level decision making AI "Projects".</p> <ul> <li>All projects firstly compute their priorities and sort by them, then run sequentially.</li> <li>If the project is not suitable, it returns less than 0 priority.</li> <li>The projects can hold ships and halite (as budget) for multiple steps to do consistent, long term decision making.<ul> <li>However, some of the projects rob ships from the other projects is still open to handle flexible urgent situations.<ul> <li>For example, HuntProject may rob ships from other projects.</li> <li>Swapping ship roles in some situations are valuable to move to target positions faster. However, it's difficult to implement swap task without bugs. Therefore I implemented it only in some very limited situations.</li></ul></li></ul></li> </ul> <h3>Actual projects (roughly sorted by priority)</h3> <p><img src="https://github.com/viewlagoon/HaliteRaineForce/blob/main/images/HuntProject_example.gif?raw=true" alt="HuntProject example"></p> <ul> <li>HuntProject (1 project per opponent ship)<ul> <li>Do ally ships surround the opponent ship? (= Is the opponent ship boxed in by my ship candidates?)</li> <li>It assigns 5 to 8 ships (1 or 2 ships for each direction) as many as possible to hunt stably.</li> <li>It does nothing (= no ships join to it) when surrounding is incomplete (ex. only 3 directions / only 4 ships) or when coordination of another opponent is required.</li> <li>If one of ally ships wants to stay but it stands on a halite ground and the opponent is not checkmate, it may back. Additionally, when the opponent ship's safe position is only one, they may use forward step prediction to move to a valid direction.</li></ul></li> </ul> <hr> <p><img src="https://github.com/viewlagoon/HaliteRaineForce/blob/main/images/DefenseShipyardProject_example.gif?raw=true" alt="DefenseShipyardProject example"></p> <ul> <li>DefenseShipyardProject (1 project per ally shipyard)<ul> <li>It assigns a ship which can reach the shipyard faster than any opponent.</li> <li>The ship mines ground halite if there are free steps. It conflicts to MineProject. Usually DefenseShipyardProject has much priority than MineProject, then MineProject is ignored and DefenseShipyardProject looks at the MineProject's halite threshold.</li> <li>The Target shipyard spawns if needed.</li> <li>It detects camper from current round history, and punish it.</li></ul></li> </ul> <hr> <p><img src="https://github.com/viewlagoon/HaliteRaineForce/blob/main/images/ExpeditionProject_example.gif?raw=true" alt="ExpeditionProject example"></p> <ul> <li>ExpeditionProject (1 project)<ul> <li>It assigns a ship.</li> <li>It decides whether converting another shipyard or not.</li> <li>It searches suitable position to convert.</li> <li>It reserves 1000 halite budget to spawn safely after convert.</li> <li>See Aggressive Conversion Strategy section for more details.</li></ul></li> </ul> <hr> <p><img src="https://github.com/viewlagoon/HaliteRaineForce/blob/main/images/EscortProject_and_MineProject_example.gif?raw=true" alt="EscortProject and MineProject example"></p> <ul> <li>EscortProject (1 project per ally ship)<ul> <li>It assigns an empty ship as a defender.</li> <li>Usually a target ship has halite, or is belongs to MineProject whose position is far from ally shipyards.</li> <li>Escorted ship can also join this project. It means that the ship just wants to return to shipyard, and to prevent other projects robbing it.</li> <li>In the late game, empty ship's target position is switched to a nearest opponent shipyard to attack.</li></ul></li> <li>MineProject (1 project per ground cell with halite)<ul> <li>It assigns a miner ship.</li> <li>It computes halite threshold (= how amount halite should be mined?). It depends on current step and ally/opponent shipyard distance, or hunt zone (see Shipyard Location section below).</li> <li>Risk management<ul> <li>If the miner mines here right now, can opponents surround and hunt the miner?</li> <li>Ignore cell at the neighbor of opponent shipyard.</li></ul></li> <li>Note that it's far from optimal mining because multiple cells coordination is very limited. Just the projects try to evade to assign neighbor cells simultaneously unless ships are very near.</li> <li>Discard projects when it cannot deposit to my shipyard in the late game (cell wise).</li></ul></li> </ul> <hr> <p><img src="https://github.com/viewlagoon/HaliteRaineForce/blob/main/images/RestrainShipyardProject_example.gif?raw=true" alt="RestrainShipyardProject example"></p> <ul> <li>RestrainShipyardProject (1 project per opponent shipyard)<ul> <li>1 or 2 ships harass to the shipyard.</li> <li>Since camping gives 2 other opponents advantage, some submissions including best one don't have the project.</li></ul></li> </ul> <hr> <ul> <li>Default Strategy<ul> <li>If a ship is not assigned by any project, a default strategy is just returning to shipyard and move around it to defend shipyards and plantations which grow halite by a regeneration rule (2% per step).</li></ul></li> </ul> <hr> <h3>Debugging</h3> <ul> <li>Debugging stateful agents are difficult.</li> <li>I kept stateless decision if possible. Otherwise, I reduced the number of states to minimum. The final states are few:<ul> <li>Ship id in some projects</li> <li>Halite budgets in ExpeditionProject and DefenseShipyardProject</li> <li>Ships' defending directions in HuntProject</li></ul></li> <li>I kept my codes replay reproductive<ul> <li>When I found suspicious move at step t, I gave the replay step 0 to (t - 1) to reproduce it. Then modified my code and retried to proceed to (t - 1), then checked new Q value again.</li> <li>Situations to use pure random value is very limited. Almost all to use pure random value is a game of chicken situation, that is, two player ships are located on cells nearby a fertil halite ground.</li></ul></li> </ul> <hr> <h2>Aggressive Conversion Strategy</h2> <h3>Motivation</h3> <p>Although Tom evaluated Raine Force agent as "its highly aggressive base conversion logic", my motivation to convert as many as possible, is quite conservative.<br> I respect to mzotkiew's hunting power and at the early stage of my agent coding (late August), I implemented HuntProject. The project was enough to hunt my miner even with an EscortProject defender, and I realized that it's often impossible or quite risky to carry halite for long distance. That's why my agents build shipyards at many places. I just want to deposit safely against offensive top competitors.<br> Urgent conversion is also conservative. When a ship detects that it can survive with staying, but Q values of 4 directions are less than conversion threshold, it tries to convert. See also Decision Ordering section.<br> The only thing which is truly aggressive conversion, is the second conversion. ExpeditionProject reserves 1000 halite budgets and converts an empty ship as fast as possible. Then I start with 7 ships and 2 shipyards while many other players start with 9 ships and 1 shipyard. I was not sure whether it works or not but replay logs indicates that it works well to dominate a center / edge / corner fertil position.<br> Another thing my agent looks like too aggressive is not a conversion but a late game spawning (It looks like Robiland). My spawning strategy evaluates number of ships, remaining steps and world ground halite. In fact, the origin of the late game spawning is not my intend (i.e. bug). Top players grow their halite well, and are careful to mine against powerful opponent attackers nearby, then the late game world halite are increased. My agents are confused that it's time to spawn. However, after my agents built many ships and shipyards, my ships attack and mine to their plantation and sometimes success to rob their fertil grounds. It sometimes leads to dominate the game completely and then other competitors may be impressed that Raine Force is too aggressive.</p> <p><img src="https://github.com/viewlagoon/HaliteRaineForce/blob/main/images/Aggressive_spawning_successed.PNG?raw=true" alt="Aggressive spawning could be successed"><br> <img src="https://github.com/viewlagoon/HaliteRaineForce/blob/main/images/Aggressive_spawning_failed.PNG?raw=true" alt="Aggressive spawning could be failed"></p> <hr> <h3>Shipyard Location</h3> <p>Many players imitated Fei Wang's triangle to grow internal ground halite and hunt mining opponents. I did it too in some submissions. However, in the other submissions including the best one, I prefer just to locate two shipyards diagonally. It is enough to grow and hunt in the internal rectangle/square because spawning from two diagonal shipyards can supply HuntProject candidates for all directions easily. I called the internal rectangle a hunt zone for me and a danger zone for opponents.</p> <p><img src="https://github.com/viewlagoon/HaliteRaineForce/blob/main/images/hunt_zone_example.gif?raw=true" alt="Hunt in hunt zone"></p> <p>ExpeditionProject calculates shipyard candidate score for every cell (more precisely, BFS from ship candidates of ExpeditionProject). Basic scoring is based on:</p> <ul> <li>surrounding halite</li> <li>increasing hunt zone</li> <li>decreasing danger zone</li> <li>distance between the other shipyards</li> <li>distance between the location and ship candidates<ul> <li>can safely reach? (when ExpeditionProject assigns non empty ship)</li> <li>decaying score for far locations</li></ul></li> </ul> <p>and executing threshold in ExpeditionProject is based on:</p> <ul> <li>number of remaining steps</li> <li>world ground halite / number of all player ships</li> <li>number of ships<ul> <li>Parameters are different among submissions, but I describe the parameters of my best agent here.</li> <li>Basically the threshold is 1 shipyard per 7 ships.<ul> <li>For example, if number of ships are greater than 14, then ExpeditionProject tries to convert 3rd shipyard.</li></ul></li> <li>If world ground halite are fertil, the threshold is 1 shipyard per 6 ships.</li> <li>If number of ships is top, the threshold is 1 shipyard per 4 ships.</li></ul></li> </ul> <p>However after I submitted at 9/13 and checked replay logs, I was firstly noticed that most of top players loved to attack an opponent shipyard nearby their shipyard (while Leukocyte loved to attack shipyards anywhere), in spite of giving advantage to two other opponents. Then the last two days I removed preference of decreasing danger zone and keep distance from opponent shipyards. Since urgent conversion is still remained outside of ExpeditionProject, sometimes my ship still converts in an opponent triangle and start war anyway.</p> <hr> <h2>Escape Strategy</h2> <p>Two simple principles are enough to understand my escape strategy when there is no safe position:</p> <p><img src="https://github.com/viewlagoon/HaliteRaineForce/blob/main/images/escape_strategy_example_1.gif?raw=true" alt="Escape Strategy"></p> <ul> <li>Go to positions which empty ships of two different players can reach.<ul> <li>To give opponents risks to cancel trade.</li> <li>One of the ship may be an ally. Typically it's an EscortProject defender.</li></ul></li> </ul> <hr> <p><img src="https://github.com/viewlagoon/HaliteRaineForce/blob/main/images/escape_strategy_example_2.gif?raw=true" alt="Escape Strategy"></p> <ul> <li>Go to positions with an empty opponent and ground halite<ul> <li>Typical attackers evade to mine except checkmate situations.</li></ul></li> </ul> <hr> <h2>Decision Ordering</h2> <ol> <li>All ships calculate their Q-values by projects or a default strategy.</li> <li>All ships calculate their priority by their cargo, number of surrounding ships and a parent ship (described below).</li> <li>Sort ships by the priorities.</li> <li>Resolve to move sequentially.</li> </ol> <ul> <li>I prepared two types of Q-values.<ul> <li>shape == (5,). default. mine / north / east / south / west<ul> <li>choose argmax direction.</li> <li>positions which the other ships determined to move, are masked.<ul> <li>I have map size flags to record next moving positions by determined ships.</li> <li>if optional argument "forced" is True, the ship can move to the position (for the last several steps).</li></ul></li></ul></li> <li>shape == (5, 5).<ul> <li>Ships can set a parent ship.</li> <li>Used Q values are depend on parent ship's moving direction.<ul> <li>For example, q[1, 4] is Q value that the parent ship moved to north and the target ship moves to west.</li></ul></li> <li>In the priority calculation phase, if parent.priority &lt; child.priority, parent's priority is increased. It can propagate to parent's parent, parent's parent's parent, …</li> <li>It is basically used by EscortProject. For example, a defender can set a miner as a parent ship.<ul> <li>When projects decide ships' Q values, an actual miner movement cannot be decided. Therefore I prepared (5, 5) shape for the defender.</li></ul></li></ul></li></ul></li> <li>The Q values also compared to convert threshold which depends on the ship's cargo and values described at ExpeditionProject.<ul> <li>If 4 moving Q values are less than convert threshold or masked, the ship tries to convert.</li> <li>When conversion is worthless, convert threshold is -infinity. It means that ships can select low Q value move such as move to empty opponent.</li></ul></li> </ul> <hr> <h2>Local Evaluation</h2> <p>Someone might have a question about local evaluation because I only submitted 17 times and 13 submissions are submitted during last 3 days (9/13, 14, 15).<br> Sadly, I have no impressive way. I implemented a simple system which reorder seats for 24 patterns, count win=1, lose=-1 for 6 pairs, continue playing. That's all. I always picked 4 agents by myself. I didn't consume time to build powerful matchmaking system. It is absolutely my weakness.<br> I prepared HuntProject and RestrainShipyardProject and it's eventually roughly enough to simulate uncomfortable opponent attacks except shipyard attacking… I implemented shipyard attacking in RestrainShipyardProject at 9/14.<br> My submitted agents still remain weaknesses. Especially I had a lot of TODO works in end game specializations such as leaving shipyard and no conversion without shipyard (escape only).</p> <hr> <h2>Source Codes</h2> <p>My best agent is on <a href="https://github.com/viewlagoon/HaliteRaineForce" target="_blank">GitHub</a></p> <hr> <h2>Conclusion</h2> <p>I developed 100% rule based agents which have:</p> <ul> <li>Projects to give roles and to do long term decision</li> <li>Aggressive conversion strategy to deposit halite safely and to create hunt zone</li> <li>Decision ordering system which uses Q values and priorities to evade collision</li> </ul> <p>Thank you for reading!</p>
OSIC Pulmonary Fibrosis Progression
Silver medal in three days of work
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: OSIC Pulmonary Fibrosis Progression <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Congrats to everyone and thank you Kaggle for hosting this competition.<br> This contest was by far one of the most realistic ones. </p> <p>I decided to join late this competition after I saw the public kernels, it was obvious that people were overfitting the public leaderboard. Then I decided to find the best validation strategy and use it to find new features and tune hyper-parameters.</p> <h2>Validation strategy</h2> <p>I used GroupKFold to create a K-fold partition (K == 3) with non-overlapping groups (here the Patient ID) and the distribution of patients across the folds is close to being uniform. (explanation and code took from <a href="https://www.kaggle.com/rftexas" target="_blank">@rftexas</a> 's notebook.</p> <p><img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1803801%2Fff68dceee4b8e5de81f1bcb5cc7dc1ca%2FScreen%20Shot%202020-10-07%20at%201.17.31%20AM.png?generation=1602030140932166&amp;alt=media" alt=""></p> <p>Then like I mentioned in this discussion, I didn't include the Percent feature in my validation folds and I only included the last three measurements for each patient. Why ? because I want to mimic exactly the testing dataset, since we don't have too many features, using Percent improved CV and Lb scores. BUT we only have initial Percent values in test. So I decided to create init_Percent feature that I used in my validation folds.</p> <p>With that I was able to have a good correlation between CV and LB scores, with that I was more confident.</p> <h2>Features used</h2> <p>I only used the tabular dataset and I kept features that improved my validation score. I didn't include weeks and base_week. <br> I created init_FVC and init_Percent features, there are the initial values of FVC and Percent for each patient.</p> <p><img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1803801%2F3f5a07f25b7a753c48d1807f173ae01b%2FScreen%20Shot%202020-10-07%20at%201.26.32%20AM.png?generation=1602030491883502&amp;alt=media" alt=""></p> <p>I added Sex_SmokingStatus <br> <img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1803801%2Fc3965f9c27c8278dfd6c2fed72ff62ae%2FScreen%20Shot%202020-10-07%20at%201.26.36%20AM.png?generation=1602030521844243&amp;alt=media" alt=""></p> <p>I used group statistics features<br> <img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1803801%2Ff93fb7f94f4636fe054e1c8133a4f94f%2FScreen%20Shot%202020-10-07%20at%201.26.26%20AM.png?generation=1602030547099121&amp;alt=media" alt=""></p> <h2>Model used</h2> <p>I used a simple neural network with pinball loss for multiple quantiles using [0.2, 0.5, 0.8].</p> <h2>What didn't work</h2> <p>I tried to extract features from images but I wasn't able to improve my CV score. <br> I also tried others models like linear regression and lightgbm but they performed poorly. Even ensembling them didn't improve my results.</p> <p>I didn't spent a lot of time in this competition, I didn't find time to improve this solution. </p> <h2>Key for this competition</h2> <p>Find the validation strategy that gives you a correlation between CV and LB scores !!!</p> <p>Again, thank you for this competition and for reading my solution, it is only a top 100 solution but it means a lot to me because I will be a kaggle competition master :p </p>
Lyft Motion Prediction for Autonomous Vehicles
7th place solution - Peter & Beluga
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Lyft Motion Prediction for Autonomous Vehicles <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><h4>Acknowledgements</h4> <p>Thanks for the organizers for this tough but certainly interesting challenge.<br> Special thanks for Vladimir Iglovikov and Luca Bergamini for their active forum contribution during the competition.</p> <p>Hats off to my team mate <a href="https://www.kaggle.com/pestipeti" target="_blank">@pestipeti</a> by the time I joined him he already had optimized the hell out of l5kit and had a solid training framework.<br> Then he managed to boost the training speed even further by <a href="https://www.kaggle.com/c/lyft-motion-prediction-autonomous-vehicles/discussion/199583" target="_blank">rasterizing the images on GPU</a>.<br> With all those improvements we were able to run dozens of experiments with different config parameters and slightly modified encodings during the last months.</p> <h4>Back to the future</h4> <p>We noticed that the training dataset and chopped validation set had slightly different feature distributions. After some digging we found that the chopped datasets (valid, test) always had availability for at least 10 future frames. It was quite the opposite than the default <code>AgentDataset</code> settings so we used that for training too. </p> <pre><code>AgentDataset( cfg, dataset_zarr, gpu_rasterizer, agents_mask=dataset_mask, min_frame_history=1, min_frame_future=10 ) </code></pre> <p>It helped both in terms of validation consistency and final score.</p> <h4>Poor Man's Ensembling</h4> <p>We did not hope that blending or any simple heuristic would help to combine different models. (I read clever tricks though and I hear that stacking works too…)</p> <p>The speed of the agent matters a lot and we saw that in our experiments. Intuitively for slower objects we used smaller raster size but more history.<br> Our final and best submission used three models based on speed (Total distance in the last 1 sec) </p> <ul> <li>[0-2] Slow model 320x220 with 3 sec history (compressed by 1.5 s) trained for 7+ days on slower examples</li> <li>[2-5] Medium model 320x220 with 3 sec history (compressed by 1.5 s) trained for 5+ days [1.5-12]</li> <li>[5+] Fast model 480x320 with 1 sec history on separate channels trained for 9+ days on [2+]</li> </ul> <h4>Things that did not work</h4> <ul> <li>We tried to use additional meta data (speed, acceleration, position, hour of the day, day of the week etc.) but it did not really help.</li> <li>We did not use satellite images at all. We noticed that they could have additional info (especially for pedestrians or cyclists) but it would be too slow.</li> <li>Different backbone. We tried a few other networks but mostly used Effnet-B2.</li> </ul>
Lyft Motion Prediction for Autonomous Vehicles
9th place solution
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Lyft Motion Prediction for Autonomous Vehicles <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>First, it was a well organized competition. The engagement from <a href="https://www.kaggle.com/lucabergamini" target="_blank">@lucabergamini</a> and <a href="https://www.kaggle.com/iglovikov" target="_blank">@iglovikov</a> on the forum is exemplarily, and one can see how <a href="https://www.kaggle.com/iglovikov" target="_blank">@iglovikov</a> corrects in this competition problems that he himself has probably experienced when he was a participant, well done. Second, I think Lyft investing and organizing Kaggle competitions is not something to be taken for granted. They give the data and lots of their time, but also expose their proprietary l5kit library to the competitors. I hope it pays off to a degree with the ideas that kagglers generate, but in any case thanks to Lyft for doing this, please continue. </p> <p>My solution at the end is surprisingly simple, because no fancy ideas have worked well. Yet, there are several things that helped me, I describe everything below. For me, it is once again a lesson to stick to the solid basics. I remember when I started 3 months ago I was excited to try GANs, as it <a href="http://papers.neurips.cc/paper/8308-social-bigat-multimodal-trajectory-forecasting-using-bicycle-gan-and-graph-attention-networks.pdf" target="_blank">seemed to be the state of the art</a>. I couldn't finish further away from it.</p> <h1>Data</h1> <h3>Samples selection</h3> <p>The dataset parameters are <code>min_history_steps = 0</code> and <code>min_future_steps = 10</code>, which is standard and what was probably used to chop the test data. And I added another layer of filtering, - based on the state index. Stated index is a frame's count inside its scene, ranging from 0 to 250. In test, state index is always 99. If one decides to train on a chopped dataset he basically constraints himself to state index 99. But this cuts too much data, so I built a mask similar to the existing mask and require <code>min_state_history = 30</code> and <code>min_state_future = 50</code>. I believe this change improved my scores. Without it I would get samples with state index starting from 0, which is not good.</p> <h3>zarr files</h3> <p>From the beginning I used full train zarr, and two weeks before the end I added the chopped validation and the test zarrs. That last part may sound surprising at first. Basically we have 100 frames in the test and validation, and with my states index filtering I look only at frames 30 to 50 to train on. It is a legitimate data for the training, and my motivation was to expose the models to any specifics of the test dataset, like a raining day. After all the filtering I had that much data for the training:</p> <ul> <li>140M full train</li> <li>1.4M test, frames 30-50</li> <li>1.9M validation, frames 30-50</li> </ul> <h3>Rasterization</h3> <ul> <li>12 frames <code>[0,1,2,3,4,5,8,10,13,16,20,30]</code> into the past</li> <li>3 channels semantic map</li> <li>another 3 channels of semantic map for history frame 30, gives traffic light 3s from the past</li> <li>future frame, when applicable (which is about <code>87%</code> of time). <a href="https://www.kaggle.com/c/lyft-motion-prediction-autonomous-vehicles/discussion/199498" target="_blank">Discussed here</a>.</li> <li>AV vehicle is marked with a black dot (see the above link for an example)</li> <li>raster size <code>[256,192]</code>, all the rest of the parameters are defaults</li> </ul> <p>All of the above modification have helped to improve the score. </p> <h3>Sampling</h3> <p>We had a lot of training data so I had a luxury to make sure that I did not attend the same sample more than once during the whole training. Basically I generated the order before the training and picked indices from it sequentially. </p> <h1>Model</h1> <p>The ensemble of 3 models, from <a href="https://rwightman.github.io/pytorch-image-models/results/" target="_blank">timm package</a></p> <table> <thead> <tr> <th>Model</th> <th>train</th> <th>validation</th> <th>LB public</th> </tr> </thead> <tbody> <tr> <td>mixnet_m, 3 traj</td> <td>12.10</td> <td>12.62</td> <td>12.976</td> </tr> <tr> <td>mixnet_l, 3 traj</td> <td>11.48</td> <td>12.02</td> <td>12.285</td> </tr> <tr> <td>mixnet_l, 6 traj</td> <td>6.88</td> <td>7.10</td> <td></td> </tr> <tr> <td>ensembled, 3 traj</td> <td></td> <td>11.61</td> <td>11.788</td> </tr> </tbody> </table> <p>The approach to the model is straightforward 3 or 6 trajectories prediction, I initially got the idea from <a href="https://www.kaggle.com/corochann/lyft-training-with-multi-mode-confidence" target="_blank">this kernel</a>, and it stuck. </p> <h3>Training</h3> <ul> <li>the best model <code>mixnet_l</code> was trained for <code>215 (epochs) x 64 (batch size) x 2500 (iterations)=34.4M</code> samples</li> <li>Adam optimizer</li> <li>learning rate <code>4e-4</code> decaying to <code>1e-7</code>. Most of the training on <code>1e-4</code> - <code>2e-4</code></li> <li>Auxiliary losses - also predicting 50 future velocities and yaws. It helped to converge faster, but not sure if it improved the accuracy. </li> </ul> <h1>Ensembling</h1> <p>I am proud of the ensembling procedure that I developed, however I have not tested it against the alternatives, and the benefit is only <code>0.5</code>. It seems like some people report good results with stacking, very interesting what is better. </p> <p>In my approach I gave weights <code>[0.8,0.3,0.5]</code> to my 3 models, which multiplied their own confidences. As a result I had 12 (3+3+6) trajectories with some probabilities assigned to them. How to ensemble those? I want to optimize the negative log likelihood metric and get three trajectories with confidences as output. If I assume that each of the 12 trajectories is a ground truth with its probability, then I have a well-defined optimization problem at hand. Still, it is a difficult non-convex optimization problem. By writing down the expression, requesting that the gradient equals to zero (local minimum requirement), I got to a fixed point formulation. Fixed point is an expression of form <code>x = f(x)</code>. From this by making several iterations I can get to an optimum. </p> <p>There are a couple of questions. First, does it always converge? In practice, it does always converge in 2-20 iterations. In theory it needs to be proven, I think it can be proven. Second, does it converge to a global minimum and not a local one? Given the problem structure I believe it is a global optimum, but maybe it is a global optimum only almost always. Third, does my original assumption about 12 ground truth trajectories with probabilities create a problem? It seems to me that it is a theoretically sounds approach, but it is a long discussion in itself.</p> <p>The advantages of the approach is that I run it in batches on GPU, very fast. The results are stable, and it accepts any number of input trajectories. Specifically, I trained the 6 trajectory model to cover a wider range of possibilities, knowing that I can ensemble them effectively. </p> <h1>Things that did not work, all in one big pile</h1> <ul> <li>weight decay, AdamP, AdamW, one-cycle learning rate policy</li> <li>freezing batch normalization layers at the last epochs of training</li> <li>changing agents box colors continuously based on their velocity. Bright - fast, dim - slow.</li> <li>GAN: train a model to differentiate between real and generated trajectories, with gradient reverse layer to propagate the gradient</li> <li>PCA: selecting 25 PCA components for 100 dimensional vector of the possible futures and learning to predict their coefficients</li> <li>predicting probability maps (like a segmentation task) and clustering those into 3 trajectories</li> <li>adding velocity, acceleration, yaws to the last layer of the network</li> <li>predicting trajectory as a difference above constant speed trajectory</li> <li>rasterizing output of a model and feeding it to a second level CNN model which outputs small corrections</li> <li>bigger raster sizes</li> <li>predicting heading and velocity instead of <code>x</code> and <code>y</code></li> <li>adding 1-2 fully connected layers on top of the model</li> <li>learning a "specialized" model, - one output trajectory for fast modes, one for turns etc.</li> <li>augmentations: random cutout of semantic map, removing random agents</li> <li>resnet18, resnet50, mobilenetv3_large_100, densenet121</li> <li>adding constant speed and constant acceleration models to the ensembling with low weights</li> <li>smoothing final trajectories with B-splines gave indecently small improvement</li> </ul> <p>Wow, I tried a lot of stuff. </p> <h1>Finally</h1> <p>Congratulations to the winners! It was a great competition, truly unique, challenging and rewarding.</p> <p>And with that I am happy to become Kaggle competitions grandmaster, number 197. Thank you Kaggle and kagglers for that journey!</p>
Lyft Motion Prediction for Autonomous Vehicles
Things I have tried and my final solution
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Lyft Motion Prediction for Autonomous Vehicles <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Congratulations to all the winners and thank the host for this very interesting competition. I have to admit that I did not expect a medal at all at the beginning. At some point I almost gave up, as the training was painfully slow, and I just could not get a reasonable score. This result gives me great motivation to keep trying in the future.</p> <p>Forgive me if my terminology does not make sense. Any feedback would be greatly appreciated. </p> <p>To my understanding, this is not a problem of finding three most likely future routes, which is equivalent to finding the one most likely route, as the second most likely route will always be the most likely route shifted by one nanometre. Instead, this is a problem of finding three routes that could best represent the probability distribution. Ideally, we want to include the less likely, but nonetheless typical routes. The most damage to our score probably will be caused by those less likely but very different routes. Therefore, we want diversity in our predictions, and simple ensemble might not work. </p> <p>My work is based on the model shared by <a href="https://www.kaggle.com/corochann" target="_blank">@corochann</a> <a href="https://www.kaggle.com/corochann/lyft-training-with-multi-mode-confidence" target="_blank">here</a>. While this simple approach to achieve multi-mode prediction is surprisingly effective, there is one thing that does not make sense to me, and I have been fighting with this problem most of the time: </p> <p>At every training step, the coordinates of all three predictions are all pulled towards the ground truth. The confidence of the prediction that is most close to the ground truth is increased, while the confidences for the other two predictions are decreased. Therefore, for the other two predictions that are relatively further from the ground truth, we are decreasing their confidence values (meaning now we think they are less likely) but pushing their coordinates to the ground truth (meaning making them more likely). Although at the early training stage this should not be such a big problem and the model is able to converge, I just cannot believe it can converge to an optimal point. <br> Other models such as classification models or NLP models would not have this problem as the target possibilities are fixed and finite. Here we are basically assigning confidence values to moving targets. </p> <p>I thought about several solutions: </p> <ul> <li>I constructed a “diversity” factor in the loss function. It is basically the average distance between three predictions. By adding this to the loss I was hoping I could gently push three predictions away from each other, reduce the effect of three predictions being pulled together. However, my experiments were of no success. The model either totally ignored this factor or used this factor as the only way to gain lower loss. I did not try many times because every experiment took too long. </li> <li>Make the coordinate space discrete and finite and assign a confidence value to every possible point in this space at each step. Then generate randomly many possible future routes. Finally do a k-means clustering to cluster the routes into three groups and take the centre of each group as the final prediction. I did not even finish the implementation of this idea as the computer power needed would be out of my reach. </li> <li>Very large batch size. It was until very late into the competition I suddenly realized that maybe increasing the batch size could mitigate (certainly not resolve) this problem. By letting the model see as many future possibilities as possible at each step, the model might learn to maintain the diversity of its three predictio<a href="url" target="_blank"></a>ns. It indeed worked, although to be honest I am not sure it was only because of the problem I mentioned above. </li> </ul> <p>So, my final solution might seem surprisingly simple to most people. I just used the good old Resnet18, a very small image setting of 150x150 with only 5 history frames, which enabled me to fit in a batch of 512 samples into my 8G VRAM. The optimizer is again good old Adam, with a learning rate starting from 0.0001 and reduce by half every 50000 steps. I trained on the full dataset, not because I think I need so much data, but to mitigate the problem of overlapping samples as discussed <a href="https://www.kaggle.com/c/lyft-motion-prediction-autonomous-vehicles/discussion/185762" target="_blank">here</a>. </p> <p>I trained 400k steps, which intermittently took me more than 15 days!!! After this, my computer and I were so exhausted, so we did not try other models or optimizers. </p> <p>(I tried accumulating gradients to increase the effect batch size but again the training was too slow, and the early result was not fantastic, possibly because of the incompatibility with Batch Normalization.) </p> <p>I guess, if we could make the batch size even bigger, and image size a little larger, train longer, or maybe use a more sophisticated model, there is potential to further improve the score significantly. </p> <p>By the way, I have never really solved the problem of deviation between my training loss and validation loss. After removing some problematic parts of my model and setting the min future and history frames in alignment with the validation dataset, the problem was only partly solved. My training loss has reached below 10 but validation loss was never below 12.10. This is not too bad, but I know some of you get much better alignment. How did you guys get the scores aligned? </p>
Lyft Motion Prediction for Autonomous Vehicles
4th place solution: Ensemble with GMM
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Lyft Motion Prediction for Autonomous Vehicles <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>Thank you to the organizers and congratulations to all the participants. <br> Also I would like to thank my team members <a href="https://www.kaggle.com/zaburo" target="_blank">@zaburo</a>, <a href="https://www.kaggle.com/qhapaq49" target="_blank">@qhapaq49</a>, <a href="https://www.kaggle.com/charmq" target="_blank">@charmq</a> for our hard work, I could enjoy the competition!<br> The LB was really stable in this competition due to the big amount of data, we could work on improving the model without caring about big shake-up.</p> <p>We have started with my baseline kernel <a href="https://www.kaggle.com/corochann/lyft-training-with-multi-mode-confidence" target="_blank">Lyft: Training with multi-mode confidence</a>.<br> Below items are substantial changes we made:</p> <p>[Update 2020/12/9] <strong>We have published our code:</strong></p> <ul> <li><a href="https://github.com/pfnet-research/kaggle-lyft-motion-prediction-4th-place-solution" target="_blank">https://github.com/pfnet-research/kaggle-lyft-motion-prediction-4th-place-solution</a></li> </ul> <h1>Short Summary</h1> <p><img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F518134%2Fa27c649533aca3f12e23255ed2295440%2Flyft_4th_place_solution.png?generation=1606414075335190&amp;alt=media" alt=""></p> <p>Published baseline training pipeline was indeed already very strong. <br> Just modifying</p> <ol> <li>train_full.zarr</li> <li>l5kit==1.1.0</li> <li>Set min_history=0, min_future=10 in AgentDataset</li> <li>Cosine annealing for LR decrease until 0</li> </ol> <p>with training 1 epoch was already enough to win the prize.</p> <h1>1. Use train_full.zarr data</h1> <p>Bigger data is almost always better for deep learning model training. We used <a href="https://www.kaggle.com/philculliton/lyft-full-training-set" target="_blank">Lyft Full Training Set</a>.</p> <p>However its size is really large, containing 191M data for AgentDataset.</p> <p>Practically we need this modifications in order to train this big dataset in real time:</p> <h2>Distributed training</h2> <p>We implemented distributed training using <code>torch.distributed</code>.<br> It usually takes about 5 days to finish 1 epoch when we use 8GPUs.</p> <h2>Caching some arrays into zarr beforehand to reduce on-memory usage in AgentDataset</h2> <p>The problem arises when we run distributed training and <code>DataLoader</code> with setting <code>num_workers</code> for multi-process data loading.</p> <p>In the distributed training, 8 processes run in parallel and each process invokes <code>num_workers</code> subprocess. Therefore 8 * num_workers subprocess is launched and <code>AgentDataset</code> data is copied in each subprocess.<br> Then Out Of Memory error occurs because <code>AgentDataset</code> internally holds <code>cumulative_sizes</code> attribute whose size is very big (<a href="https://github.com/lyft/l5kit/blob/1ea2f8cecfe7ad974419bf5c8519ab3a21300119/l5kit/l5kit/dataset/agent.py#L62" target="_blank">code</a>).</p> <p>Instead, we pre-calculated <code>track_id, scene_index, state_index</code> and saved as the zarr format. So that we can load each data from disk, and reduce on-memory usage.</p> <p>The Public Score was around <strong>25.742</strong> <a href="https://www.kaggle.com/corochann/lyft-prediction-with-multi-mode-confidence" target="_blank">kernel</a> at this stage.</p> <h1>2. Use l5kit==1.1.0</h1> <p>As mentioned in the discussion <a href="https://www.kaggle.com/c/lyft-motion-prediction-autonomous-vehicles/discussion/186492" target="_blank">We did it all wrong</a>, image is rotated while the target value is not rotated in the previous version of l5kit==1.0.6 during the beginning of the competition.<br> We updated l5kit version to 1.1.0 once it is released, which fixes this behavior.</p> <p>The Public LB score was jumped to <strong>15.874</strong> with this update.</p> <h1>3. Set min_history=0, min_future=10</h1> <p>As written in the “Validation Strategy” section, validation&amp;test data is made by <code>create_chopped_dataset</code> method. We noticed that this validation/test data consists of the data with A. always contains more than 10 future frames, and B sometimes it does not contain any history frame.</p> <p>To align the training <code>AgentDataset</code> to this test dataset behavior, we can set <strong><code>min_frame_history=0</code> and <code>min_frame_future=10</code></strong>.<br> I think <strong>this modification is the most important part to notice in this competition</strong>.<br> You need a courage to intentionally ignore l5kit library warning ;)(<a href="https://github.com/lyft/l5kit/blob/1ea2f8cecfe7ad974419bf5c8519ab3a21300119/l5kit/l5kit/dataset/agent.py#L15-L17" target="_blank">code</a>).</p> <p>It’s very effective, the score jumped to <strong>13.059</strong>.</p> <h1>4. Training: with cosine annealing</h1> <p>Model: We trained &amp; used following models for final ensemble</p> <ul> <li>Resnet18</li> <li>Resnet50</li> <li>SEResNeXt50</li> <li>ecaresnet18</li> </ul> <p>However resnet18 baseline was strong, and enough to win the prize.</p> <p>Image size: tried (128, 128) and (224, 224). image size of 128 training proceeds faster, but image size 224 final score was slightly better.</p> <p>Optimizer: Adam with Cosine annealing<br> Cosine annealing was better than Exponential decay. I think decreasing the learning rate until very close to 0 is important for final tuning.</p> <p>Batch size: 12 * 8 process = 96</p> <p>We just trained only 1 epoch to train full data. We did not downsample any of the data.</p> <p>Public LB score for single resnet18 model is <strong>11.341</strong>.</p> <h1>Augmentation</h1> <h2>Image augmentation</h2> <p>Many of the augmentation used in natural images is not appropriate for this competition task, (for example flip augmentation flips the target value as well and not realistic since right-lane, left-lane will change). We tried</p> <ul> <li>Cutout</li> <li>Blur</li> <li>Downscale<br> using <a href="https://github.com/albumentations-team/albumentations" target="_blank">albumentations</a> library.</li> </ul> <h2>Rasterizer-level augmentation</h2> <p>What is different from normal image prediction is that the image is drawn by rasterizer. We can also consider applying augmentation during rasterization.</p> <p>I tried following augmentation by modifying <code>BoxRasterizer</code> (<a href="https://github.com/lyft/l5kit/blob/1ea2f8cecfe7ad974419bf5c8519ab3a21300119/l5kit/l5kit/rasterization/box_rasterizer.py" target="_blank">code</a>).</p> <ul> <li>Drop agent randomly<ul> <li>I assumed that the target agent’s movement does not change so much when the other agent far from the target agent exists or not. So we randomly skip drawing some of the agent boxes.</li></ul></li> <li>Scale extent size randomly<ul> <li>Even when the other agent size changes a bit, I assume that the target agent’s behavior does not change. So we scaled extent size from factor 0.9~1.1</li></ul></li> </ul> <p>I thought rasterizer-level augmentation was an interesting idea for this competition task. However we could not see big score improvement actually. Maybe the training dataset size is already big enough and its effect is not so big.</p> <p>By <strong>only adding cutout augmentation</strong>, we achieved to get public LB score of <strong>10.846</strong>, already enough to win the prize. </p> <h1>Validation Strategy</h1> <p>As discussed in <a href="https://www.kaggle.com/c/lyft-motion-prediction-autonomous-vehicles/discussion/188695" target="_blank">Validation vs LB score</a>, we can run very stable validation using a chopped dataset.<br> However, it removes ground truth data, format is different from training AgentDataset and difficult to validate during training phase.</p> <p>What we want is <code>agents_mask_orig_bool</code> (<a href="https://github.com/lyft/l5kit/blob/1ea2f8cecfe7ad974419bf5c8519ab3a21300119/l5kit/l5kit/evaluation/chop_dataset.py#L68" target="_blank">code</a>).<br> We saved this <code>agents_mask_orig_bool</code> and set it to the <code>agent_mask</code> argument of <code>AgentDataset</code>.<br> Then we could run validation during training.</p> <p>We sub-sampled 10000 dataset for fast validation during training, but it differs a lot from the score using a total 190327 validation dataset.<br> At the end phase of the competition, we validated the trained model using a full validation dataset.</p> <h1>Ensemble: sample trajectory and GMM fitting</h1> <p>To improve the score further, how to ensemble is the key question in this task.<br> No golden method is suggested in <a href="https://www.kaggle.com/c/lyft-motion-prediction-autonomous-vehicles/discussion/180931" target="_blank">the discussion</a> and we came up with an idea to adopt the <strong>Gaussian Mixture Model</strong>.</p> <p>We can sample trajectory and fit the sampled points by GMM with the 3 components.<br> We started from the <a href="https://scikit-learn.org/stable/modules/generated/sklearn.mixture.GaussianMixture.html" target="_blank">sklearn implementation</a>.<br> Setting <code>n_components=3</code> and <code>covariance_type=”spherical”</code> achieved the good score.<br> However sigma is fixed to 1 in this competition <a href="https://www.kaggle.com/c/lyft-motion-prediction-autonomous-vehicles/overview/evaluation" target="_blank">metric</a>, so we also tried implementing own GMM model with fixing covariance to be 1.</p> <p>Ensemble by GMM was really effective, we finally achieved <strong>public LB score 10.272/private LB score 9.475</strong></p> <p>Thus, the ensemble pushed the public LB score from 10.846 to 10.272. But it does not change the final rank this time ;)</p> <p>By the way, I saw other participants used k-means clustering for ensembling coords. <br> I think the behavior is quite similar with using GMM, since it calls k-means clustering in the initialization of EM algorithm.</p> <h1>What we tried and not worked</h1> <p>We noticed Baseline model &amp; l5kit default rasterizer was already very strong in this competition.<br> We really tried a lot, but many of the attempts failed to improve the scores. I’ll write in the reply section (since it’s already very long).</p>
Lyft Motion Prediction for Autonomous Vehicles
classification approach
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Lyft Motion Prediction for Autonomous Vehicles <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>In the last week, I tried classification approach and it performed well or even better than my regression model.</p> <p>Due to time limitations, I just use K-Means on validation trajectories to get 1K target classes. In test, merge Top70 predicts to 3. Last day, I trained a 5K classes model and use Top400 to merge.</p> <p>Blend regression(three models) and classification(500, 1K, 5K classes) models to get public LB score improvement from 15 to 12.8</p> <p>My merge code:</p> <p>`from itertools import combinations</p> <p>def optimize_predicts(preds, topK=3, yp=1):<br> pred3 = []<br> comb = np.array((list(combinations(range(preds.shape[-2]), topK))))</p> <pre><code>for k in range(len(preds)): p = preds[k,:,:-1] y = preds[k,:,-1] cost = pairwise_distances(p)*(y**yp) labels = cost[comb[cost[comb].min(1).sum(-1).argmin()]].argmin(0) pr=np.zeros((topK,101)) for i in range(topK): sel = labels==i pr[i,:100] = ((p[sel]*y[sel,None]).sum(0)/y[sel].sum()) pr[i,-1] = y[sel].sum() pred3.append(pr) return np.array(pred3)` </code></pre>
Lyft Motion Prediction for Autonomous Vehicles
25nd place Summary
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Lyft Motion Prediction for Autonomous Vehicles <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><h2>Tools I used</h2> <ul> <li>Tensorflow/Keras</li> <li>Colab (with TPU, free version)</li> <li>Google Cloud Storage<br> I rendered the data offline, packed the data into .tfrec format, and uploaded them to Google Cloud Storage (~2TB), To ensure that the size would not be exploded, I compress the image into PNG format</li> </ul> <h2>Dataset</h2> <ul> <li>Used training (not full version*) and validation data</li> <li>Used default setting (from sample code) for rendering except min_future_frame ( = 10)</li> </ul> <h2>Network backbone</h2> <ul> <li>Xception<br> I had tried a lot of backbone provided from Keras and different version of Resnet (101, 50, 34, 18), and found Xception's quality was the best (through validation)</li> <li>Batch size = 256</li> </ul> <h2>Other tricks</h2> <ul> <li>Validation<br> Validation data and part of training data were used, and I separated both training and validation data into five parts by y-position of agent's center points. I made sure that the same (or similar) maps would not appear in both training and validation data simultaneously</li> <li>Multimode<br> I predicted 4 modes and picked the top-3 (determined by confidences) modes. Besides, I had tried more modes (&gt; 4) but found only 4 modes had larger confidence values while the other modes' never be picked. The unbalanced issue seems common in multimode trick</li> <li>Label smoothing <br> I "multiply" a small gaussion noise (mean = 1, std = 0.00333) to each ground truth.</li> <li>Custom loss function<br> I used the evaluation metric for multimode (provided from official) as loss function. To gave more penalty to the corner cases, the loss was multiply by a weight, which was proportional to the "Angle" of each agent<br> Angle = acos(x/sqrt(x**2 + y ** 2)), (x, y) is the coordinate of the final position of each agent </li> <li>Discard History<br> I used 10 history frames for training, but I found that around 5% testing data had history frames less than 10. So, I discard the history of target history frame randomly</li> </ul> <p>*Due to the limitation of memory in colab, I could not use preprocess full training data. So sad.</p>
Lyft Motion Prediction for Autonomous Vehicles
21st solution: freeze and stage-wise training
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Lyft Motion Prediction for Autonomous Vehicles <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>in summary (lb shown in red is public LB):<br> <img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F113660%2F936f4a397b66a26c15b2fe47ac47087c%2FSelection_063.png?generation=1606461205385767&amp;alt=media" alt=""></p> <p><img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F113660%2Fd426997c9a23e7b0777ede06cbb62de2%2FSelection_061.png?generation=1606460932975188&amp;alt=media" alt=""></p> <p><img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F113660%2Fef5337723983b036b1b613c6d4b87da5%2FSelection_062.png?generation=1606460950160462&amp;alt=media" alt=""></p> <p>since ensemble is difficult, I adopt stacking.</p>
Lyft Motion Prediction for Autonomous Vehicles
[Summary] 42nd place - What I did briefly, Single Model
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Lyft Motion Prediction for Autonomous Vehicles <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><h1>Intro</h1> <p>I joined this competition late. It was difficult to try many things.<br> So, I tried a few things.<br> (Maybe my solution is too simple. :) )</p> <h1>First Step</h1> <p>My first goal was to be in the top 100.<br> I used Resnet18 and train_full.zarr that have 224 raster_size.</p> <p>I got <strong>20.56</strong> lb score after about <code>80,000</code> steps.</p> <h1>Second Step - Switch to Resnet34</h1> <p>I got <strong>19.23</strong> after <code>25,000</code> steps. The performance has been greatly improved.<br> So, I trained more steps and finally got 15.080.</p> <p>Ensemble using public kernel's way didn't work for me.<br> And ensemble using a simple average way with same model helped public and private lb.<br> (But I didn't have many models. So, I used basic one and weights averaged model i.e. polyak.)</p> <ul> <li>I got public lb score of <strong>14.91</strong> </li> </ul> <h1>Third Step - Switch to Resnet50</h1> <p>2 days ago I switched my baseline model to resnet50.<br> When I trained resnet50, I found the interesting part between valid score and public lb.</p> <p>After <code>50,000</code> steps, public lb was <strong>19.132</strong> that it is bad compared to resnet34. But valid score is a pretty good.</p> <ul> <li><strong>12.504</strong></li> </ul> <p>I checked resnet34 and got a little bad valid score.</p> <ul> <li><strong>16.66</strong></li> </ul> <p>And also I observed mean loss when I trained resnet50.<br> <img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F3492127%2F33dd4f76a9b3e7f7a1d29a9f859e80fb%2F1.png?generation=1606395471230692&amp;alt=media" alt=""><br> [<code>Left</code>: When <code>57,000</code> steps - 19.194 loss, <code>Right</code>: <code>60,000</code> steps - 19.089 loss]</p> <p>In that points, lb scores are:<br> <img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F3492127%2Fe307542c1bcee60540d08583a092e717%2F2.png?generation=1606396024722504&amp;alt=media" alt=""></p> <p>I just trained resnet50 after <code>100,000</code> steps and got public lb score <strong>16.076</strong>.<br> (I have no time for training. haha)</p> <h1>Final</h1> <p>I selected resnet34 and resnet50.<br> <img src="https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F3492127%2Fcf29ed6aadd3b67951817754a9691fbe%2F3.png?generation=1606396517653027&amp;alt=media" alt=""></p> <p>As you can see, resnet50 got better private lb despite public lb score.<br> (I wasn't sure, so I didn't choose the ensemble model.)</p> <h1>Etc.</h1> <p>I did some other experiments such as raster size - 300 and finetuning model using high raster size, but It is not good for me. Single model is best. haha<br> I tried <a href="https://www.kaggle.com/pestipeti" target="_blank">@pestipeti</a> advices for improving training speed but my hardware is not good for this. (no spaces and no time) Anyway, Thanks all. :)</p>
Lyft Motion Prediction for Autonomous Vehicles
22nd place journey : a completely different motion prediction approach
Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge
<|system|>You can successfully explain and teach others topics and concepts from Kaggle competition solution write-ups. You are a highly talented data scientist who has shown exceptional performance in this data-science Kaggle competition: Lyft Motion Prediction for Autonomous Vehicles <|user|>Explain and teach me concepts from Kaggle competition solution write-ups that solved this challenge <|assistant|><p>First of all, many thanks to the Kaggle team and Lyft team for hosting this competition, and congrats to all winners! Thanks to my teammates too, especially <a href="https://www.kaggle.com/doanquanvietnamca" target="_blank">@doanquanvietnamca</a> for his hard work and commitment during all those 3 laborious months.</p> <h1>Preditcting agent motion with PointNet architecture …</h1> <p>Our ideas are mainly based on the pointnet architechture. We totally forgot about L5kit package and deal with the raw data which was transformed into a 4D tensors of shape (num_mini_scenes, max_agents_on_frame, num_backward_frames, num_features). Those tensors are concatenated over n_batches scenes and feed to the pointnet architecture. We was able to reach a score of 21.xx by using a single pointnet model but things become harder and we got stuck.</p> <h1>Breakthrough ideas</h1> <p>To push our model performance a little bit, we manage to stack many pointnet models. This was doable since pointnet is very lightweight. Each model will look at a limited time step back to the agent history and output some embeddings of the scenes, the embeddging are then projected into a lower dimension space and concatenated. A simple full connected head is responsible for outputing the final 300+3 predictions.<br> Our best model is composed of 4 stacked models which resp. look at 10, 5, 3, and 1 frame back into the agent history. We use a simple zero padding for agents with no enough frames. With that giant pointnet model (~40 M params), we was able to reach a score of 13.353 on the public LB and 12.912 on the private.</p> <h1>Custom loss and training</h1> <p>We implement a custom version of the competition loss in which agent's loss is ignored when it leaves the scene. This custom loss allows us to try things like sample weight, penalization … We use <strong>pytorch-lightening</strong> to ease things. We maingly train on Colab, which is just owesome given the huge size of the competiion dataset. The optimizer is the classical Adam with a step learning rate scheduler, nothing fancy over there.</p> <h1>Things that doesn't work</h1> <ul> <li>Sample weight</li> <li>Bagging: we try a lot of ideas, and they all fail :(</li> <li>RNN : we try a LSTM over time-stacked models without any success</li> <li>Longer history : augementing the history step leads to worse results (likely because of the many zeros coming from our zero padding stratedy)</li> </ul> <h1>Advantages of our model</h1> <ul> <li>Very fast model, whole inference last 14 min's with single model and less than 30 minutes with tens of stacked models</li> <li>Training on whole train_full takes just 30' with a light pointnet model and 1h30' with 4 stacked models on a Colab Tesla-V100 single GPU</li> </ul> <h1>Cons of our model</h1> <ul> <li>Our pointnet implementation is completely road lanes blinded, even if we manage to incorporate light faces info in some extents</li> </ul> <h1>Things we may like to try</h1> <ul> <li>Moving from pointnet to other point-cloud models or voxel based models (pointCNN, point-Voxel, ShapeNet, …)</li> <li>Stacking &amp; transfer learning: use our best models as embedders and train a simple model on top of them</li> <li>Combining our model with other image raster models (this one could make the pointnet road lanes aware)</li> <li>3D convolutions</li> </ul> <p>PS: Our inference code by <a href="https://www.kaggle.com/doanquanvietnamca" target="_blank">@doanquanvietnamca</a> is available <a href="https://www.kaggle.com/doanquanvietnamca/22st-solution-kkiller" target="_blank">here</a> .</p>