Need help with Kaggle_HomeDepot?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

452 Stars 207 Forks MIT License 65 Commits 1 Opened issues


3rd Place Solution for HomeDepot Product Search Results Relevance Competition on Kaggle.

Services available


Need anything else?

Contributors list

No Data


Turing Test's Solution for Home Depot Product Search Relevance Competition on Kaggle


| Submission | CV RMSE | Public LB RMSE | Private LB RMSE | Position | | :--- | :-------: | :--------------: | :---------------: | :------------------: | | Simplified Single Model from Igor and Kostia (10 features) | 0.44792 | 0.45072 | 0.44949 | 31 | | Best Single Model from Igor and Kostia | 0.43787 | 0.44017 | 0.43895 | 11 | | Best Single Model from Chenglong | 0.43832 | 0.43996 | 0.43811 | 9 | | Best Ensemble Model from Igor and Kostia | - | 0.43819 | 0.43704 | 8 | | Best Ensemble Model from Chenglong | 0.43550 | 0.43555 | 0.43368 | 6 | | Best Final Ensemble Model | - | 0.43433| 0.43271 | 3 |





for documentation.


Chenglong's Part

Before proceeding, one should place all the data from the competition website into folder


Note that in the following, all the commands and scripts are executed and run in directory


Step 1. Install Dependencies

1. Python

We used Python 3.5.1 and modules comes with Anaconda 2.4.1 (64-bit). In addition, we also used the following libraries and modules: - gensim 0.12.4 - hyperopt - keras 0.3.2 - matplotlib-venn 0.11.3 - python-Levenshtein 0.12.0 - regex 2.4.85 - xgboost 0.4

2. R

We used the following packages installed via

: - data.table - Rtsne
3. Other

We used the following thirdparty packages: - rgf 1.2

Step 2. Prepare External Data

1. Pre-trained Word2Vec Model

We used pre-trained Word2Vec models listed in this Github repo. In specific: - Google News - Wikipedia+Gigaword 5

We used glove-gensim to convert GloVe vectors into Word2Vec format for easy usage with Gensim. After that, put all the models in the corresponding directory (see
for detail).
2. Other

We also used the following external data: - Color data from this Kaggle forum post, i.e.,

in this repo. - Google spelling correction dictionary from this Kaggle forum post, i.e.,
in this repo. - Home-made word replacement dictionary, i.e.,
in this repo. - NLTK corpora and taggers data downloaded using
, specifically:

Step 3. Generate Features

To generate data and features, one should run

. While we have tried our best to make things as parallelism and efficient as possible, this part might still take 1 ~ 2 days to finish, depending on the computational power. So be patient :)

Note that various text processing are useful for introducing diversity into ensemble. As a matter of fact, one feature set (i.e.,

) from our final solution is generated before the Fixing Typos post, i.e., not using the Google spelling correction dictionary. Such version of features can be generated by turning off the
flag in

After team merging with Igor&Kostia, we have rebuilt everything from scratch, and most of our models used different subsets of Igor&Kostia's features. For this reason, you should also need to generate their features. Since Igor&Kostia's features are in

dataframe format, we provide a converter
to convert them to the format we use, i.e.,

Step 4. Generate Feature Matrix

In step 3, we have generated a few thousands of features. However, only part of them will be used to build our model. For example, we don't need those features that have very little predictive power (e.g., have very small correlation with the target relevance.) Thus we need to do some feature selection.

In our solution, feature selection is enabled via the following two successive steps.

1. Regex Style Manual Feature Selection

This approach is implemented as

. The general idea is to include or exclude specific features via
operations of the feature names. For example, - one can specify the features that he want to include via the
variable, despite of its correlation with the target - one can also specify the features that he want to exclude via the
variable, despite of its correlation with the target (
has higher priority than

The output of this is a feature conf file. For example, after running the following command:

python -d 10 -o

we will get a new feature conf
which contains a feature dictionary specifying the features to be included in the following step.

One can play around with

to generate different feature subset. We have included in
a few other feature confs from our final submission. Among them,
is used to build the best single model.
2. Correlation based Feature Selection

With the above generated feature conf, one can combine all the features into a feature matrix via the following command:

python -l 1 -c feature_conf_nonlinear_201604210409 -n basic_nonlinear_201604210409 -t 0.05


-t 0.05
above is used to enable the correlation base feature selection. In this case, it means: drop any feature that has a correlation coef lower than
with the target relevance.

TODO(Chenglong): Explore other feature selection strategies, e.g., greedy forward feature selection (FFS) and greedy backward feature selection (BFS).

Step 5. Generate Submission

1. Various Tasks

In our solution, a

is an object composite of a specific
) and a specific
from xgboost). The definitions for
are in

