Slides added

This commit is contained in:
Robert Kwieciński 2020-05-21 16:20:12 +02:00
parent 67d6328405
commit 8ad2469287
12 changed files with 1390 additions and 2061 deletions

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
@ -26,7 +26,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
@ -43,7 +43,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 3,
"metadata": {},
"outputs": [
{
@ -134,7 +134,7 @@
"4 560 24 2 879976772 559 23"
]
},
"execution_count": 4,
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
@ -145,7 +145,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
@ -155,7 +155,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
@ -169,7 +169,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
@ -189,17 +189,17 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<3x4 sparse matrix of type '<class 'numpy.longlong'>'\n",
"<3x4 sparse matrix of type '<class 'numpy.int64'>'\n",
"\twith 8 stored elements in Compressed Sparse Row format>"
]
},
"execution_count": 9,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
@ -214,7 +214,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 8,
"metadata": {},
"outputs": [
{
@ -257,7 +257,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 9,
"metadata": {},
"outputs": [
{
@ -283,7 +283,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 10,
"metadata": {},
"outputs": [
{
@ -307,7 +307,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"563 ns ± 16.7 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)\n",
"472 ns ± 7.02 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)\n",
"Inefficient way to access items rated by user:\n"
]
},
@ -325,7 +325,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"70.8 µs ± 2.93 µs per loop (mean ± std. dev. of 7 runs, 10000 loops each)\n"
"57.3 µs ± 6.26 µs per loop (mean ± std. dev. of 7 runs, 10000 loops each)\n"
]
}
],
@ -350,7 +350,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 11,
"metadata": {},
"outputs": [
{
@ -384,7 +384,7 @@
"matrix([[ 8, 3, 11]])"
]
},
"execution_count": 17,
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
@ -398,7 +398,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 12,
"metadata": {},
"outputs": [
{
@ -468,7 +468,7 @@
" [-1.66666667, 0. , 1.33333333, 0.33333333]])"
]
},
"execution_count": 19,
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
@ -498,7 +498,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 13,
"metadata": {},
"outputs": [
{
@ -556,7 +556,20 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"if not os.path.exists('./Recommendations generated/'):\n",
" os.mkdir('./Recommendations generated/')\n",
" os.mkdir('./Recommendations generated/ml-100k/')\n",
" os.mkdir('./Recommendations generated/toy-example/')"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [],
"source": [
@ -605,7 +618,7 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": 23,
"metadata": {},
"outputs": [],
"source": [
@ -642,7 +655,7 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 24,
"metadata": {},
"outputs": [
{
@ -744,18 +757,18 @@
"</div>"
],
"text/plain": [
" 0 1 2 3 4 5 6 7 8 9 ... 11 \\\n",
"0 1 5 3.529975 10 3.529975 25 3.529975 32 3.529975 33 ... 44 \n",
"1 2 1 3.529975 2 3.529975 3 3.529975 4 3.529975 5 ... 6 \n",
" 0 1 2 3 4 5 6 7 8 9 ... \\\n",
"0 1 5 3.529975 10 3.529975 25 3.529975 32 3.529975 33 ... \n",
"1 2 1 3.529975 2 3.529975 3 3.529975 4 3.529975 5 ... \n",
"\n",
" 12 13 14 15 16 17 18 19 20 \n",
"0 3.529975 46 3.529975 50 3.529975 52 3.529975 55 3.529975 \n",
"1 3.529975 7 3.529975 8 3.529975 9 3.529975 11 3.529975 \n",
" 11 12 13 14 15 16 17 18 19 20 \n",
"0 44 3.529975 46 3.529975 50 3.529975 52 3.529975 55 3.529975 \n",
"1 6 3.529975 7 3.529975 8 3.529975 9 3.529975 11 3.529975 \n",
"\n",
"[2 rows x 21 columns]"
]
},
"execution_count": 31,
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
@ -773,7 +786,7 @@
},
{
"cell_type": "code",
"execution_count": 32,
"execution_count": 25,
"metadata": {},
"outputs": [],
"source": [
@ -792,7 +805,7 @@
},
{
"cell_type": "code",
"execution_count": 33,
"execution_count": 26,
"metadata": {},
"outputs": [],
"source": [
@ -865,7 +878,7 @@
},
{
"cell_type": "code",
"execution_count": 41,
"execution_count": 27,
"metadata": {},
"outputs": [
{
@ -1033,7 +1046,7 @@
},
{
"cell_type": "code",
"execution_count": 36,
"execution_count": 28,
"metadata": {},
"outputs": [],
"source": [
@ -1057,7 +1070,7 @@
},
{
"cell_type": "code",
"execution_count": 37,
"execution_count": 29,
"metadata": {},
"outputs": [],
"source": [
@ -1076,7 +1089,7 @@
},
{
"cell_type": "code",
"execution_count": 46,
"execution_count": 30,
"metadata": {},
"outputs": [
{
@ -1133,7 +1146,7 @@
},
{
"cell_type": "code",
"execution_count": 47,
"execution_count": 31,
"metadata": {},
"outputs": [
{
@ -1147,10 +1160,10 @@
{
"data": {
"text/plain": [
"0.7524871012820799"
"0.75248710128207985"
]
},
"execution_count": 47,
"execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
@ -1180,24 +1193,24 @@
},
{
"cell_type": "code",
"execution_count": 48,
"execution_count": 32,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"RMSE: 1.5186\n",
"MAE: 1.2188\n"
"RMSE: 1.5190\n",
"MAE: 1.2222\n"
]
},
{
"data": {
"text/plain": [
"1.2187837474576546"
"1.222159317007133"
]
},
"execution_count": 48,
"execution_count": 32,
"metadata": {},
"output_type": "execute_result"
}

Binary file not shown.

File diff suppressed because it is too large Load Diff

BIN
P2. Evaluation.pdf Normal file

Binary file not shown.

View File

@ -9,7 +9,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
@ -28,7 +28,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
@ -73,7 +73,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 3,
"metadata": {},
"outputs": [
{
@ -154,7 +154,7 @@
" [20, 10, 5.0, 20, 5.0]]"
]
},
"execution_count": 5,
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
@ -185,7 +185,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
@ -202,14 +202,14 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"943it [00:00, 8845.73it/s]\n"
"943it [00:00, 10667.92it/s]\n"
]
},
{
@ -288,7 +288,7 @@
"0 0.003181 0.392153 0.11544 4.174741 0.965327 "
]
},
"execution_count": 7,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
@ -306,29 +306,19 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"943it [00:00, 7423.18it/s]\n",
"943it [00:00, 7890.87it/s]\n",
"943it [00:00, 7370.82it/s]\n",
"943it [00:00, 8035.93it/s]\n",
"943it [00:00, 8071.70it/s]\n",
"943it [00:00, 7893.80it/s]\n",
"943it [00:00, 8159.55it/s]\n",
"943it [00:00, 7982.77it/s]\n",
"943it [00:00, 7514.53it/s]\n",
"943it [00:00, 8047.34it/s]\n",
"943it [00:00, 7874.80it/s]\n",
"943it [00:00, 7657.62it/s]\n",
"943it [00:00, 8281.73it/s]\n",
"943it [00:00, 8253.33it/s]\n",
"943it [00:00, 8332.31it/s]\n",
"943it [00:00, 8348.73it/s]\n"
"943it [00:00, 8975.00it/s]\n",
"943it [00:00, 10288.02it/s]\n",
"943it [00:00, 9740.46it/s]\n",
"943it [00:00, 10104.74it/s]\n",
"943it [00:00, 10418.45it/s]\n",
"943it [00:00, 10339.85it/s]\n"
]
},
{
@ -375,27 +365,6 @@
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Self_RP3Beta</td>\n",
" <td>3.702446</td>\n",
" <td>3.527273</td>\n",
" <td>0.282185</td>\n",
" <td>0.192092</td>\n",
" <td>0.186749</td>\n",
" <td>0.216980</td>\n",
" <td>0.204185</td>\n",
" <td>0.240096</td>\n",
" <td>0.339114</td>\n",
" <td>0.204905</td>\n",
" <td>0.572157</td>\n",
" <td>0.593544</td>\n",
" <td>0.875928</td>\n",
" <td>1.000000</td>\n",
" <td>0.077201</td>\n",
" <td>3.875892</td>\n",
" <td>0.974947</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Self_TopPop</td>\n",
" <td>2.508258</td>\n",
" <td>2.217909</td>\n",
@ -417,69 +386,6 @@
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Ready_SVD</td>\n",
" <td>0.952784</td>\n",
" <td>0.750597</td>\n",
" <td>0.095228</td>\n",
" <td>0.047497</td>\n",
" <td>0.053142</td>\n",
" <td>0.067082</td>\n",
" <td>0.084871</td>\n",
" <td>0.076457</td>\n",
" <td>0.109075</td>\n",
" <td>0.050124</td>\n",
" <td>0.241366</td>\n",
" <td>0.520459</td>\n",
" <td>0.499470</td>\n",
" <td>0.992047</td>\n",
" <td>0.217893</td>\n",
" <td>4.405246</td>\n",
" <td>0.953484</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Self_SVDBaseline</td>\n",
" <td>0.930321</td>\n",
" <td>0.734643</td>\n",
" <td>0.092683</td>\n",
" <td>0.042046</td>\n",
" <td>0.048568</td>\n",
" <td>0.063218</td>\n",
" <td>0.082940</td>\n",
" <td>0.068730</td>\n",
" <td>0.098937</td>\n",
" <td>0.044405</td>\n",
" <td>0.203936</td>\n",
" <td>0.517696</td>\n",
" <td>0.469777</td>\n",
" <td>1.000000</td>\n",
" <td>0.058442</td>\n",
" <td>3.085857</td>\n",
" <td>0.988824</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Ready_SVDBiased</td>\n",
" <td>0.940375</td>\n",
" <td>0.742264</td>\n",
" <td>0.092153</td>\n",
" <td>0.039645</td>\n",
" <td>0.046804</td>\n",
" <td>0.061886</td>\n",
" <td>0.079399</td>\n",
" <td>0.055967</td>\n",
" <td>0.102017</td>\n",
" <td>0.047972</td>\n",
" <td>0.216876</td>\n",
" <td>0.516515</td>\n",
" <td>0.441145</td>\n",
" <td>0.997455</td>\n",
" <td>0.167388</td>\n",
" <td>4.235348</td>\n",
" <td>0.962085</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Ready_Baseline</td>\n",
" <td>0.949459</td>\n",
" <td>0.752487</td>\n",
@ -501,27 +407,6 @@
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Self_SVD</td>\n",
" <td>0.939326</td>\n",
" <td>0.740022</td>\n",
" <td>0.074549</td>\n",
" <td>0.031755</td>\n",
" <td>0.038425</td>\n",
" <td>0.050562</td>\n",
" <td>0.065665</td>\n",
" <td>0.050602</td>\n",
" <td>0.077117</td>\n",
" <td>0.031574</td>\n",
" <td>0.165509</td>\n",
" <td>0.512485</td>\n",
" <td>0.414634</td>\n",
" <td>0.981866</td>\n",
" <td>0.080087</td>\n",
" <td>3.858982</td>\n",
" <td>0.975271</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Self_GlobalAvg</td>\n",
" <td>1.125760</td>\n",
" <td>0.943534</td>\n",
@ -544,128 +429,23 @@
" <tr>\n",
" <th>0</th>\n",
" <td>Ready_Random</td>\n",
" <td>1.518551</td>\n",
" <td>1.218784</td>\n",
" <td>0.050583</td>\n",
" <td>0.024085</td>\n",
" <td>0.027323</td>\n",
" <td>0.034826</td>\n",
" <td>0.031223</td>\n",
" <td>0.026436</td>\n",
" <td>0.054902</td>\n",
" <td>0.020652</td>\n",
" <td>0.137928</td>\n",
" <td>0.508570</td>\n",
" <td>0.353128</td>\n",
" <td>0.987699</td>\n",
" <td>0.183261</td>\n",
" <td>5.093805</td>\n",
" <td>0.908215</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Ready_I-KNN</td>\n",
" <td>1.030386</td>\n",
" <td>0.813067</td>\n",
" <td>0.026087</td>\n",
" <td>0.006908</td>\n",
" <td>0.010593</td>\n",
" <td>0.016046</td>\n",
" <td>0.021137</td>\n",
" <td>0.009522</td>\n",
" <td>0.024214</td>\n",
" <td>0.008958</td>\n",
" <td>0.048068</td>\n",
" <td>0.499885</td>\n",
" <td>0.154825</td>\n",
" <td>0.402333</td>\n",
" <td>0.434343</td>\n",
" <td>5.133650</td>\n",
" <td>0.877999</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Ready_U-KNNBaseline</td>\n",
" <td>0.935327</td>\n",
" <td>0.737424</td>\n",
" <td>0.002545</td>\n",
" <td>0.000755</td>\n",
" <td>0.001105</td>\n",
" <td>0.001602</td>\n",
" <td>0.002253</td>\n",
" <td>0.000930</td>\n",
" <td>0.003444</td>\n",
" <td>0.001362</td>\n",
" <td>0.011760</td>\n",
" <td>0.496724</td>\n",
" <td>0.021209</td>\n",
" <td>0.482821</td>\n",
" <td>0.059885</td>\n",
" <td>2.232578</td>\n",
" <td>0.994487</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Ready_I-KNNBaseline</td>\n",
" <td>0.935327</td>\n",
" <td>0.737424</td>\n",
" <td>0.002545</td>\n",
" <td>0.000755</td>\n",
" <td>0.001105</td>\n",
" <td>0.001602</td>\n",
" <td>0.002253</td>\n",
" <td>0.000930</td>\n",
" <td>0.003444</td>\n",
" <td>0.001362</td>\n",
" <td>0.011760</td>\n",
" <td>0.496724</td>\n",
" <td>0.021209</td>\n",
" <td>0.482821</td>\n",
" <td>0.059885</td>\n",
" <td>2.232578</td>\n",
" <td>0.994487</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Ready_U-KNN</td>\n",
" <td>1.023495</td>\n",
" <td>0.807913</td>\n",
" <td>0.000742</td>\n",
" <td>0.000205</td>\n",
" <td>0.000305</td>\n",
" <td>0.000449</td>\n",
" <td>0.000536</td>\n",
" <td>0.000198</td>\n",
" <td>0.000845</td>\n",
" <td>0.000274</td>\n",
" <td>0.002744</td>\n",
" <td>0.496441</td>\n",
" <td>0.007423</td>\n",
" <td>0.602121</td>\n",
" <td>0.010823</td>\n",
" <td>2.089186</td>\n",
" <td>0.995706</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Self_TopRated</td>\n",
" <td>1.033085</td>\n",
" <td>0.822057</td>\n",
" <td>0.000954</td>\n",
" <td>0.000188</td>\n",
" <td>0.000298</td>\n",
" <td>0.000481</td>\n",
" <td>0.000644</td>\n",
" <td>0.000223</td>\n",
" <td>0.001043</td>\n",
" <td>0.000335</td>\n",
" <td>0.003348</td>\n",
" <td>0.496433</td>\n",
" <td>0.009544</td>\n",
" <td>0.699046</td>\n",
" <td>0.005051</td>\n",
" <td>1.945910</td>\n",
" <td>0.995669</td>\n",
" <td>1.518964</td>\n",
" <td>1.222159</td>\n",
" <td>0.046554</td>\n",
" <td>0.020603</td>\n",
" <td>0.023679</td>\n",
" <td>0.031216</td>\n",
" <td>0.028970</td>\n",
" <td>0.021179</td>\n",
" <td>0.050489</td>\n",
" <td>0.019185</td>\n",
" <td>0.123856</td>\n",
" <td>0.506812</td>\n",
" <td>0.322375</td>\n",
" <td>0.987805</td>\n",
" <td>0.184704</td>\n",
" <td>5.103172</td>\n",
" <td>0.906873</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
@ -715,61 +495,31 @@
],
"text/plain": [
" Model RMSE MAE precision recall F_1 \\\n",
"0 Self_RP3Beta 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 Ready_SVD 0.952784 0.750597 0.095228 0.047497 0.053142 \n",
"0 Self_SVDBaseline 0.930321 0.734643 0.092683 0.042046 0.048568 \n",
"0 Ready_SVDBiased 0.940375 0.742264 0.092153 0.039645 0.046804 \n",
"0 Ready_Baseline 0.949459 0.752487 0.091410 0.037652 0.046030 \n",
"0 Self_SVD 0.939326 0.740022 0.074549 0.031755 0.038425 \n",
"0 Self_GlobalAvg 1.125760 0.943534 0.061188 0.025968 0.031383 \n",
"0 Ready_Random 1.518551 1.218784 0.050583 0.024085 0.027323 \n",
"0 Ready_I-KNN 1.030386 0.813067 0.026087 0.006908 0.010593 \n",
"0 Ready_U-KNNBaseline 0.935327 0.737424 0.002545 0.000755 0.001105 \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.033085 0.822057 0.000954 0.000188 0.000298 \n",
"0 Ready_Random 1.518964 1.222159 0.046554 0.020603 0.023679 \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.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.067082 0.084871 0.076457 0.109075 0.050124 0.241366 \n",
"0 0.063218 0.082940 0.068730 0.098937 0.044405 0.203936 \n",
"0 0.061886 0.079399 0.055967 0.102017 0.047972 0.216876 \n",
"0 0.061286 0.079614 0.056463 0.095957 0.043178 0.198193 \n",
"0 0.050562 0.065665 0.050602 0.077117 0.031574 0.165509 \n",
"0 0.041343 0.040558 0.032107 0.067695 0.027470 0.171187 \n",
"0 0.034826 0.031223 0.026436 0.054902 0.020652 0.137928 \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.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.031216 0.028970 0.021179 0.050489 0.019185 0.123856 \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.593544 0.875928 1.000000 0.077201 3.875892 0.974947 \n",
"0 0.555546 0.765642 1.000000 0.038961 3.159079 0.987317 \n",
"0 0.520459 0.499470 0.992047 0.217893 4.405246 0.953484 \n",
"0 0.517696 0.469777 1.000000 0.058442 3.085857 0.988824 \n",
"0 0.516515 0.441145 0.997455 0.167388 4.235348 0.962085 \n",
"0 0.515501 0.437964 1.000000 0.033911 2.836513 0.991139 \n",
"0 0.512485 0.414634 0.981866 0.080087 3.858982 0.975271 \n",
"0 0.509546 0.384942 1.000000 0.025974 2.711772 0.992003 \n",
"0 0.508570 0.353128 0.987699 0.183261 5.093805 0.908215 \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.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.506812 0.322375 0.987805 0.184704 5.103172 0.906873 \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 "
]
},
"execution_count": 8,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
@ -802,7 +552,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 10,
"metadata": {},
"outputs": [
{
@ -828,7 +578,7 @@
"algo = sp.KNNBasic(sim_options=sim_options)\n",
"\n",
"helpers.ready_made(algo, reco_path='Recommendations generated/ml-100k/Ready_I-KNN_reco.csv',\n",
" estimations_path='Recommendations generated/ml-100k/Ready_Baseline_I-KNN_estimations.csv')"
" estimations_path='Recommendations generated/ml-100k/Ready_I-KNN_estimations.csv')"
]
},
{
@ -840,7 +590,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 11,
"metadata": {},
"outputs": [
{
@ -849,27 +599,10 @@
"text": [
"Computing the cosine similarity matrix...\n",
"Done computing similarity matrix.\n",
"Generating predictions...\n",
"Generating top N recommendations...\n",
"Generating predictions...\n"
]
},
{
"ename": "KeyboardInterrupt",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-10-dd4f59625a08>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 10\u001b[0m helpers.ready_made(algo, reco_path='Recommendations generated/ml-100k/Ready_U-KNN_reco.csv',\n\u001b[0;32m---> 11\u001b[0;31m estimations_path='Recommendations generated/ml-100k/Ready_Baseline_U-KNN_estimations.csv')\n\u001b[0m",
"\u001b[0;32m/mnt/c/Users/rkwie/Repositories/Warsztaty z uczenia maszynowego - systemy rekomendacyjne/helpers.py\u001b[0m in \u001b[0;36mready_made\u001b[0;34m(algo, reco_path, estimations_path)\u001b[0m\n\u001b[1;32m 61\u001b[0m \u001b[0mantitrainset\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtrainset\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbuild_anti_testset\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# We want to predict ratings of pairs (user, item) which are not in train set\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 62\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'Generating predictions...'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 63\u001b[0;31m \u001b[0mpredictions\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0malgo\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtest\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mantitrainset\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 64\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'Generating top N recommendations...'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 65\u001b[0m \u001b[0mtop_n\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mget_top_n\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpredictions\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mn\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m10\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/.local/lib/python3.6/site-packages/surprise/prediction_algorithms/algo_base.py\u001b[0m in \u001b[0;36mtest\u001b[0;34m(self, testset, verbose)\u001b[0m\n\u001b[1;32m 165\u001b[0m \u001b[0mr_ui_trans\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 166\u001b[0m verbose=verbose)\n\u001b[0;32m--> 167\u001b[0;31m for (uid, iid, r_ui_trans) in testset]\n\u001b[0m\u001b[1;32m 168\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mpredictions\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 169\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/.local/lib/python3.6/site-packages/surprise/prediction_algorithms/algo_base.py\u001b[0m in \u001b[0;36m<listcomp>\u001b[0;34m(.0)\u001b[0m\n\u001b[1;32m 165\u001b[0m \u001b[0mr_ui_trans\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 166\u001b[0m verbose=verbose)\n\u001b[0;32m--> 167\u001b[0;31m for (uid, iid, r_ui_trans) in testset]\n\u001b[0m\u001b[1;32m 168\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mpredictions\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 169\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/.local/lib/python3.6/site-packages/surprise/prediction_algorithms/algo_base.py\u001b[0m in \u001b[0;36mpredict\u001b[0;34m(self, uid, iid, r_ui, clip, verbose)\u001b[0m\n\u001b[1;32m 103\u001b[0m \u001b[0mdetails\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 104\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 105\u001b[0;31m \u001b[0mest\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mestimate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0miuid\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0miiid\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 106\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 107\u001b[0m \u001b[0;31m# If the details dict was also returned\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/.local/lib/python3.6/site-packages/surprise/prediction_algorithms/knns.py\u001b[0m in \u001b[0;36mestimate\u001b[0;34m(self, u, i)\u001b[0m\n\u001b[1;32m 109\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 110\u001b[0m \u001b[0mneighbors\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msim\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mx2\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mr\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mx2\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mr\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0myr\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0my\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 111\u001b[0;31m \u001b[0mk_neighbors\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mheapq\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mnlargest\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mneighbors\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkey\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mlambda\u001b[0m \u001b[0mt\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mt\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 112\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 113\u001b[0m \u001b[0;31m# compute weighted average\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/usr/lib/python3.6/heapq.py\u001b[0m in \u001b[0;36mnlargest\u001b[0;34m(n, iterable, key)\u001b[0m\n\u001b[1;32m 567\u001b[0m \u001b[0;31m# General case, slowest method\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 568\u001b[0m \u001b[0mit\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0miter\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0miterable\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 569\u001b[0;31m \u001b[0mresult\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0melem\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mi\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0melem\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0melem\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mzip\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m-\u001b[0m\u001b[0mn\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m-\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mit\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 570\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mresult\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 571\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mresult\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/usr/lib/python3.6/heapq.py\u001b[0m in \u001b[0;36m<listcomp>\u001b[0;34m(.0)\u001b[0m\n\u001b[1;32m 567\u001b[0m \u001b[0;31m# General case, slowest method\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 568\u001b[0m \u001b[0mit\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0miter\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0miterable\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 569\u001b[0;31m \u001b[0mresult\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0melem\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mi\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0melem\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0melem\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mzip\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m-\u001b[0m\u001b[0mn\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m-\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mit\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 570\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mresult\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 571\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mresult\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/.local/lib/python3.6/site-packages/surprise/prediction_algorithms/knns.py\u001b[0m in \u001b[0;36m<lambda>\u001b[0;34m(t)\u001b[0m\n\u001b[1;32m 109\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 110\u001b[0m \u001b[0mneighbors\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msim\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mx2\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mr\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mx2\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mr\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0myr\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0my\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 111\u001b[0;31m \u001b[0mk_neighbors\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mheapq\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mnlargest\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mneighbors\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkey\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mlambda\u001b[0m \u001b[0mt\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mt\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 112\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 113\u001b[0m \u001b[0;31m# compute weighted average\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mKeyboardInterrupt\u001b[0m: "
]
}
],
"source": [
@ -883,7 +616,7 @@
"algo = sp.KNNBasic(sim_options=sim_options)\n",
"\n",
"helpers.ready_made(algo, reco_path='Recommendations generated/ml-100k/Ready_U-KNN_reco.csv',\n",
" estimations_path='Recommendations generated/ml-100k/Ready_Baseline_U-KNN_estimations.csv')"
" estimations_path='Recommendations generated/ml-100k/Ready_U-KNN_estimations.csv')"
]
},
{
@ -895,9 +628,22 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 9,
"metadata": {},
"outputs": [],
"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": [
"import helpers\n",
"import surprise as sp\n",

Binary file not shown.

View File

@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 1,
"metadata": {},
"outputs": [
{
@ -11,10 +11,10 @@
"['dimensions: 1, cases when observation is the nearest: 0.0%',\n",
" 'dimensions: 2, cases when observation is the nearest: 0.0%',\n",
" 'dimensions: 3, cases when observation is the nearest: 0.0%',\n",
" 'dimensions: 10, cases when observation is the nearest: 10.0%',\n",
" 'dimensions: 20, cases when observation is the nearest: 61.0%',\n",
" 'dimensions: 30, cases when observation is the nearest: 96.0%',\n",
" 'dimensions: 40, cases when observation is the nearest: 98.0%',\n",
" 'dimensions: 10, cases when observation is the nearest: 14.000000000000002%',\n",
" 'dimensions: 20, cases when observation is the nearest: 65.0%',\n",
" 'dimensions: 30, cases when observation is the nearest: 100.0%',\n",
" 'dimensions: 40, cases when observation is the nearest: 100.0%',\n",
" 'dimensions: 50, cases when observation is the nearest: 100.0%',\n",
" 'dimensions: 60, cases when observation is the nearest: 100.0%',\n",
" 'dimensions: 70, cases when observation is the nearest: 100.0%',\n",
@ -22,7 +22,7 @@
" 'dimensions: 90, cases when observation is the nearest: 100.0%']"
]
},
"execution_count": 4,
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}

File diff suppressed because one or more lines are too long

Binary file not shown.

BIN
P5. Graph-based models.pdf Normal file

Binary file not shown.

File diff suppressed because one or more lines are too long