Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
task_A
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
RISHABH GARG
task_A
Commits
79c080af
Commit
79c080af
authored
Aug 27, 2016
by
RISHABH GARG
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Euclidean Distance
parent
59e137ab
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
8 deletions
+27
-8
collab-filter.py
collab-filter.py
+25
-6
user_preference.csv
user_preference.csv
+2
-2
No files found.
collab-filter.py
View file @
79c080af
import
csv
import
csv
from
math
import
sqrt
csvfile
=
open
(
'movie-ratings.csv'
)
csvfile
=
open
(
'movie-ratings.csv'
)
read
=
csv
.
reader
(
csvfile
)
read
=
csv
.
reader
(
csvfile
)
reading
=
[]
reading
=
[]
for
line
in
read
:
for
line
in
read
:
reading
.
append
(
line
)
reading
.
append
(
line
)
#########################
f2
=
open
(
"user_preference.csv"
)
f2
=
open
(
"user_preference.csv"
)
data
=
csv
.
reader
(
f2
)
user_
data
=
csv
.
reader
(
f2
)
preference
=
[]
preference
=
[]
a
=
input
(
"Your name :"
)
preference
.
append
(
input
(
"Your name :"
))
preference
.
append
(
a
)
for
line
in
user_data
:
for
line
in
data
:
preference
.
append
(
line
)
preference
.
append
(
line
)
prefdict
=
dict
(
zip
(
preference
[
1
],
preference
[
2
]))
prefdict
=
dict
(
zip
(
preference
[
1
],
preference
[
2
]))
print
(
prefdict
)
####################
\ No newline at end of file
# print(reading[1][6])
header
=
reading
[
0
]
del
reading
[
0
]
reviewers
=
[
s
[
0
]
for
s
in
reading
]
reviewdic
=
[]
for
line
in
reading
:
dic
=
dict
(
(
header
[
i
],
line
[
i
])
for
i
in
range
(
1
,
len
(
line
)))
reviewdic
.
append
(
dic
)
dist
=
[]
# print(reviewdic)
for
i
in
reviewdic
:
sum
=
0
for
j
in
prefdict
.
keys
():
if
(
i
[
j
]
!=
-
1
and
prefdict
[
j
]
!=
-
1
):
sum
+=
sqrt
((
float
(
i
[
j
])
-
float
(
prefdict
[
j
]))
**
2
)
dist
.
append
(
sum
)
# print(len(prefdict))
# for i in reviewdic:
order_dist
=
sorted
(
zip
(
reviewers
,
dist
),
key
=
lambda
x
:
x
[
1
],
reverse
=
True
)
user_preference.csv
View file @
79c080af
The Godfather,Pulp Fiction,
The Clockwork Orange,Cinema Paradiso,Wild Strawberries,Amadeus
The Godfather,Pulp Fiction,
Gone With the Wind,12 Angry Men,Lawrence of Arabia,Raging Bull,The Clockwork Orange,Cinema Paradiso,Wild Strawberries,Amadeus
9,7,6,10,8,10
9,7,6,10,8,10
,-1,-1,-1,-1
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment