{
  "id": 382921,
  "title": "110th place solution",
  "url": "/competitions/otto-recommender-system/discussion/382921",
  "author_name": "Bykov Dmitrii",
  "post_date": "2023-02-01T14:46:01.850000",
  "votes": 7,
  "comment_count": 0,
  "views": 0,
  "content": "<p>I would thank organizers for this competition. It was first my serious approach to learn rescys. Also I want thank <a href=\"https://www.kaggle.com/cdeotte\" target=\"_blank\">@cdeotte</a> for very helpfull notebooks and comments.</p>\n<p>My solution consisted of a candidate model and a ranking model.</p>\n<p>My first candidate model was based on matrices from this notebook <a href=\"https://www.kaggle.com/code/cdeotte/compute-validation-score-cv-565\" target=\"_blank\">https://www.kaggle.com/code/cdeotte/compute-validation-score-cv-565</a> . But it was different in that I just took candidates from each of the matrices. And also I added there all the aids that were in the session. I took 100 candidates for each of the matrices by aggregating the values. I used 5 aggregations:<br>\n1) the most common<br>\n2) the largest total value in the matrix<br>\n3) the largest sum value divided by the frequency of aid in the session<br>\n4) the largest sum value in the matrix multiplied by 1/(session_len – aid_number)<br>\n5) the largest sum divided by the frequency of aid in the session multiplied by the 1/(session_len - aid_number) <br>\nAfter that, I combined all the aid across all the matrices.</p>\n<p>I used such aggregations because I wanted to get aids that strongly correlate with low-frequency aids in session and also I wanted to boost the latest ones.</p>\n<p>For the ranker I used Catboost model with 3 folds splitted by session_id. It was trained with 20 negatives from candidates model. My features was <br>\n1) aggrefations from the matrixes which described above<br>\n2) current session len<br>\n3) number of click/card/orders devided by session len<br>\n4) 1/(session_len – aid_number)</p>\n<p>The LB score of this solution was 0.581</p>\n<p>On the next iteration, I created two additional matrices. the first of these is the inverted distance matrix. This is a matrix of the sum of inverted distances between pairs of aids. And it improved my LB score to 0.582.</p>\n<p>After that, I decided that my matrices do not take into account which of the aids were before and which after. Thus I add new matrix similar to previous but I took only pairs which aids_x position was smaller than aid_y  position. And its improved my LB score to 0.583.</p>\n<p>At the 4th itter I decided to add Word2Vec similarity model. I took the model from this notebook <a href=\"https://www.kaggle.com/code/balaganiarz0/word2vec-model-training-and-submission-0-533\" target=\"_blank\">https://www.kaggle.com/code/balaganiarz0/word2vec-model-training-and-submission-0-533</a>. In the candidates model I took top 50 most similar elements from 6 latest aids in session + 3 last orders + 3 last cards. And also I add cosine similarity scores to my ranker features. It improved my LB to 0.584. But it was 0.583 of private too.</p>\n<p>At the end of competition I made voting ensemble of two my last models submission file with the <a href=\"https://www.kaggle.com/code/karakasatarik/0-578-ensemble-of-public-notebooks\" target=\"_blank\">https://www.kaggle.com/code/karakasatarik/0-578-ensemble-of-public-notebooks</a>. The LB of ensemble was 0.586 but private score was only 0.585.</p>\n<p>It seems that my candidate model was generating a very large number of candidates, but the candidates from different matrices and aggregations were very similar and the average was ~200 candidates per session.</p>",
  "messages": [
    {
      "id": 2125248,
      "postDate": "2023-02-01T14:46:01.850Z",
      "content": "<p>I would thank organizers for this competition. It was first my serious approach to learn rescys. Also I want thank <a href=\"https://www.kaggle.com/cdeotte\" target=\"_blank\">@cdeotte</a> for very helpfull notebooks and comments.</p>\n<p>My solution consisted of a candidate model and a ranking model.</p>\n<p>My first candidate model was based on matrices from this notebook <a href=\"https://www.kaggle.com/code/cdeotte/compute-validation-score-cv-565\" target=\"_blank\">https://www.kaggle.com/code/cdeotte/compute-validation-score-cv-565</a> . But it was different in that I just took candidates from each of the matrices. And also I added there all the aids that were in the session. I took 100 candidates for each of the matrices by aggregating the values. I used 5 aggregations:<br>\n1) the most common<br>\n2) the largest total value in the matrix<br>\n3) the largest sum value divided by the frequency of aid in the session<br>\n4) the largest sum value in the matrix multiplied by 1/(session_len – aid_number)<br>\n5) the largest sum divided by the frequency of aid in the session multiplied by the 1/(session_len - aid_number) <br>\nAfter that, I combined all the aid across all the matrices.</p>\n<p>I used such aggregations because I wanted to get aids that strongly correlate with low-frequency aids in session and also I wanted to boost the latest ones.</p>\n<p>For the ranker I used Catboost model with 3 folds splitted by session_id. It was trained with 20 negatives from candidates model. My features was <br>\n1) aggrefations from the matrixes which described above<br>\n2) current session len<br>\n3) number of click/card/orders devided by session len<br>\n4) 1/(session_len – aid_number)</p>\n<p>The LB score of this solution was 0.581</p>\n<p>On the next iteration, I created two additional matrices. the first of these is the inverted distance matrix. This is a matrix of the sum of inverted distances between pairs of aids. And it improved my LB score to 0.582.</p>\n<p>After that, I decided that my matrices do not take into account which of the aids were before and which after. Thus I add new matrix similar to previous but I took only pairs which aids_x position was smaller than aid_y  position. And its improved my LB score to 0.583.</p>\n<p>At the 4th itter I decided to add Word2Vec similarity model. I took the model from this notebook <a href=\"https://www.kaggle.com/code/balaganiarz0/word2vec-model-training-and-submission-0-533\" target=\"_blank\">https://www.kaggle.com/code/balaganiarz0/word2vec-model-training-and-submission-0-533</a>. In the candidates model I took top 50 most similar elements from 6 latest aids in session + 3 last orders + 3 last cards. And also I add cosine similarity scores to my ranker features. It improved my LB to 0.584. But it was 0.583 of private too.</p>\n<p>At the end of competition I made voting ensemble of two my last models submission file with the <a href=\"https://www.kaggle.com/code/karakasatarik/0-578-ensemble-of-public-notebooks\" target=\"_blank\">https://www.kaggle.com/code/karakasatarik/0-578-ensemble-of-public-notebooks</a>. The LB of ensemble was 0.586 but private score was only 0.585.</p>\n<p>It seems that my candidate model was generating a very large number of candidates, but the candidates from different matrices and aggregations were very similar and the average was ~200 candidates per session.</p>",
      "rawMarkdown": "I would thank organizers for this competition. It was first my serious approach to learn rescys. Also I want thank @cdeotte for very helpfull notebooks and comments.\n\nMy solution consisted of a candidate model and a ranking model.\n\nMy first candidate model was based on matrices from this notebook https://www.kaggle.com/code/cdeotte/compute-validation-score-cv-565 . But it was different in that I just took candidates from each of the matrices. And also I added there all the aids that were in the session. I took 100 candidates for each of the matrices by aggregating the values. I used 5 aggregations:\n1) the most common\n2) the largest total value in the matrix\n3) the largest sum value divided by the frequency of aid in the session\n4) the largest sum value in the matrix multiplied by 1/(session_len – aid_number)\n5) the largest sum divided by the frequency of aid in the session multiplied by the 1/(session_len - aid_number) \nAfter that, I combined all the aid across all the matrices.\n\nI used such aggregations because I wanted to get aids that strongly correlate with low-frequency aids in session and also I wanted to boost the latest ones.\n\nFor the ranker I used Catboost model with 3 folds splitted by session_id. It was trained with 20 negatives from candidates model. My features was \n1) aggrefations from the matrixes which described above\n2) current session len\n3) number of click/card/orders devided by session len\n4) 1/(session_len – aid_number)\n\nThe LB score of this solution was 0.581\n\nOn the next iteration, I created two additional matrices. the first of these is the inverted distance matrix. This is a matrix of the sum of inverted distances between pairs of aids. And it improved my LB score to 0.582.\n\n After that, I decided that my matrices do not take into account which of the aids were before and which after. Thus I add new matrix similar to previous but I took only pairs which aids_x position was smaller than aid_y  position. And its improved my LB score to 0.583.\n\nAt the 4th itter I decided to add Word2Vec similarity model. I took the model from this notebook https://www.kaggle.com/code/balaganiarz0/word2vec-model-training-and-submission-0-533. In the candidates model I took top 50 most similar elements from 6 latest aids in session + 3 last orders + 3 last cards. And also I add cosine similarity scores to my ranker features. It improved my LB to 0.584. But it was 0.583 of private too.\n\nAt the end of competition I made voting ensemble of two my last models submission file with the https://www.kaggle.com/code/karakasatarik/0-578-ensemble-of-public-notebooks. The LB of ensemble was 0.586 but private score was only 0.585.\n\nIt seems that my candidate model was generating a very large number of candidates, but the candidates from different matrices and aggregations were very similar and the average was ~200 candidates per session.",
      "votes": 7
    }
  ],
  "comments": [],
  "raw_markdown_by_id": {
    "2125248": "I would thank organizers for this competition. It was first my serious approach to learn rescys. Also I want thank @cdeotte for very helpfull notebooks and comments.\n\nMy solution consisted of a candidate model and a ranking model.\n\nMy first candidate model was based on matrices from this notebook https://www.kaggle.com/code/cdeotte/compute-validation-score-cv-565 . But it was different in that I just took candidates from each of the matrices. And also I added there all the aids that were in the session. I took 100 candidates for each of the matrices by aggregating the values. I used 5 aggregations:\n1) the most common\n2) the largest total value in the matrix\n3) the largest sum value divided by the frequency of aid in the session\n4) the largest sum value in the matrix multiplied by 1/(session_len – aid_number)\n5) the largest sum divided by the frequency of aid in the session multiplied by the 1/(session_len - aid_number) \nAfter that, I combined all the aid across all the matrices.\n\nI used such aggregations because I wanted to get aids that strongly correlate with low-frequency aids in session and also I wanted to boost the latest ones.\n\nFor the ranker I used Catboost model with 3 folds splitted by session_id. It was trained with 20 negatives from candidates model. My features was \n1) aggrefations from the matrixes which described above\n2) current session len\n3) number of click/card/orders devided by session len\n4) 1/(session_len – aid_number)\n\nThe LB score of this solution was 0.581\n\nOn the next iteration, I created two additional matrices. the first of these is the inverted distance matrix. This is a matrix of the sum of inverted distances between pairs of aids. And it improved my LB score to 0.582.\n\n After that, I decided that my matrices do not take into account which of the aids were before and which after. Thus I add new matrix similar to previous but I took only pairs which aids_x position was smaller than aid_y  position. And its improved my LB score to 0.583.\n\nAt the 4th itter I decided to add Word2Vec similarity model. I took the model from this notebook https://www.kaggle.com/code/balaganiarz0/word2vec-model-training-and-submission-0-533. In the candidates model I took top 50 most similar elements from 6 latest aids in session + 3 last orders + 3 last cards. And also I add cosine similarity scores to my ranker features. It improved my LB to 0.584. But it was 0.583 of private too.\n\nAt the end of competition I made voting ensemble of two my last models submission file with the https://www.kaggle.com/code/karakasatarik/0-578-ensemble-of-public-notebooks. The LB of ensemble was 0.586 but private score was only 0.585.\n\nIt seems that my candidate model was generating a very large number of candidates, but the candidates from different matrices and aggregations were very similar and the average was ~200 candidates per session."
  }
}