From 60194de8538cff959337e9e396bc01145c465b4e Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 10 Jun 2021 22:10:42 +0200 Subject: [PATCH] Zadanie 5 --- P3. k-nearest neighbours.ipynb | 763 +++++++++++++++++++++++++++++---- 1 file changed, 682 insertions(+), 81 deletions(-) diff --git a/P3. k-nearest neighbours.ipynb b/P3. k-nearest neighbours.ipynb index a15592c..55a3ee7 100644 --- a/P3. k-nearest neighbours.ipynb +++ b/P3. k-nearest neighbours.ipynb @@ -113,7 +113,7 @@ "text/plain": [ "array([[3, 4, 0, 0, 5, 0, 0, 4],\n", " [0, 1, 2, 3, 0, 0, 0, 0],\n", - " [0, 0, 0, 5, 0, 3, 4, 0]])" + " [0, 0, 0, 5, 0, 3, 4, 0]], dtype=int64)" ] }, "metadata": {}, @@ -256,7 +256,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "943it [00:00, 9004.71it/s]\n" + "943it [00:00, 9914.99it/s]\n" ] }, { @@ -293,6 +293,8 @@ " MRR\n", " LAUC\n", " HR\n", + " HitRate2\n", + " HitRate3\n", " Reco in test\n", " Test coverage\n", " Shannon\n", @@ -315,6 +317,8 @@ " 0.000368\n", " 0.496391\n", " 0.003181\n", + " 0.0\n", + " 0.0\n", " 0.392153\n", " 0.11544\n", " 4.174741\n", @@ -331,8 +335,11 @@ " precision_super recall_super NDCG mAP MRR LAUC \\\n", "0 0.0 0.0 0.000214 0.000037 0.000368 0.496391 \n", "\n", - " HR Reco in test Test coverage Shannon Gini \n", - "0 0.003181 0.392153 0.11544 4.174741 0.965327 " + " HR HitRate2 HitRate3 Reco in test Test coverage Shannon \\\n", + "0 0.003181 0.0 0.0 0.392153 0.11544 4.174741 \n", + "\n", + " Gini \n", + "0 0.965327 " ] }, "execution_count": 5, @@ -365,12 +372,15 @@ "name": "stderr", "output_type": "stream", "text": [ - "943it [00:00, 8517.83it/s]\n", - "943it [00:00, 11438.64it/s]\n", - "943it [00:00, 11933.36it/s]\n", - "943it [00:00, 10307.81it/s]\n", - "943it [00:00, 12250.41it/s]\n", - "943it [00:00, 12064.07it/s]\n" + "943it [00:00, 9928.75it/s]\n", + "943it [00:00, 10480.56it/s]\n", + "943it [00:00, 8591.71it/s]\n", + "943it [00:00, 9949.81it/s]\n", + "943it [00:00, 9925.57it/s]\n", + "943it [00:00, 9911.02it/s]\n", + "943it [00:00, 9196.77it/s]\n", + "943it [00:00, 9443.97it/s]\n", + "943it [00:00, 8577.83it/s]\n" ] }, { @@ -408,6 +418,8 @@ " MRR\n", " LAUC\n", " HR\n", + " HitRate2\n", + " HitRate3\n", " Reco in test\n", " Test coverage\n", " Shannon\n", @@ -431,6 +443,8 @@ " 0.400939\n", " 0.555546\n", " 0.765642\n", + " 0.492047\n", + " 0.290562\n", " 1.000000\n", " 0.038961\n", " 3.159079\n", @@ -452,6 +466,8 @@ " 0.198193\n", " 0.515501\n", " 0.437964\n", + " 0.239661\n", + " 0.126193\n", " 1.000000\n", " 0.033911\n", " 2.836513\n", @@ -460,23 +476,94 @@ " \n", " 0\n", " Ready_Random\n", - " 1.521845\n", - " 1.225949\n", - " 0.047190\n", - " 0.020753\n", - " 0.024810\n", - " 0.032269\n", - " 0.029506\n", - " 0.023707\n", - " 0.050075\n", - " 0.018728\n", - " 0.121957\n", - " 0.506893\n", - " 0.329799\n", - " 0.986532\n", - " 0.184704\n", - " 5.099706\n", - " 0.907217\n", + " 1.516512\n", + " 1.217214\n", + " 0.045599\n", + " 0.021001\n", + " 0.024136\n", + " 0.031226\n", + " 0.028541\n", + " 0.022057\n", + " 0.050154\n", + " 0.019000\n", + " 0.125089\n", + " 0.507013\n", + " 0.327678\n", + " 0.093319\n", + " 0.026511\n", + " 0.988017\n", + " 0.192641\n", + " 5.141246\n", + " 0.903763\n", + " \n", + " \n", + " 0\n", + " Ready_I-KNN\n", + " 1.030386\n", + " 0.813067\n", + " 0.026087\n", + " 0.006908\n", + " 0.010593\n", + " 0.016046\n", + " 0.021137\n", + " 0.009522\n", + " 0.024214\n", + " 0.008958\n", + " 0.048068\n", + " 0.499885\n", + " 0.154825\n", + " 0.072110\n", + " 0.024390\n", + " 0.402333\n", + " 0.434343\n", + " 5.133650\n", + " 0.877999\n", + " \n", + " \n", + " 0\n", + " Ready_I-KNNBaseline\n", + " 0.935327\n", + " 0.737424\n", + " 0.002545\n", + " 0.000755\n", + " 0.001105\n", + " 0.001602\n", + " 0.002253\n", + " 0.000930\n", + " 0.003444\n", + " 0.001362\n", + " 0.011760\n", + " 0.496724\n", + " 0.021209\n", + " 0.004242\n", + " 0.000000\n", + " 0.482821\n", + " 0.059885\n", + " 2.232578\n", + " 0.994487\n", + " \n", + " \n", + " 0\n", + " Ready_U-KNN\n", + " 1.023495\n", + " 0.807913\n", + " 0.000742\n", + " 0.000205\n", + " 0.000305\n", + " 0.000449\n", + " 0.000536\n", + " 0.000198\n", + " 0.000845\n", + " 0.000274\n", + " 0.002744\n", + " 0.496441\n", + " 0.007423\n", + " 0.000000\n", + " 0.000000\n", + " 0.602121\n", + " 0.010823\n", + " 2.089186\n", + " 0.995706\n", " \n", " \n", " 0\n", @@ -494,6 +581,8 @@ " 0.003348\n", " 0.496433\n", " 0.009544\n", + " 0.000000\n", + " 0.000000\n", " 0.699046\n", " 0.005051\n", " 1.945910\n", @@ -515,6 +604,8 @@ " 0.001677\n", " 0.496424\n", " 0.009544\n", + " 0.000000\n", + " 0.000000\n", " 0.600530\n", " 0.005051\n", " 1.803126\n", @@ -536,6 +627,8 @@ " 0.000368\n", " 0.496391\n", " 0.003181\n", + " 0.000000\n", + " 0.000000\n", " 0.392153\n", " 0.115440\n", " 4.174741\n", @@ -546,29 +639,49 @@ "" ], "text/plain": [ - " Model RMSE MAE precision recall F_1 \\\n", - "0 Self_TopPop 2.508258 2.217909 0.188865 0.116919 0.118732 \n", - "0 Ready_Baseline 0.949459 0.752487 0.091410 0.037652 0.046030 \n", - "0 Ready_Random 1.521845 1.225949 0.047190 0.020753 0.024810 \n", - "0 Self_TopRated 1.030712 0.820904 0.000954 0.000188 0.000298 \n", - "0 Self_BaselineUI 0.967585 0.762740 0.000954 0.000170 0.000278 \n", - "0 Self_IKNN 1.018363 0.808793 0.000318 0.000108 0.000140 \n", + " Model RMSE MAE precision recall F_1 \\\n", + "0 Self_TopPop 2.508258 2.217909 0.188865 0.116919 0.118732 \n", + "0 Ready_Baseline 0.949459 0.752487 0.091410 0.037652 0.046030 \n", + "0 Ready_Random 1.516512 1.217214 0.045599 0.021001 0.024136 \n", + "0 Ready_I-KNN 1.030386 0.813067 0.026087 0.006908 0.010593 \n", + "0 Ready_I-KNNBaseline 0.935327 0.737424 0.002545 0.000755 0.001105 \n", + "0 Ready_U-KNN 1.023495 0.807913 0.000742 0.000205 0.000305 \n", + "0 Self_TopRated 1.030712 0.820904 0.000954 0.000188 0.000298 \n", + "0 Self_BaselineUI 0.967585 0.762740 0.000954 0.000170 0.000278 \n", + "0 Self_IKNN 1.018363 0.808793 0.000318 0.000108 0.000140 \n", "\n", " F_05 precision_super recall_super NDCG mAP MRR \\\n", "0 0.141584 0.130472 0.137473 0.214651 0.111707 0.400939 \n", "0 0.061286 0.079614 0.056463 0.095957 0.043178 0.198193 \n", - "0 0.032269 0.029506 0.023707 0.050075 0.018728 0.121957 \n", + "0 0.031226 0.028541 0.022057 0.050154 0.019000 0.125089 \n", + "0 0.016046 0.021137 0.009522 0.024214 0.008958 0.048068 \n", + "0 0.001602 0.002253 0.000930 0.003444 0.001362 0.011760 \n", + "0 0.000449 0.000536 0.000198 0.000845 0.000274 0.002744 \n", "0 0.000481 0.000644 0.000223 0.001043 0.000335 0.003348 \n", "0 0.000463 0.000644 0.000189 0.000752 0.000168 0.001677 \n", "0 0.000189 0.000000 0.000000 0.000214 0.000037 0.000368 \n", "\n", - " LAUC HR Reco in test Test coverage Shannon Gini \n", - "0 0.555546 0.765642 1.000000 0.038961 3.159079 0.987317 \n", - "0 0.515501 0.437964 1.000000 0.033911 2.836513 0.991139 \n", - "0 0.506893 0.329799 0.986532 0.184704 5.099706 0.907217 \n", - "0 0.496433 0.009544 0.699046 0.005051 1.945910 0.995669 \n", - "0 0.496424 0.009544 0.600530 0.005051 1.803126 0.996380 \n", - "0 0.496391 0.003181 0.392153 0.115440 4.174741 0.965327 " + " LAUC HR HitRate2 HitRate3 Reco in test Test coverage \\\n", + "0 0.555546 0.765642 0.492047 0.290562 1.000000 0.038961 \n", + "0 0.515501 0.437964 0.239661 0.126193 1.000000 0.033911 \n", + "0 0.507013 0.327678 0.093319 0.026511 0.988017 0.192641 \n", + "0 0.499885 0.154825 0.072110 0.024390 0.402333 0.434343 \n", + "0 0.496724 0.021209 0.004242 0.000000 0.482821 0.059885 \n", + "0 0.496441 0.007423 0.000000 0.000000 0.602121 0.010823 \n", + "0 0.496433 0.009544 0.000000 0.000000 0.699046 0.005051 \n", + "0 0.496424 0.009544 0.000000 0.000000 0.600530 0.005051 \n", + "0 0.496391 0.003181 0.000000 0.000000 0.392153 0.115440 \n", + "\n", + " Shannon Gini \n", + "0 3.159079 0.987317 \n", + "0 2.836513 0.991139 \n", + "0 5.141246 0.903763 \n", + "0 5.133650 0.877999 \n", + "0 2.232578 0.994487 \n", + "0 2.089186 0.995706 \n", + "0 1.945910 0.995669 \n", + "0 1.803126 0.996380 \n", + "0 4.174741 0.965327 " ] }, "execution_count": 6, @@ -718,15 +831,15 @@ "name": "stderr", "output_type": "stream", "text": [ - "943it [00:00, 11286.27it/s]\n", - "943it [00:00, 10874.86it/s]\n", - "943it [00:00, 11509.97it/s]\n", - "943it [00:00, 11855.81it/s]\n", - "943it [00:00, 11574.00it/s]\n", - "943it [00:00, 11080.19it/s]\n", - "943it [00:00, 11550.84it/s]\n", - "943it [00:00, 12148.14it/s]\n", - "943it [00:00, 10779.39it/s]\n" + "943it [00:00, 8051.57it/s]\n", + "943it [00:00, 9790.90it/s]\n", + "943it [00:00, 9404.38it/s]\n", + "943it [00:00, 9429.83it/s]\n", + "943it [00:00, 9915.86it/s]\n", + "943it [00:00, 8625.66it/s]\n", + "943it [00:00, 9687.63it/s]\n", + "943it [00:00, 10469.91it/s]\n", + "943it [00:00, 8577.63it/s]\n" ] }, { @@ -764,6 +877,8 @@ " MRR\n", " LAUC\n", " HR\n", + " HitRate2\n", + " HitRate3\n", " Reco in test\n", " Test coverage\n", " Shannon\n", @@ -787,6 +902,8 @@ " 0.400939\n", " 0.555546\n", " 0.765642\n", + " 0.492047\n", + " 0.290562\n", " 1.000000\n", " 0.038961\n", " 3.159079\n", @@ -808,6 +925,8 @@ " 0.198193\n", " 0.515501\n", " 0.437964\n", + " 0.239661\n", + " 0.126193\n", " 1.000000\n", " 0.033911\n", " 2.836513\n", @@ -816,23 +935,25 @@ " \n", " 0\n", " Ready_Random\n", - " 1.521845\n", - " 1.225949\n", - " 0.047190\n", - " 0.020753\n", - " 0.024810\n", - " 0.032269\n", - " 0.029506\n", - " 0.023707\n", - " 0.050075\n", - " 0.018728\n", - " 0.121957\n", - " 0.506893\n", - " 0.329799\n", - " 0.986532\n", - " 0.184704\n", - " 5.099706\n", - " 0.907217\n", + " 1.516512\n", + " 1.217214\n", + " 0.045599\n", + " 0.021001\n", + " 0.024136\n", + " 0.031226\n", + " 0.028541\n", + " 0.022057\n", + " 0.050154\n", + " 0.019000\n", + " 0.125089\n", + " 0.507013\n", + " 0.327678\n", + " 0.093319\n", + " 0.026511\n", + " 0.988017\n", + " 0.192641\n", + " 5.141246\n", + " 0.903763\n", " \n", " \n", " 0\n", @@ -850,6 +971,8 @@ " 0.048068\n", " 0.499885\n", " 0.154825\n", + " 0.072110\n", + " 0.024390\n", " 0.402333\n", " 0.434343\n", " 5.133650\n", @@ -871,6 +994,8 @@ " 0.011760\n", " 0.496724\n", " 0.021209\n", + " 0.004242\n", + " 0.000000\n", " 0.482821\n", " 0.059885\n", " 2.232578\n", @@ -892,6 +1017,8 @@ " 0.002744\n", " 0.496441\n", " 0.007423\n", + " 0.000000\n", + " 0.000000\n", " 0.602121\n", " 0.010823\n", " 2.089186\n", @@ -913,6 +1040,8 @@ " 0.003348\n", " 0.496433\n", " 0.009544\n", + " 0.000000\n", + " 0.000000\n", " 0.699046\n", " 0.005051\n", " 1.945910\n", @@ -934,6 +1063,8 @@ " 0.001677\n", " 0.496424\n", " 0.009544\n", + " 0.000000\n", + " 0.000000\n", " 0.600530\n", " 0.005051\n", " 1.803126\n", @@ -955,6 +1086,8 @@ " 0.000368\n", " 0.496391\n", " 0.003181\n", + " 0.000000\n", + " 0.000000\n", " 0.392153\n", " 0.115440\n", " 4.174741\n", @@ -968,7 +1101,7 @@ " Model RMSE MAE precision recall F_1 \\\n", "0 Self_TopPop 2.508258 2.217909 0.188865 0.116919 0.118732 \n", "0 Ready_Baseline 0.949459 0.752487 0.091410 0.037652 0.046030 \n", - "0 Ready_Random 1.521845 1.225949 0.047190 0.020753 0.024810 \n", + "0 Ready_Random 1.516512 1.217214 0.045599 0.021001 0.024136 \n", "0 Ready_I-KNN 1.030386 0.813067 0.026087 0.006908 0.010593 \n", "0 Ready_I-KNNBaseline 0.935327 0.737424 0.002545 0.000755 0.001105 \n", "0 Ready_U-KNN 1.023495 0.807913 0.000742 0.000205 0.000305 \n", @@ -979,7 +1112,7 @@ " F_05 precision_super recall_super NDCG mAP MRR \\\n", "0 0.141584 0.130472 0.137473 0.214651 0.111707 0.400939 \n", "0 0.061286 0.079614 0.056463 0.095957 0.043178 0.198193 \n", - "0 0.032269 0.029506 0.023707 0.050075 0.018728 0.121957 \n", + "0 0.031226 0.028541 0.022057 0.050154 0.019000 0.125089 \n", "0 0.016046 0.021137 0.009522 0.024214 0.008958 0.048068 \n", "0 0.001602 0.002253 0.000930 0.003444 0.001362 0.011760 \n", "0 0.000449 0.000536 0.000198 0.000845 0.000274 0.002744 \n", @@ -987,16 +1120,27 @@ "0 0.000463 0.000644 0.000189 0.000752 0.000168 0.001677 \n", "0 0.000189 0.000000 0.000000 0.000214 0.000037 0.000368 \n", "\n", - " LAUC HR Reco in test Test coverage Shannon Gini \n", - "0 0.555546 0.765642 1.000000 0.038961 3.159079 0.987317 \n", - "0 0.515501 0.437964 1.000000 0.033911 2.836513 0.991139 \n", - "0 0.506893 0.329799 0.986532 0.184704 5.099706 0.907217 \n", - "0 0.499885 0.154825 0.402333 0.434343 5.133650 0.877999 \n", - "0 0.496724 0.021209 0.482821 0.059885 2.232578 0.994487 \n", - "0 0.496441 0.007423 0.602121 0.010823 2.089186 0.995706 \n", - "0 0.496433 0.009544 0.699046 0.005051 1.945910 0.995669 \n", - "0 0.496424 0.009544 0.600530 0.005051 1.803126 0.996380 \n", - "0 0.496391 0.003181 0.392153 0.115440 4.174741 0.965327 " + " LAUC HR HitRate2 HitRate3 Reco in test Test coverage \\\n", + "0 0.555546 0.765642 0.492047 0.290562 1.000000 0.038961 \n", + "0 0.515501 0.437964 0.239661 0.126193 1.000000 0.033911 \n", + "0 0.507013 0.327678 0.093319 0.026511 0.988017 0.192641 \n", + "0 0.499885 0.154825 0.072110 0.024390 0.402333 0.434343 \n", + "0 0.496724 0.021209 0.004242 0.000000 0.482821 0.059885 \n", + "0 0.496441 0.007423 0.000000 0.000000 0.602121 0.010823 \n", + "0 0.496433 0.009544 0.000000 0.000000 0.699046 0.005051 \n", + "0 0.496424 0.009544 0.000000 0.000000 0.600530 0.005051 \n", + "0 0.496391 0.003181 0.000000 0.000000 0.392153 0.115440 \n", + "\n", + " Shannon Gini \n", + "0 3.159079 0.987317 \n", + "0 2.836513 0.991139 \n", + "0 5.141246 0.903763 \n", + "0 5.133650 0.877999 \n", + "0 2.232578 0.994487 \n", + "0 2.089186 0.995706 \n", + "0 1.945910 0.995669 \n", + "0 1.803126 0.996380 \n", + "0 4.174741 0.965327 " ] }, "execution_count": 10, @@ -1021,7 +1165,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -1031,6 +1175,463 @@ "# please save the output in 'Recommendations generated/ml-100k/Self_KNNSurprisetask_reco.csv' and\n", "# 'Recommendations generated/ml-100k/Self_KNNSurprisetask_estimations.csv'" ] + }, + { + "cell_type": "code", + "execution_count": 43, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Estimating biases using als...\n", + "Computing the msd similarity matrix...\n", + "Done computing similarity matrix.\n", + "Generating predictions...\n", + "Generating top N recommendations...\n", + "Generating predictions...\n" + ] + } + ], + "source": [ + "sim_options = {\n", + " \"name\": \"cosine\",\n", + " \"user_based\": True,\n", + "} # compute similarities between items\n", + "algorytm = sp.KNNBaseline(min_k=55, k=155)\n", + "\n", + "helpers.ready_made(\n", + " algorytm,\n", + " reco_path=\"Recommendations generated/ml-100k/Self_KNNSurprisetask_reco.csv\",\n", + " estimations_path=\"Recommendations generated/ml-100k/Self_KNNSurprisetask_estimations.csv\",\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 44, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "943it [00:00, 12777.10it/s]\n", + "943it [00:00, 13902.58it/s]\n", + "943it [00:00, 13703.41it/s]\n", + "943it [00:00, 12363.57it/s]\n", + "943it [00:00, 14321.56it/s]\n", + "943it [00:00, 13132.35it/s]\n", + "943it [00:00, 14318.76it/s]\n", + "943it [00:00, 11530.04it/s]\n", + "943it [00:00, 11255.60it/s]\n", + "943it [00:00, 12605.02it/s]\n", + "943it [00:00, 12946.27it/s]\n", + "943it [00:00, 12127.73it/s]\n" + ] + }, + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
ModelRMSEMAEprecisionrecallF_1F_05precision_superrecall_superNDCGmAPMRRLAUCHRHitRate2HitRate3Reco in testTest coverageShannonGini
0Self_RP3Beta3.5011583.3213680.3159070.2130880.2084920.2427560.2334760.2700020.3829460.2459880.6262410.6041800.8960760.7274660.5387061.0000000.1226554.3429300.959561
0Self_P33.7024463.5272730.2821850.1920920.1867490.2169800.2041850.2400960.3391140.2049050.5721570.5935440.8759280.6850480.4952281.0000000.0772013.8758920.974947
0Self_TopPop2.5082582.2179090.1888650.1169190.1187320.1415840.1304720.1374730.2146510.1117070.4009390.5555460.7656420.4920470.2905621.0000000.0389613.1590790.987317
0Self_KNNSurprisetask0.9425310.7448510.0905620.0380310.0459510.0608630.0802580.0586810.0901740.0385520.1787150.5156790.4485680.2322380.1230121.0000000.0425693.0155080.989612
0Ready_Baseline0.9494590.7524870.0914100.0376520.0460300.0612860.0796140.0564630.0959570.0431780.1981930.5155010.4379640.2396610.1261931.0000000.0339112.8365130.991139
0Ready_Random1.5165121.2172140.0455990.0210010.0241360.0312260.0285410.0220570.0501540.0190000.1250890.5070130.3276780.0933190.0265110.9880170.1926415.1412460.903763
0Ready_I-KNN1.0303860.8130670.0260870.0069080.0105930.0160460.0211370.0095220.0242140.0089580.0480680.4998850.1548250.0721100.0243900.4023330.4343435.1336500.877999
0Ready_I-KNNBaseline0.9353270.7374240.0025450.0007550.0011050.0016020.0022530.0009300.0034440.0013620.0117600.4967240.0212090.0042420.0000000.4828210.0598852.2325780.994487
0Ready_U-KNN1.0234950.8079130.0007420.0002050.0003050.0004490.0005360.0001980.0008450.0002740.0027440.4964410.0074230.0000000.0000000.6021210.0108232.0891860.995706
0Self_TopRated1.0307120.8209040.0009540.0001880.0002980.0004810.0006440.0002230.0010430.0003350.0033480.4964330.0095440.0000000.0000000.6990460.0050511.9459100.995669
0Self_BaselineUI0.9675850.7627400.0009540.0001700.0002780.0004630.0006440.0001890.0007520.0001680.0016770.4964240.0095440.0000000.0000000.6005300.0050511.8031260.996380
0Self_IKNN1.0183630.8087930.0003180.0001080.0001400.0001890.0000000.0000000.0002140.0000370.0003680.4963910.0031810.0000000.0000000.3921530.1154404.1747410.965327
\n", + "
" + ], + "text/plain": [ + " Model RMSE MAE precision recall F_1 \\\n", + "0 Self_RP3Beta 3.501158 3.321368 0.315907 0.213088 0.208492 \n", + "0 Self_P3 3.702446 3.527273 0.282185 0.192092 0.186749 \n", + "0 Self_TopPop 2.508258 2.217909 0.188865 0.116919 0.118732 \n", + "0 Self_KNNSurprisetask 0.942531 0.744851 0.090562 0.038031 0.045951 \n", + "0 Ready_Baseline 0.949459 0.752487 0.091410 0.037652 0.046030 \n", + "0 Ready_Random 1.516512 1.217214 0.045599 0.021001 0.024136 \n", + "0 Ready_I-KNN 1.030386 0.813067 0.026087 0.006908 0.010593 \n", + "0 Ready_I-KNNBaseline 0.935327 0.737424 0.002545 0.000755 0.001105 \n", + "0 Ready_U-KNN 1.023495 0.807913 0.000742 0.000205 0.000305 \n", + "0 Self_TopRated 1.030712 0.820904 0.000954 0.000188 0.000298 \n", + "0 Self_BaselineUI 0.967585 0.762740 0.000954 0.000170 0.000278 \n", + "0 Self_IKNN 1.018363 0.808793 0.000318 0.000108 0.000140 \n", + "\n", + " F_05 precision_super recall_super NDCG mAP MRR \\\n", + "0 0.242756 0.233476 0.270002 0.382946 0.245988 0.626241 \n", + "0 0.216980 0.204185 0.240096 0.339114 0.204905 0.572157 \n", + "0 0.141584 0.130472 0.137473 0.214651 0.111707 0.400939 \n", + "0 0.060863 0.080258 0.058681 0.090174 0.038552 0.178715 \n", + "0 0.061286 0.079614 0.056463 0.095957 0.043178 0.198193 \n", + "0 0.031226 0.028541 0.022057 0.050154 0.019000 0.125089 \n", + "0 0.016046 0.021137 0.009522 0.024214 0.008958 0.048068 \n", + "0 0.001602 0.002253 0.000930 0.003444 0.001362 0.011760 \n", + "0 0.000449 0.000536 0.000198 0.000845 0.000274 0.002744 \n", + "0 0.000481 0.000644 0.000223 0.001043 0.000335 0.003348 \n", + "0 0.000463 0.000644 0.000189 0.000752 0.000168 0.001677 \n", + "0 0.000189 0.000000 0.000000 0.000214 0.000037 0.000368 \n", + "\n", + " LAUC HR HitRate2 HitRate3 Reco in test Test coverage \\\n", + "0 0.604180 0.896076 0.727466 0.538706 1.000000 0.122655 \n", + "0 0.593544 0.875928 0.685048 0.495228 1.000000 0.077201 \n", + "0 0.555546 0.765642 0.492047 0.290562 1.000000 0.038961 \n", + "0 0.515679 0.448568 0.232238 0.123012 1.000000 0.042569 \n", + "0 0.515501 0.437964 0.239661 0.126193 1.000000 0.033911 \n", + "0 0.507013 0.327678 0.093319 0.026511 0.988017 0.192641 \n", + "0 0.499885 0.154825 0.072110 0.024390 0.402333 0.434343 \n", + "0 0.496724 0.021209 0.004242 0.000000 0.482821 0.059885 \n", + "0 0.496441 0.007423 0.000000 0.000000 0.602121 0.010823 \n", + "0 0.496433 0.009544 0.000000 0.000000 0.699046 0.005051 \n", + "0 0.496424 0.009544 0.000000 0.000000 0.600530 0.005051 \n", + "0 0.496391 0.003181 0.000000 0.000000 0.392153 0.115440 \n", + "\n", + " Shannon Gini \n", + "0 4.342930 0.959561 \n", + "0 3.875892 0.974947 \n", + "0 3.159079 0.987317 \n", + "0 3.015508 0.989612 \n", + "0 2.836513 0.991139 \n", + "0 5.141246 0.903763 \n", + "0 5.133650 0.877999 \n", + "0 2.232578 0.994487 \n", + "0 2.089186 0.995706 \n", + "0 1.945910 0.995669 \n", + "0 1.803126 0.996380 \n", + "0 4.174741 0.965327 " + ] + }, + "execution_count": 44, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dir_path = \"Recommendations generated/ml-100k/\"\n", + "super_reactions = [4, 5]\n", + "test = pd.read_csv(\"./Datasets/ml-100k/test.csv\", sep=\"\\t\", header=None)\n", + "\n", + "ev.evaluate_all(test, dir_path, super_reactions)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": {