Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taskA
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
group18
taskA
Commits
3e4969bd
Commit
3e4969bd
authored
Aug 28, 2016
by
DIVYANSH PAREEK
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update collab-filter.py for Including Pearson Calculation
parent
03be5922
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
1 deletion
+38
-1
collab-filter.py
collab-filter.py
+38
-1
No files found.
collab-filter.py
100755 → 100644
View file @
3e4969bd
...
...
@@ -36,4 +36,41 @@ for i in range(10):
data
.
append
(
userRatings
)
file
.
close
()
userFile
.
close
()
#data is complete at this point
\ No newline at end of file
#data is complete at this point
# Pearson Correlation Basic Implementation Using for Loop
pearson
=
[]
rows
=
len
(
data
)
users
=
data
[
rows
-
1
]
cols
=
len
(
users
)
for
x
in
range
(
1
,
rows
-
1
):
# does not include (rows-1)
lis
=
data
[
x
]
sumprod
=
0
sumx
=
0
sumy
=
0
sumx2
=
0
sumy2
=
0
n
=
0
for
y
in
range
(
1
,
cols
):
if
(
float
(
lis
[
y
])
!=
-
1
and
float
(
users
[
y
])
!=
-
1
):
sumprod
+=
float
(
lis
[
y
])
*
float
(
users
[
y
])
sumx
+=
float
(
lis
[
y
])
sumy
+=
float
(
users
[
y
])
sumx2
+=
float
(
lis
[
y
])
**
2
sumy2
+=
float
(
users
[
y
])
**
2
n
+=
1
if
(
n
>
0
):
nume
=
n
*
sumprod
-
sumx
*
sumy
deno
=
(
n
*
sumx2
-
sumx
**
2
)
*
(
n
*
sumy2
-
sumy
**
2
)
deno
=
deno
**
0.5
if
(
deno
>
0
):
summ
=
nume
/
deno
else
:
summ
=
1
pearson
.
append
((
summ
,
lis
[
0
]))
else
:
pearson
.
append
((
0
,
lis
[
0
]))
pearson
.
sort
(
reverse
=
True
)
print
(
pearson
)
\ No newline at end of file
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