add result rounding
This commit is contained in:
parent
18c03e5d02
commit
aa534a578f
54784
datasets/test_all.csv
54784
datasets/test_all.csv
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
143754
datasets/train_all.csv
143754
datasets/train_all.csv
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -3,8 +3,8 @@
|
|||||||
{
|
{
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"ExecuteTime": {
|
"ExecuteTime": {
|
||||||
"end_time": "2024-12-07T01:55:39.637007Z",
|
"end_time": "2024-12-07T02:10:47.179886Z",
|
||||||
"start_time": "2024-12-07T01:55:39.633398Z"
|
"start_time": "2024-12-07T02:10:47.169245Z"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
@ -15,13 +15,13 @@
|
|||||||
],
|
],
|
||||||
"id": "5a823fabad3c186f",
|
"id": "5a823fabad3c186f",
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"execution_count": 2
|
"execution_count": 18
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"ExecuteTime": {
|
"ExecuteTime": {
|
||||||
"end_time": "2024-12-07T01:55:39.646149Z",
|
"end_time": "2024-12-07T02:10:47.197156Z",
|
||||||
"start_time": "2024-12-07T01:55:39.641016Z"
|
"start_time": "2024-12-07T02:10:47.181892Z"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
@ -36,13 +36,13 @@
|
|||||||
],
|
],
|
||||||
"id": "d694dbe819b591ac",
|
"id": "d694dbe819b591ac",
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"execution_count": 3
|
"execution_count": 19
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"ExecuteTime": {
|
"ExecuteTime": {
|
||||||
"end_time": "2024-12-07T01:55:39.715567Z",
|
"end_time": "2024-12-07T02:10:47.278189Z",
|
||||||
"start_time": "2024-12-07T01:55:39.660120Z"
|
"start_time": "2024-12-07T02:10:47.199151Z"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
@ -52,39 +52,39 @@
|
|||||||
],
|
],
|
||||||
"id": "1bc78bafbae06c89",
|
"id": "1bc78bafbae06c89",
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"execution_count": 4
|
"execution_count": 20
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"ExecuteTime": {
|
"ExecuteTime": {
|
||||||
"end_time": "2024-12-07T01:55:39.729648Z",
|
"end_time": "2024-12-07T02:10:47.298677Z",
|
||||||
"start_time": "2024-12-07T01:55:39.717570Z"
|
"start_time": "2024-12-07T02:10:47.280192Z"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"source": "movies['genres'] = movies['genres'].str.split('|')",
|
"source": "movies['genres'] = movies['genres'].str.split('|')",
|
||||||
"id": "2543aa8216425342",
|
"id": "2543aa8216425342",
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"execution_count": 5
|
"execution_count": 21
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"ExecuteTime": {
|
"ExecuteTime": {
|
||||||
"end_time": "2024-12-07T01:55:39.758043Z",
|
"end_time": "2024-12-07T02:10:47.334238Z",
|
||||||
"start_time": "2024-12-07T01:55:39.730651Z"
|
"start_time": "2024-12-07T02:10:47.299673Z"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"source": "data = pd.merge(ratings, movies, on=\"movieId\")",
|
"source": "data = pd.merge(ratings, movies, on=\"movieId\")",
|
||||||
"id": "b3fa37255dccb066",
|
"id": "b3fa37255dccb066",
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"execution_count": 6
|
"execution_count": 22
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"ExecuteTime": {
|
"ExecuteTime": {
|
||||||
"end_time": "2024-12-07T01:55:39.775205Z",
|
"end_time": "2024-12-07T02:10:47.349030Z",
|
||||||
"start_time": "2024-12-07T01:55:39.759045Z"
|
"start_time": "2024-12-07T02:10:47.336244Z"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
@ -255,31 +255,31 @@
|
|||||||
"</div>"
|
"</div>"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"execution_count": 7,
|
"execution_count": 23,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"output_type": "execute_result"
|
"output_type": "execute_result"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"execution_count": 7
|
"execution_count": 23
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"ExecuteTime": {
|
"ExecuteTime": {
|
||||||
"end_time": "2024-12-07T01:55:39.789305Z",
|
"end_time": "2024-12-07T02:10:47.374751Z",
|
||||||
"start_time": "2024-12-07T01:55:39.776211Z"
|
"start_time": "2024-12-07T02:10:47.352036Z"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"source": "train_data, test_data = split_by_user(data)",
|
"source": "train_data, test_data = split_by_user(data)",
|
||||||
"id": "b66149513c0c6b0e",
|
"id": "b66149513c0c6b0e",
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"execution_count": 8
|
"execution_count": 24
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"ExecuteTime": {
|
"ExecuteTime": {
|
||||||
"end_time": "2024-12-07T01:55:39.800344Z",
|
"end_time": "2024-12-07T02:10:47.387434Z",
|
||||||
"start_time": "2024-12-07T01:55:39.790308Z"
|
"start_time": "2024-12-07T02:10:47.375755Z"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
@ -450,18 +450,18 @@
|
|||||||
"</div>"
|
"</div>"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"execution_count": 9,
|
"execution_count": 25,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"output_type": "execute_result"
|
"output_type": "execute_result"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"execution_count": 9
|
"execution_count": 25
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"ExecuteTime": {
|
"ExecuteTime": {
|
||||||
"end_time": "2024-12-07T01:55:39.813332Z",
|
"end_time": "2024-12-07T02:10:47.402433Z",
|
||||||
"start_time": "2024-12-07T01:55:39.803336Z"
|
"start_time": "2024-12-07T02:10:47.389431Z"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
@ -645,18 +645,18 @@
|
|||||||
"</div>"
|
"</div>"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"execution_count": 10,
|
"execution_count": 26,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"output_type": "execute_result"
|
"output_type": "execute_result"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"execution_count": 10
|
"execution_count": 26
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"ExecuteTime": {
|
"ExecuteTime": {
|
||||||
"end_time": "2024-12-07T01:56:24.904397Z",
|
"end_time": "2024-12-07T02:11:35.298333Z",
|
||||||
"start_time": "2024-12-07T01:55:39.833745Z"
|
"start_time": "2024-12-07T02:10:47.404434Z"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
@ -685,7 +685,7 @@
|
|||||||
" genre_scores = user_pref[user_pref['genres'].isin(genres)]['avg_genre_rating']\n",
|
" genre_scores = user_pref[user_pref['genres'].isin(genres)]['avg_genre_rating']\n",
|
||||||
"\n",
|
"\n",
|
||||||
" if not genre_scores.empty:\n",
|
" if not genre_scores.empty:\n",
|
||||||
" return genre_scores.mean()\n",
|
" return round(genre_scores.mean(), 2)\n",
|
||||||
" else:\n",
|
" else:\n",
|
||||||
" return 0\n",
|
" return 0\n",
|
||||||
"\n",
|
"\n",
|
||||||
@ -714,7 +714,7 @@
|
|||||||
" genre_scores = user_pref[user_pref['genres'].isin(genres)]['avg_genre_rating']\n",
|
" genre_scores = user_pref[user_pref['genres'].isin(genres)]['avg_genre_rating']\n",
|
||||||
"\n",
|
"\n",
|
||||||
" if not genre_scores.empty:\n",
|
" if not genre_scores.empty:\n",
|
||||||
" return genre_scores.mean()\n",
|
" return round(genre_scores.mean(), 2)\n",
|
||||||
" else:\n",
|
" else:\n",
|
||||||
" return 0\n",
|
" return 0\n",
|
||||||
"\n",
|
"\n",
|
||||||
@ -722,13 +722,13 @@
|
|||||||
],
|
],
|
||||||
"id": "88296c8c47cdbf60",
|
"id": "88296c8c47cdbf60",
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"execution_count": 11
|
"execution_count": 27
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"ExecuteTime": {
|
"ExecuteTime": {
|
||||||
"end_time": "2024-12-07T01:56:54.150918Z",
|
"end_time": "2024-12-07T02:12:06.387910Z",
|
||||||
"start_time": "2024-12-07T01:56:24.905400Z"
|
"start_time": "2024-12-07T02:11:35.300336Z"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
@ -742,7 +742,7 @@
|
|||||||
" similar_users = train_user_similarity_df[user_id].sort_values(ascending=False).index[1:top_n + 1]\n",
|
" similar_users = train_user_similarity_df[user_id].sort_values(ascending=False).index[1:top_n + 1]\n",
|
||||||
" similar_ratings = train_user_movie.loc[similar_users, movie_id]\n",
|
" similar_ratings = train_user_movie.loc[similar_users, movie_id]\n",
|
||||||
"\n",
|
"\n",
|
||||||
" return similar_ratings.dropna().mean()\n",
|
" return round(similar_ratings.dropna().mean(), 2)\n",
|
||||||
"\n",
|
"\n",
|
||||||
"train_data['similarUsers'] = train_data.apply(\n",
|
"train_data['similarUsers'] = train_data.apply(\n",
|
||||||
" lambda row: train_average(row['userId'], row['movieId']), axis=1\n",
|
" lambda row: train_average(row['userId'], row['movieId']), axis=1\n",
|
||||||
@ -757,7 +757,7 @@
|
|||||||
" similar_users = test_user_similarity_df[user_id].sort_values(ascending=False).index[1:top_n + 1]\n",
|
" similar_users = test_user_similarity_df[user_id].sort_values(ascending=False).index[1:top_n + 1]\n",
|
||||||
" similar_ratings = test_user_movie.loc[similar_users, movie_id]\n",
|
" similar_ratings = test_user_movie.loc[similar_users, movie_id]\n",
|
||||||
"\n",
|
"\n",
|
||||||
" return similar_ratings.dropna().mean()\n",
|
" return round(similar_ratings.dropna().mean(), 2)\n",
|
||||||
"\n",
|
"\n",
|
||||||
"test_data['similarUsers'] = test_data.apply(\n",
|
"test_data['similarUsers'] = test_data.apply(\n",
|
||||||
" lambda row: test_average(row['userId'], row['movieId']), axis=1\n",
|
" lambda row: test_average(row['userId'], row['movieId']), axis=1\n",
|
||||||
@ -765,13 +765,13 @@
|
|||||||
],
|
],
|
||||||
"id": "e931f4041a1802fb",
|
"id": "e931f4041a1802fb",
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"execution_count": 12
|
"execution_count": 28
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"ExecuteTime": {
|
"ExecuteTime": {
|
||||||
"end_time": "2024-12-07T01:56:54.194857Z",
|
"end_time": "2024-12-07T02:12:06.432258Z",
|
||||||
"start_time": "2024-12-07T01:56:54.151920Z"
|
"start_time": "2024-12-07T02:12:06.388912Z"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
@ -784,13 +784,13 @@
|
|||||||
],
|
],
|
||||||
"id": "ce65ce417e7f5207",
|
"id": "ce65ce417e7f5207",
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"execution_count": 13
|
"execution_count": 29
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"ExecuteTime": {
|
"ExecuteTime": {
|
||||||
"end_time": "2024-12-07T01:56:54.224008Z",
|
"end_time": "2024-12-07T02:12:06.459220Z",
|
||||||
"start_time": "2024-12-07T01:56:54.195860Z"
|
"start_time": "2024-12-07T02:12:06.433260Z"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
@ -803,13 +803,13 @@
|
|||||||
],
|
],
|
||||||
"id": "aa798201db531188",
|
"id": "aa798201db531188",
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"execution_count": 14
|
"execution_count": 30
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"ExecuteTime": {
|
"ExecuteTime": {
|
||||||
"end_time": "2024-12-07T01:56:54.819973Z",
|
"end_time": "2024-12-07T02:12:06.988425Z",
|
||||||
"start_time": "2024-12-07T01:56:54.225011Z"
|
"start_time": "2024-12-07T02:12:06.459645Z"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
@ -819,13 +819,13 @@
|
|||||||
],
|
],
|
||||||
"id": "f7b5130c72ad35af",
|
"id": "f7b5130c72ad35af",
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"execution_count": 15
|
"execution_count": 31
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"ExecuteTime": {
|
"ExecuteTime": {
|
||||||
"end_time": "2024-12-07T01:56:54.846938Z",
|
"end_time": "2024-12-07T02:12:07.017641Z",
|
||||||
"start_time": "2024-12-07T01:56:54.820977Z"
|
"start_time": "2024-12-07T02:12:06.989428Z"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
@ -839,13 +839,13 @@
|
|||||||
],
|
],
|
||||||
"id": "20dba13e7a3d105b",
|
"id": "20dba13e7a3d105b",
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"execution_count": 16
|
"execution_count": 32
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"ExecuteTime": {
|
"ExecuteTime": {
|
||||||
"end_time": "2024-12-07T01:56:54.873768Z",
|
"end_time": "2024-12-07T02:12:07.042554Z",
|
||||||
"start_time": "2024-12-07T01:56:54.847941Z"
|
"start_time": "2024-12-07T02:12:07.018643Z"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
@ -855,7 +855,7 @@
|
|||||||
],
|
],
|
||||||
"id": "be9f6106c5e4b04a",
|
"id": "be9f6106c5e4b04a",
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"execution_count": 17
|
"execution_count": 33
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
Loading…
Reference in New Issue
Block a user