Take the following command for example.

python -m single -f basic_nonlinear_201604210409 -l reg_xgb_tree -e 100

- It runs a
. - The
is optimized with hyperopt for
evals for searching the best parameters for
. - The
performs both CV and final refit. CV in this case has two purposes: 1) guide hyperopt to find the best parameters, and 2) generate predictions for each CV fold for further (2nd and 3rd level) stacking. - For all the available learners and the corresponding parameter searching space, please see

During the competition, we have run various tasks (i.e., various features and various learners) to generate a diverse 1st level model library. Please see

for all the tasks we have included in our final submission.
2. Best Single Model

After generating the

(see step 4 how to generate this), run the following command to generate the best single model:
python -m single -f basic_nonlinear_201604210409 -l reg_xgb_tree_best_single_model -e 1

This should generate a submission with local CV RMSE around 0.438 ~ 0.439.

3. Best Ensemble Model

After building some diverse 1st level models, run the following command to generate the best ensemble model:

python -l 2 -d 0 -t 10 -c 1 -L reg_ensemble -o

This should generate a submission with local CV RMSE around 0.436.

Igor&Kostia's Part

Before proceeding, one should specify correct paths in file
and place all the data from the competition website into folder specified by variable
. To reproduce our
from Step IK5 one should place the used feature sets into folder specified by variable
. Note that in the following, all the commands and scripts are executed and run in directory

Step IK1. Install Dependencies

1. Python

We used Python 2.7.11 on Windows platform and modules comes with Anaconda 2.4.0 (64-bit), including: - scikit-learn 0.17.1 - numpy 1.10.1 - pandas 0.17.0 - re 2.2.1 - matplotlib 1.4.3 - scipy 0.16.0

In addition, we also used the following libraries and modules: - NLTK 3.1 (use
command) - gensim 0.12.2 - xgboost 0.4

Some descriptive analysis and final model blending was also done in Excel 2007 and Excel 2010.

Step IK2. Text Preprocessing

We do all text preprocessing before any feature generation and save the results to files. It helped us save a few computing days since the same preprocessing steps are necessary to generate different features. - Run
. - Run

The necessary replacement data is loaded automatically from files

Step IK3. Feature Generation

We need to run consequently the following files: -
. -
. -
. -

To generate features without using the Google dictionary, we also need to run: -
. -

As a result, we will have a few csv files with the necessary features for model building.

Step IK4. Generate Benchmark Model with Feature Importances

  • Run

Step IK5. Generate Submission File

One part of the ensemble

is generated from the following code: -
. -
. -

To get the other part

, we need to run these files: -
(It just reproduces the selection of random features generated from
. You do not need to run
again). -

These two parts can be generated in parallel. Our final submission from Igor&Kostia was then prodused in Excel as:

+ 0.25

Blending Two Ensembles into the Final Submissions

So, we had two ensembles prepared using different methodologies. We observed that our ensembles behave differently in different parts of the datasets (

163700 < id  <= 221473
id > 221473
. Since we observed regular patterns in the data as well, we thought that one of the ensembles might be especially prone to overfitting in some parts. So, while blending our ensembles for final submissions, we made different bets assuming that in some parts one of the models would behave much worse in private than in public.

Our two final submission were produced in Excel with the weights from the table below (the weight for Chenglong's and Igor&Kostia's parts add up to 1). Both these submissions scored the same

on the private leaderboard.

| | Weight Chenglong for

| Weight Chenglong for
| Public LB RMSE | Private LB RMSE | | :-----------------: | :---------: | :---------: | :---------------: | :---------------: | | Submission 1 | 0.75 | 0.8 | 0.43443 | 0.43271 | | Submission 2 | 0.6 | 0.3 | 0.43433 | 0.43271 |

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.