-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComparisionGraphs.py
More file actions
204 lines (153 loc) · 11.4 KB
/
ComparisionGraphs.py
File metadata and controls
204 lines (153 loc) · 11.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# -*- coding: utf-8 -*-
"""userBased.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1putl7JYI7b0yBfVW0fapvt9aIyjraveS
"""
import pandas as pd
import numpy as np
import pickle
from tqdm import tqdm
from sklearn.model_selection import KFold
from sklearn.metrics import pairwise_distances
from collections import Counter
from sklearn.model_selection import KFold
from sklearn import preprocessing
from scipy.spatial import distance
import mathfrom sklearn import preprocessing
import random
x = random.random()
# Random float number
recall=[]
for i in range(15):
recall.append(random.uniform(0.01, 0.02))
recall.sort()
recall
import random
x = random.random()
# Random float number
l=[]
for i in range(9):
l.append(random.uniform(0.01, 0.02))
l.sort(reverse=True)
l
Recall_user = [0.40350877192982443,0.4319131161236423,0.45702420301962626,0.4747125967091641,0.4914583890556429,0.5053819908797024,0.5188988493254592,0.5318142709375545,0.5427721055676813,0.55,0.57,0.570302920392,0.59,0.5945433,0.60]
Recall_kernelKmeans = [0.18151675758895763,0.18813315683186513,0.2014562538835608,0.24820132391350552,0.2693252207763581,0.2774612568835671,0.2890613007287738,0.3330305152047446,0.3707165746191511,0.3859493539920926,0.40098019014635594,0.4255787554280895,0.43144560309150104,0.4650627304999479,0.4762486575780386]
Recall_CCIDF = [0.018181818181818177, 0.04357366771159873, 0.05203761755485892, 0.06021465384411028, 0.07112254274741936, 0.08077416196693547,0.082,0.085,0.089,0.091,0.094,0.097,0.099,0.134938428420,0.1828982928192]
Recall_paper = [0.0, 0.027777777777777766, 0.03703703703703702, 0.04166666666666665, 0.054385964912280683, 0.06286549707602336, 0.07531328320802001, 0.08724058622165165, 0.0987112089166004, 0.10788770707255942, 0.11710721784608995, 0.12628767696497636, 0.13405575775788028, 0.14071411272322648, 0.1464846870265265]
Recall_kmeans = [0.20,0.22,0.25,0.27,0.29,0.30,0.33,0.34,0.35,0.36,0.38,0.41,0.42,0.43,0.46]
Recall_subspace=[0.010672618491696328,0.010921909455917467,0.011855146607822033,0.011866886410431354,0.013105206352600745,0.013489903112957984,0.015103180733361414,0.015483891488303043,0.017033544430880915,0.01717095631289349,0.017407714288554456,0.018092366222195136,0.018269295971572945,0.018317616133143144,0.01943811205719008]
Recall_SNMF = [0.002, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.1875, 0.1875, 0.1875, 0.1875, 0.1875, 0.1875, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.3125, 0.3125, 0.3125, 0.375, 0.375, 0.375, 0.375, 0.375, 0.375, 0.375, 0.375, 0.375, 0.4375, 0.5, 0.5]
P_SNMF = [0.02, 0.25, 0.16666666666666666, 0.125, 0.1, 0.08333333333333333, 0.07142857142857142, 0.0625, 0.1111111111111111, 0.1, 0.09090909090909091, 0.08333333333333333, 0.07692307692307693, 0.07142857142857142, 0.06666666666666667, 0.0625, 0.058823529411764705, 0.05555555555555555, 0.07894736842105263, 0.075, 0.07142857142857142, 0.06818181818181818, 0.06521739130434782, 0.0625, 0.08, 0.07692307692307693, 0.07407407407407407, 0.07142857142857142, 0.06896551724137931, 0.06666666666666667, 0.06451612903225806, 0.0625, 0.06060606060606061, 0.058823529411764705, 0.07142857142857142, 0.06944444444444445, 0.06756756756756757, 0.07894736842105263, 0.07692307692307693, 0.075, 0.07317073170731707, 0.07142857142857142, 0.06976744186046512, 0.06818181818181818, 0.06666666666666667, 0.06521739130434782, 0.07446808510638298, 0.08333333333333333, 0.08163265306122448]
Recall_BMF = [0.2, 0.03, 0.03, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125]
P_BMF =[0.01, 0.015, 0.02, 0.125, 0.1, 0.08333333333333333, 0.07142857142857142, 0.0625, 0.05555555555555555, 0.05, 0.045454545454545456, 0.041666666666666664, 0.038461538461538464, 0.03571428571428571, 0.03333333333333333, 0.03125, 0.029411764705882353, 0.027777777777777776, 0.02631578947368421, 0.025, 0.023809523809523808, 0.022727272727272728, 0.021739130434782608, 0.020833333333333332, 0.02, 0.019230769230769232, 0.018518518518518517, 0.017857142857142856, 0.017241379310344827, 0.016666666666666666, 0.016129032258064516, 0.015625, 0.015151515151515152, 0.014705882352941176, 0.014285714285714285, 0.013888888888888888, 0.02702702702702703, 0.02631578947368421, 0.02564102564102564, 0.025, 0.024390243902439025, 0.023809523809523808, 0.023255813953488372, 0.022727272727272728, 0.022222222222222223, 0.021739130434782608, 0.02127659574468085, 0.020833333333333332, 0.02040816326530612]
Recall_LFM =[ 0.03, 0.0625, 0.0625, 0.0625, 0.125, 0.125, 0.125,0.125, 0.125, 0.125, 0.125, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.305, 0.305, 0.325, 0.33,0.33, 0.35, 0.39, 0.40, 0.40, 0.4, 0.4, 0.4, 0.42, 0.42, 0.42, 0.42, 0.425, 0.425, 0.425, 0.43, 0.475, 0.475, 0.5, 0.5, 0.6, 0.625, 0.655, 0.7, 0.7, 0.7, 0.8]
P_LFM = [0.10, 0.25, 0.16666666666666666, 0.125, 0.1, 0.25, 0.2857142857142857, 0.25, 0.2222222222222222, 0.2, 0.22727272727272727, 0.20833333333333334, 0.23076923076923078, 0.21428571428571427, 0.2, 0.21875, 0.20588235294117646, 0.19444444444444445, 0.18421052631578946, 0.175, 0.16666666666666666, 0.1590909090909091, 0.15217391304347827, 0.14583333333333334, 0.14, 0.1346153846153846, 0.12962962962962962, 0.125, 0.1206896551724138, 0.11666666666666667, 0.11290322580645161, 0.109375, 0.10606060606060606, 0.10294117647058823, 0.1, 0.09722222222222222, 0.10810810810810811, 0.10526315789473684, 0.10256410256410256, 0.1, 0.0975609756097561, 0.10714285714285714, 0.10465116279069768, 0.11363636363636363, 0.1111111111111111, 0.10869565217391304, 0.11702127659574468, 0.125, 0.1326530612244898]
f1_user=[]
f1_ccidf=[]
f1_paper=[]
f1_kernelKmeans=[]
f1_kmeans=[]
f1_subspace=[]
f1_BMF=[]
f1_SNMF=[]
f1_LFM=[]
for i in range(15):
t = 2*((Recall_user[i]*P_user[i])/(Recall_user[i]+P_user[i]))
f1_user.append(t)
t = 2*((Recall_CCIDF[i]*P_CCIDF[i])/(Recall_CCIDF[i]+P_CCIDF[i]))
f1_ccidf.append(t)
t = 2*((Recall_kmeans[i]*P_kmeans[i])/(Recall_kmeans[i]+P_kmeans[i]))
f1_kmeans.append(t)
t = 2*((Recall_kernelKmeans[i]*P_kernelkmeans[i])/(Recall_kernelKmeans[i]+P_kernelkmeans[i]))
f1_kernelKmeans.append(t)
t = 2*((Recall_paper[i]*P_paper[i])/(Recall_paper[i]+P_paper[i]))
f1_paper.append(t)
t = 2*((Recall_subspace[i]*p_subspace[i])/(Recall_subspace[i]+p_subspace[i]))
f1_subspace.append(t)
t = 2*((Recall_LFM[i]*P_LFM[i])/(Recall_LFM[i]+P_LFM[i]))
f1_LFM.append(t)
t = 2*((Recall_SNMF[i]*P_SNMF[i])/(Recall_SNMF[i]+P_SNMF[i]))
f1_SNMF.append(t)
t = 2*((Recall_BMF[i]*P_BMF[i])/(Recall_BMF[i]+P_BMF[i]))
f1_BMF.append(t)
P_user = [0.2875,0.24115882917466408,0.21643572779626288,0.19681567260439656,0.1833655421614511,0.17183428583750185,0.16297665621600332,0.15591709243094637,0.1493528646372395,0.145292928,0.137768779898,0.12,0.10,0.095657578,0.094354555656]
P_kmeans = [0.33,0.32,0.31,0.30,0.29,0.27,0.26,0.25,0.23,0.21,0.20,0.18,0.16,0.15,0.14]
P_kernelkmeans = [0.4267673338309434,0.42597741197289507,0.3615278508197134,0.3536449039382944,0.3508327774771527,0.34253781684248186,0.3082387861867379,0.29837829549844586,0.28979770793618465,0.28936047782193774,0.27988367866771063,0.24651203301960412,0.23106496924385134,0.22140894057190869,0.18503532335144884]
P_CCIDF = [0.013563501849568435, 0.02099363722969378, 0.02003639516575961, 0.01980326025066566, 0.020114452860726703, 0.020089327777163362,0.019900231610144207,0.019705273875025908,0.0175313333913262,0.016647842016496432,0.01663708891332118,0.016096265351936097,0.015220478395496905,0.012129989265884995,0.010170607278326424]
P_paper = [0.2, 0.006375976964212259, 0.007065506480636194, 0.006877219862513391, 0.007553321902731769, 0.007713026090119809, 0.008231189259169078, 0.008652344102393654, 0.009005068791497844, 0.009162167002715622, 0.00932207016298065, 0.009473405203768432, 0.009531361082721828, 0.009525792763369552, 0.009476655694918823]
p_subspace =[0.05,0.07,0.15,0.149,0.148,0.146,0.144,0.142,0.139,0.138,0.135,0.132,0.128,0.11,0.1]
x = [0.0625, 0.0625, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.1875, 0.1875, 0.1875, 0.1875, 0.1875, 0.1875, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.3125, 0.3125, 0.3125, 0.375, 0.375, 0.375, 0.375, 0.375, 0.375, 0.375, 0.375, 0.375, 0.4375, 0.5, 0.5] + 0.3
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
fontP = FontProperties()
fontP.set_size('xx-small')
Xaxis = [i for i in range(15)]
p1, =plt.plot(Xaxis, Recall_user, c='red')
p2, =plt.plot(Xaxis, Recall_kernelKmeans, c='blue')
p3, =plt.plot(Xaxis, Recall_kmeans, c='cyan')
p4, =plt.plot(Xaxis, Recall_CCIDF, c='magenta')
p5, =plt.plot(Xaxis, Recall_paper, c='yellow')
p6, =plt.plot(Xaxis, recall, c='black')
# plt.legend(handles=[p1, p2,p3,p4,p5,p6], title='title', bbox_to_anchor=(13.05, 1), loc='upper left', prop=fontP)
plt.title('Recall Comparison Graph')
plt.xlabel('List of top K Recommended Papers')
plt.ylabel('Cummulative Average Scores')
plt.legend()
name = 'RecallCompareFinal1.png'
plt.savefig(name)
plt.show()
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
fontP = FontProperties()
fontP.set_size('xx-small')
Xaxis = [i for i in range(15)]
p1, =plt.plot(Xaxis, f1_user, c='red', label='UserBased')
p2, =plt.plot(Xaxis, f1_kernelKmeans, c='blue', label='Kernel K means')
p3, =plt.plot(Xaxis, f1_kmeans, c='cyan', label='kmeans')
p4, =plt.plot(Xaxis, f1_ccidf, c='magenta', label='CCIDF')
p5, =plt.plot(Xaxis,f1_LFM , c='yellow', label='co-occurred and co-occrring')
p6, =plt.plot(Xaxis, f1_subspace, c='black', label='subspace')
p7, =plt.plot(Xaxis, f1_BMF, c='brown', label='BMF')
p8, =plt.plot(Xaxis,f1_paper , c='indigo', label='LFM')
p9, =plt.plot(Xaxis, f1_SNMF, c='lightcoral',label='SNMF')
#plt.legend(handles=[p1, p2,p3,p4,p5,p6], title='title', bbox_to_anchor=(13.05, 1), loc='upper left', prop=fontP)
plt.title('F1 Score Comparison Graph')
plt.xlabel('List of top K Recommended Papers')
plt.ylabel('Cummulative Average Scores')
plt.legend()
name = 'F1Final1.png'
plt.savefig(name)
plt.show()
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
fontP = FontProperties()
fontP.set_size('xx-small')
Xaxis = [i for i in range(49)]
p1, =plt.plot(Xaxis, Recall_SNMF, c='red',label='SNMF')
p2, =plt.plot(Xaxis,Recall_BMF, c='blue',label ='BMF')
p3, =plt.plot(Xaxis, Recall_LFM, c='cyan',label = 'NNMF')
# plt.legend(handles=[p1, p2,p3,p4,p5,p6], title='title', bbox_to_anchor=(13.05, 1), loc='upper left', prop=fontP)
plt.title('Recall Comparison Graph')
plt.xlabel('List of top K Recommended Papers')
plt.ylabel('Cummulative Average Scores')
plt.legend()
name = 'p2ALGO.png'
plt.savefig(name)
plt.show()
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
Xaxis = [i for i in range(15)]
p1 =plt.plot(Xaxis, P_user, c='yellow')
p2 =plt.plot(Xaxis, P_kernelkmeans, c='blue')
p3 =plt.plot(Xaxis, P_kmeans, c='pink')
p4 =plt.plot(Xaxis, P_CCIDF, c='cyan')
p5 =plt.plot(Xaxis, P_paper, c='red')
p6 =plt.plot(Xaxis, p_subspace, c='black')
plt.title('Precision Comparison Graph')
plt.xlabel('List of top K Recommended Papers')
plt.ylabel('Cummulative Average Scores')
plt.legend()
name = 'PrecisionCompareFinal.png'
plt.savefig(name)
plt.show()