Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ef24180

Browse files
Add notebook
1 parent 1e39790 commit ef24180

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

‎mainbpr.ipynb

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 2,
6+
"id": "4f81dbcc",
7+
"metadata": {},
8+
"outputs": [
9+
{
10+
"name": "stdout",
11+
"output_type": "stream",
12+
"text": [
13+
"Reading files...\n",
14+
"Finished Reading files.\n",
15+
"Iteration 0\n",
16+
"Iteration 1\n",
17+
"Iteration 2\n",
18+
"Iteration 3\n",
19+
"Iteration 4\n",
20+
"Iteration 5\n",
21+
"Iteration 6\n",
22+
"Iteration 7\n",
23+
"Iteration 8\n",
24+
"Iteration 9\n",
25+
"Finished updating.\n",
26+
"Calculating Hit Rate...\n",
27+
"Trained:\n",
28+
"HitRate 0.5073891625615764\n",
29+
"Number of Users:609\n",
30+
"Number of Movies:9742\n"
31+
]
32+
}
33+
],
34+
"source": [
35+
"from filereader import read_ratings, read_movies\n",
36+
"from bpr import bpr_update\n",
37+
"from hitrate import hit_rate\n",
38+
"from random import seed\n",
39+
"from util import cov_matrix\n",
40+
"from util import random_vector\n",
41+
"import numpy as np\n",
42+
"import random as random\n",
43+
"seed(42)\n",
44+
"np.random.seed(42)\n",
45+
"print(\"Reading files...\")\n",
46+
"users = read_ratings(\"data/ratings.csv\")\n",
47+
"movies = read_movies(\"data/movies.csv\")\n",
48+
"print(\"Finished Reading files.\")\n",
49+
"iterations = 10\n",
50+
"\n",
51+
"for i in range(iterations):\n",
52+
" print(\"Iteration \" + str(i))\n",
53+
" bpr_update(users, movies)\n",
54+
"\n",
55+
"print(\"Finished updating.\")\n",
56+
"print(\"Calculating Hit Rate...\")\n",
57+
"\n",
58+
"hits, denom, rms, rmsall = hit_rate(users, movies)\n",
59+
"\n",
60+
"print(\"Trained:\")\n",
61+
"print(\"HitRate\" + ' ' + str(hits/denom))\n",
62+
"print(\"Number of Users:\" + str(len(users)))\n",
63+
"print(\"Number of Movies:\" + str(len(movies)))"
64+
]
65+
}
66+
],
67+
"metadata": {
68+
"kernelspec": {
69+
"display_name": "Python 3",
70+
"language": "python",
71+
"name": "python3"
72+
},
73+
"language_info": {
74+
"codemirror_mode": {
75+
"name": "ipython",
76+
"version": 3
77+
},
78+
"file_extension": ".py",
79+
"mimetype": "text/x-python",
80+
"name": "python",
81+
"nbconvert_exporter": "python",
82+
"pygments_lexer": "ipython3",
83+
"version": "3.8.8"
84+
}
85+
},
86+
"nbformat": 4,
87+
"nbformat_minor": 5
88+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /