# #6 Solution 

The main thing I took from my previous 2 competitions was that spending time in really understanding the problem and analyzing data was key to succeed. So in this one I started by carefully reading all papers, and I quickly realized that the data was from P4677. Actually, I realized it a couple of days before it was disclosed. The size of the train and test sets were 60-40% in both, the competition and the paper, so there was a first reason to think that the test set of the competition was the same. However, there was still a chance that the test set of the competition was different.
So my first step was to visually select the experiments (cycles) from the training set, trying to match the length of those in the paper (with a ruler :smile:). At first I picked 9 from the 15 full cycles of the training data. Then I compared some features and realized that they became much more similar between train and test for the selected subset of experiments, which supported that the test set was the one of the paper:
![Comparison AbsMean Train vs Test](assets/d2aef9a9cccd85dfad5a5859.png)
Using those selected cycles, I realized an inverse correlation between my CV and the public LB, so I totally forgot about the LB. Actually, my 2 selected submissions scored 1.96799 and 1.82806.
Nevertheless, I wanted to use more data than just the 9 experiments (the data was already small!), while trying to match train and test distributions. To solved this, I picked 4 different subsets from the training data, I built a model for each of them and I finally blended their predictions. I used 11 cycles from the training sets in total but in different combinations. For each of those 4 training data subsets I followed the following steps:
- Feature selection (using shap most important features and also forward and backward feature elimination). I elimianted all features with different distributions in train-test.
- Transform features to standard normal distribution, since I saw a shift between train and test:
![Transformation to Standard Normal Distribution](assets/d12f0e9e086d486775f23dac.png)
- Build 3 models: LGBM, XGB and a shallow NNet (1 or 2 layers with less than 7 nodes). This shallow NNets worked well (on transformed data). LGBM and XGB tuned using bayesian optimization.
- Blend the 3 models selecting the weights by hand (trying to avoid overfitting).
This is the summary of the model:
![Summary](assets/5a4c7ce9cdd34d08d181e557.png)
The oof predictions of the model with the largest weight in the final blending:
![oof](assets/702efa001858da5218ee0818.png)
Finally, congrats to all the winners and to those who survived the leaderboard earthquake! I guess my experience with earthquakes as a Chilean helped me a bit :smiley: