add result rounding

This commit is contained in:
Marysia 2024-12-07 03:17:45 +01:00
parent 18c03e5d02
commit aa534a578f
5 changed files with 102266 additions and 102266 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

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