In [1]:
import pandas as pd
import numpy as np
import os
import scipy as sp
from sklearn.metrics.pairwise import cosine_similarity
import operator
import cv2
import glob
from keras.preprocessing import image
from matplotlib import pyplot as plt
import seaborn as sns
%matplotlib inline
Using TensorFlow backend.
In [2]:
os.chdir('/Users/Walkon302/Desktop/deep-learning-models-master/view2buy')
In [96]:
df = pd.read_pickle('view2buy_url_CF_user_buy.pkl')
In [97]:
df.head()
Out[97]:
0
user_id
buy_spu
buy_sn
buy_ct3
view_spu
view_sn
view_ct3
time_interval
view_cnt
view_secondes
view_features
buy_features
spu
url
user_buy
CF_item
0
4209887493\t453532580309307392\t10004616\t334\...
4209887493
453532580309307392
10004616
334
14150170026959126
10010102
334
21114
1
11
[0.135, 1.078, 0.06, 0.241, 0.213, 0.22, 0.039...
[0.1, 1.804, 0.049, 0.883, 0.092, 0.053, 0.042...
14150170026959126
http://a.vpimg2.com/upload/merchandise/pdcvis/...
4209887493-453532580309307392
[82267097285177879, 12742773141631009, 8883989...
1
529805243\t103096245561765919\t10010102\t334\t...
529805243
103096245561765919
10010102
334
14150170026959126
10010102
334
37794
4
66
[0.135, 1.078, 0.06, 0.241, 0.213, 0.22, 0.039...
[0.467, 0.385, 0.0, 0.043, 0.292, 0.0, 0.448, ...
14150170026959126
http://a.vpimg2.com/upload/merchandise/pdcvis/...
529805243-103096245561765919
[82267097285177879, 12742773141631009, 8883989...
2
3748045464\t446777176556679168\t10005711\t334\...
3748045464
446777176556679168
10005711
334
14150170026959126
10010102
334
18820
1
34
[0.135, 1.078, 0.06, 0.241, 0.213, 0.22, 0.039...
[0.018, 0.161, 0.088, 0.141, 0.231, 0.0, 0.036...
14150170026959126
http://a.vpimg2.com/upload/merchandise/pdcvis/...
3748045464-446777176556679168
[82267097285177879, 12742773141631009, 8883989...
3
4209887493\t438895881520357521\t10004616\t334\...
4209887493
438895881520357521
10004616
334
14150170026959126
10010102
334
13978
1
11
[0.135, 1.078, 0.06, 0.241, 0.213, 0.22, 0.039...
[0.036, 0.439, 0.0, 0.074, 0.194, 0.0, 0.331, ...
14150170026959126
http://a.vpimg2.com/upload/merchandise/pdcvis/...
4209887493-438895881520357521
[82267097285177879, 12742773141631009, 8883989...
4
4209887493\t74104320184119307\t10004616\t334\t...
4209887493
74104320184119307
10004616
334
14150170026959126
10010102
334
14313
1
11
[0.135, 1.078, 0.06, 0.241, 0.213, 0.22, 0.039...
[0.078, 2.304, 0.132, 0.191, 0.0, 0.087, 0.341...
14150170026959126
http://a.vpimg2.com/upload/merchandise/pdcvis/...
4209887493-74104320184119307
[82267097285177879, 12742773141631009, 8883989...
In [89]:
df2 = pd.read_pickle('view2buy_url_CF.pkl')
In [90]:
df2.head()
Out[90]:
0
user_id
buy_spu
buy_sn
buy_ct3
view_spu
view_sn
view_ct3
time_interval
view_cnt
view_secondes
view_features
buy_features
spu
url
CF_item
0
4209887493\t453532580309307392\t10004616\t334\...
4209887493
453532580309307392
10004616
334
14150170026959126
10010102
334
21114
1
11
[0.135, 1.078, 0.06, 0.241, 0.213, 0.22, 0.039...
[0.1, 1.804, 0.049, 0.883, 0.092, 0.053, 0.042...
14150170026959126
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[82267097285177879, 12742773141631009, 3341747...
1
529805243\t103096245561765919\t10010102\t334\t...
529805243
103096245561765919
10010102
334
14150170026959126
10010102
334
37794
4
66
[0.135, 1.078, 0.06, 0.241, 0.213, 0.22, 0.039...
[0.467, 0.385, 0.0, 0.043, 0.292, 0.0, 0.448, ...
14150170026959126
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[82267097285177879, 12742773141631009, 3341747...
2
3748045464\t446777176556679168\t10005711\t334\...
3748045464
446777176556679168
10005711
334
14150170026959126
10010102
334
18820
1
34
[0.135, 1.078, 0.06, 0.241, 0.213, 0.22, 0.039...
[0.018, 0.161, 0.088, 0.141, 0.231, 0.0, 0.036...
14150170026959126
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[82267097285177879, 12742773141631009, 3341747...
3
4209887493\t438895881520357521\t10004616\t334\...
4209887493
438895881520357521
10004616
334
14150170026959126
10010102
334
13978
1
11
[0.135, 1.078, 0.06, 0.241, 0.213, 0.22, 0.039...
[0.036, 0.439, 0.0, 0.074, 0.194, 0.0, 0.331, ...
14150170026959126
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[82267097285177879, 12742773141631009, 3341747...
4
4209887493\t74104320184119307\t10004616\t334\t...
4209887493
74104320184119307
10004616
334
14150170026959126
10010102
334
14313
1
11
[0.135, 1.078, 0.06, 0.241, 0.213, 0.22, 0.039...
[0.078, 2.304, 0.132, 0.191, 0.0, 0.087, 0.341...
14150170026959126
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[82267097285177879, 12742773141631009, 3341747...
In [86]:
df[df['user_id']== 4209887493].columns
Out[86]:
Index([u'0', u'user_id', u'buy_spu', u'buy_sn', u'buy_ct3', u'view_spu',
u'view_sn', u'view_ct3', u'time_interval', u'view_cnt',
u'view_secondes', u'view_features_x', u'buy_features', u'spu', u'url',
u'CF_item_x', u'CF_item_y', u'ave_CF_fea_x', u'user_features',
u'CF_sim', u'CF_rank', u'ori_user_features', u'ori_sim', u'ori_rank'],
dtype='object')
In [77]:
df.drop(['0', 'CF_item_y', 'user_features', 'CF_sim', 'CF_rank', 'ori_user_features', 'ori_sim', 'ori_rank'], axis = 1)
Out[77]:
user_id
buy_spu
buy_sn
buy_ct3
view_spu
view_sn
view_ct3
time_interval
view_cnt
view_secondes
view_features_x
buy_features
spu
url
CF_item_x
ave_CF_fea_x
0
4209887493
453532580309307392
10004616
334
14150170026959126
10010102
334
21114
1
11
[0.135, 1.078, 0.06, 0.241, 0.213, 0.22, 0.039...
[0.1, 1.804, 0.049, 0.883, 0.092, 0.053, 0.042...
14150170026959126
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[82267097285177879, 12742773141631009, 3341747...
[0.5528, 1.3589, 0.0329, 0.2652, 0.1121, 0.070...
1
4209887493
438895881520357521
10004616
334
14150170026959126
10010102
334
13978
1
11
[0.135, 1.078, 0.06, 0.241, 0.213, 0.22, 0.039...
[0.036, 0.439, 0.0, 0.074, 0.194, 0.0, 0.331, ...
14150170026959126
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[82267097285177879, 12742773141631009, 3341747...
[0.5528, 1.3589, 0.0329, 0.2652, 0.1121, 0.070...
2
4209887493
74104320184119307
10004616
334
14150170026959126
10010102
334
14313
1
11
[0.135, 1.078, 0.06, 0.241, 0.213, 0.22, 0.039...
[0.078, 2.304, 0.132, 0.191, 0.0, 0.087, 0.341...
14150170026959126
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[82267097285177879, 12742773141631009, 3341747...
[0.5528, 1.3589, 0.0329, 0.2652, 0.1121, 0.070...
3
4209887493
453532580309307392
10004616
334
99155636687355977
10023064
334
18202
1
22
[0.349, 0.394, 0.007, 2.666, 0.009, 0.0, 0.0, ...
[0.1, 1.804, 0.049, 0.883, 0.092, 0.053, 0.042...
99155636687355977
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[438895881520357521, 74104320184119307, 443680...
[0.146, 0.7319, 0.0257, 0.6735, 0.1741, 0.0252...
4
4209887493
438895881520357521
10004616
334
99155636687355977
10023064
334
11066
1
22
[0.349, 0.394, 0.007, 2.666, 0.009, 0.0, 0.0, ...
[0.036, 0.439, 0.0, 0.074, 0.194, 0.0, 0.331, ...
99155636687355977
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[438895881520357521, 74104320184119307, 443680...
[0.146, 0.7319, 0.0257, 0.6735, 0.1741, 0.0252...
5
4209887493
74104320184119307
10004616
334
99155636687355977
10023064
334
11401
1
22
[0.349, 0.394, 0.007, 2.666, 0.009, 0.0, 0.0, ...
[0.078, 2.304, 0.132, 0.191, 0.0, 0.087, 0.341...
99155636687355977
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[438895881520357521, 74104320184119307, 443680...
[0.146, 0.7319, 0.0257, 0.6735, 0.1741, 0.0252...
6
4209887493
453532580309307392
10004616
334
82548613061427358
10023064
334
18053
2
10
[0.261, 1.139, 0.074, 2.173, 0.081, 0.0, 0.158...
[0.1, 1.804, 0.049, 0.883, 0.092, 0.053, 0.042...
82548613061427358
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[438895881520357521, 74104320184119307, 443680...
[0.146, 0.7319, 0.0257, 0.6735, 0.1741, 0.0252...
7
4209887493
438895881520357521
10004616
334
82548613061427358
10023064
334
10917
2
10
[0.261, 1.139, 0.074, 2.173, 0.081, 0.0, 0.158...
[0.036, 0.439, 0.0, 0.074, 0.194, 0.0, 0.331, ...
82548613061427358
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[438895881520357521, 74104320184119307, 443680...
[0.146, 0.7319, 0.0257, 0.6735, 0.1741, 0.0252...
8
4209887493
74104320184119307
10004616
334
82548613061427358
10023064
334
11252
2
10
[0.261, 1.139, 0.074, 2.173, 0.081, 0.0, 0.158...
[0.078, 2.304, 0.132, 0.191, 0.0, 0.087, 0.341...
82548613061427358
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[438895881520357521, 74104320184119307, 443680...
[0.146, 0.7319, 0.0257, 0.6735, 0.1741, 0.0252...
9
4209887493
453532580309307392
10004616
334
74104320184119307
10004616
334
6801
10
62
[0.078, 2.304, 0.132, 0.191, 0.0, 0.087, 0.341...
[0.1, 1.804, 0.049, 0.883, 0.092, 0.053, 0.042...
74104320184119307
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[438895881520357521, 74104320184119307, 443680...
[0.146, 0.7319, 0.0257, 0.6735, 0.1741, 0.0252...
10
4209887493
74104320184119307
10004616
334
74104320184119307
10004616
334
0
10
62
[0.078, 2.304, 0.132, 0.191, 0.0, 0.087, 0.341...
[0.078, 2.304, 0.132, 0.191, 0.0, 0.087, 0.341...
74104320184119307
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[438895881520357521, 74104320184119307, 443680...
[0.146, 0.7319, 0.0257, 0.6735, 0.1741, 0.0252...
11
4209887493
453532580309307392
10004616
334
443118006171230222
10004616
334
15671
2
10
[0.349, 0.113, 0.013, 0.515, 0.542, 0.0, 0.097...
[0.1, 1.804, 0.049, 0.883, 0.092, 0.053, 0.042...
443118006171230222
http://a.vpimg2.com/upload/merchandise/pdc/222...
[455221430169571357, 453532580309307392, 44311...
[0.3929, 0.919, 0.1094, 0.4559, 0.2379, 0.0193...
12
4209887493
438895881520357521
10004616
334
443118006171230222
10004616
334
8535
2
10
[0.349, 0.113, 0.013, 0.515, 0.542, 0.0, 0.097...
[0.036, 0.439, 0.0, 0.074, 0.194, 0.0, 0.331, ...
443118006171230222
http://a.vpimg2.com/upload/merchandise/pdc/222...
[455221430169571357, 453532580309307392, 44311...
[0.3929, 0.919, 0.1094, 0.4559, 0.2379, 0.0193...
13
4209887493
74104320184119307
10004616
334
443118006171230222
10004616
334
8870
2
10
[0.349, 0.113, 0.013, 0.515, 0.542, 0.0, 0.097...
[0.078, 2.304, 0.132, 0.191, 0.0, 0.087, 0.341...
443118006171230222
http://a.vpimg2.com/upload/merchandise/pdc/222...
[455221430169571357, 453532580309307392, 44311...
[0.3929, 0.919, 0.1094, 0.4559, 0.2379, 0.0193...
14
4209887493
453532580309307392
10004616
334
455221430169571357
10004616
334
15829
2
25
[0.128, 1.575, 0.0, 0.03, 0.0, 0.0, 0.013, 0.0...
[0.1, 1.804, 0.049, 0.883, 0.092, 0.053, 0.042...
455221430169571357
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[443118006171230222, 453532580309307392, 99155...
[0.166, 0.8309, 0.0245, 0.5715, 0.1694, 0.0303...
15
4209887493
438895881520357521
10004616
334
455221430169571357
10004616
334
8693
2
25
[0.128, 1.575, 0.0, 0.03, 0.0, 0.0, 0.013, 0.0...
[0.036, 0.439, 0.0, 0.074, 0.194, 0.0, 0.331, ...
455221430169571357
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[443118006171230222, 453532580309307392, 99155...
[0.166, 0.8309, 0.0245, 0.5715, 0.1694, 0.0303...
16
4209887493
74104320184119307
10004616
334
455221430169571357
10004616
334
9028
2
25
[0.128, 1.575, 0.0, 0.03, 0.0, 0.0, 0.013, 0.0...
[0.078, 2.304, 0.132, 0.191, 0.0, 0.087, 0.341...
455221430169571357
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[443118006171230222, 453532580309307392, 99155...
[0.166, 0.8309, 0.0245, 0.5715, 0.1694, 0.0303...
17
4209887493
453532580309307392
10004616
334
453532580309307392
10004616
334
0
13
149
[0.1, 1.804, 0.049, 0.883, 0.092, 0.053, 0.042...
[0.1, 1.804, 0.049, 0.883, 0.092, 0.053, 0.042...
453532580309307392
http://a.vpimg2.com/upload/merchandise/pdc/392...
[82548613061427358, 443680956124434457, 872045...
[0.1436, 0.5797, 0.0125, 0.6813, 0.1741, 0.016...
18
4209887493
453532580309307392
10004616
334
438895881520357521
10004616
334
7136
10
77
[0.036, 0.439, 0.0, 0.074, 0.194, 0.0, 0.331, ...
[0.1, 1.804, 0.049, 0.883, 0.092, 0.053, 0.042...
438895881520357521
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[438895881520357521, 74104320184119307, 443680...
[0.146, 0.7319, 0.0257, 0.6735, 0.1741, 0.0252...
19
4209887493
438895881520357521
10004616
334
438895881520357521
10004616
334
0
10
77
[0.036, 0.439, 0.0, 0.074, 0.194, 0.0, 0.331, ...
[0.036, 0.439, 0.0, 0.074, 0.194, 0.0, 0.331, ...
438895881520357521
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[438895881520357521, 74104320184119307, 443680...
[0.146, 0.7319, 0.0257, 0.6735, 0.1741, 0.0252...
20
4209887493
453532580309307392
10004616
334
461976829617950723
10004616
334
15660
1
10
[0.006, 0.131, 0.0, 0.44, 0.406, 0.002, 0.198,...
[0.1, 1.804, 0.049, 0.883, 0.092, 0.053, 0.042...
461976829617950723
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[438895881520357521, 74104320184119307, 443680...
[0.146, 0.7319, 0.0257, 0.6735, 0.1741, 0.0252...
21
4209887493
438895881520357521
10004616
334
461976829617950723
10004616
334
8524
1
10
[0.006, 0.131, 0.0, 0.44, 0.406, 0.002, 0.198,...
[0.036, 0.439, 0.0, 0.074, 0.194, 0.0, 0.331, ...
461976829617950723
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[438895881520357521, 74104320184119307, 443680...
[0.146, 0.7319, 0.0257, 0.6735, 0.1741, 0.0252...
22
4209887493
74104320184119307
10004616
334
461976829617950723
10004616
334
8859
1
10
[0.006, 0.131, 0.0, 0.44, 0.406, 0.002, 0.198,...
[0.078, 2.304, 0.132, 0.191, 0.0, 0.087, 0.341...
461976829617950723
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[438895881520357521, 74104320184119307, 443680...
[0.146, 0.7319, 0.0257, 0.6735, 0.1741, 0.0252...
23
4209887493
453532580309307392
10004616
334
74104337169281026
10004616
334
15606
1
4
[0.054, 0.782, 0.0, 0.269, 0.0, 0.0, 0.164, 0....
[0.1, 1.804, 0.049, 0.883, 0.092, 0.053, 0.042...
74104337169281026
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[438895881520357521, 74104320184119307, 443680...
[0.146, 0.7319, 0.0257, 0.6735, 0.1741, 0.0252...
24
4209887493
438895881520357521
10004616
334
74104337169281026
10004616
334
8470
1
4
[0.054, 0.782, 0.0, 0.269, 0.0, 0.0, 0.164, 0....
[0.036, 0.439, 0.0, 0.074, 0.194, 0.0, 0.331, ...
74104337169281026
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[438895881520357521, 74104320184119307, 443680...
[0.146, 0.7319, 0.0257, 0.6735, 0.1741, 0.0252...
25
4209887493
74104320184119307
10004616
334
74104337169281026
10004616
334
8805
1
4
[0.054, 0.782, 0.0, 0.269, 0.0, 0.0, 0.164, 0....
[0.078, 2.304, 0.132, 0.191, 0.0, 0.087, 0.341...
74104337169281026
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[438895881520357521, 74104320184119307, 443680...
[0.146, 0.7319, 0.0257, 0.6735, 0.1741, 0.0252...
26
4209887493
453532580309307392
10004616
334
93807568553869425
10004616
334
15517
1
28
[0.01, 0.688, 0.033, 0.075, 0.525, 0.0, 0.084,...
[0.1, 1.804, 0.049, 0.883, 0.092, 0.053, 0.042...
93807568553869425
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[438895881520357521, 74104320184119307, 443680...
[0.146, 0.7319, 0.0257, 0.6735, 0.1741, 0.0252...
27
4209887493
438895881520357521
10004616
334
93807568553869425
10004616
334
8381
1
28
[0.01, 0.688, 0.033, 0.075, 0.525, 0.0, 0.084,...
[0.036, 0.439, 0.0, 0.074, 0.194, 0.0, 0.331, ...
93807568553869425
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[438895881520357521, 74104320184119307, 443680...
[0.146, 0.7319, 0.0257, 0.6735, 0.1741, 0.0252...
28
4209887493
74104320184119307
10004616
334
93807568553869425
10004616
334
8716
1
28
[0.01, 0.688, 0.033, 0.075, 0.525, 0.0, 0.084,...
[0.078, 2.304, 0.132, 0.191, 0.0, 0.087, 0.341...
93807568553869425
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[438895881520357521, 74104320184119307, 443680...
[0.146, 0.7319, 0.0257, 0.6735, 0.1741, 0.0252...
29
4209887493
453532580309307392
10004616
334
3061398180775350287
10004616
334
15788
1
2
[0.071, 0.918, 0.0, 0.001, 0.109, 0.076, 0.18,...
[0.1, 1.804, 0.049, 0.883, 0.092, 0.053, 0.042...
3061398180775350287
http://a.vpimg2.com/upload/merchandise/pdc/287...
[438895881520357521, 74104320184119307, 443680...
[0.146, 0.7319, 0.0257, 0.6735, 0.1741, 0.0252...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
17430
3673391202
450999316113584132
10021264
334
233700618554818563
10012320
334
84949
5
45
[0.223, 0.956, 0.0, 0.048, 0.061, 0.007, 0.562...
[0.791, 1.814, 0.013, 0.438, 0.037, 0.0, 0.412...
233700618554818563
http://a.vpimg2.com/upload/merchandise/pdc/563...
[439740353870500018, 15839007868620828, 282239...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
17431
3673391202
4995412772592787655
10012320
334
233700618554818563
10012320
334
84352
5
45
[0.223, 0.956, 0.0, 0.048, 0.061, 0.007, 0.562...
[0.545, 1.177, 0.063, 0.793, 0.013, 0.055, 0.2...
233700618554818563
http://a.vpimg2.com/upload/merchandise/pdc/563...
[439740353870500018, 15839007868620828, 282239...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
17432
3673391202
433266429406154772
10021264
334
453532627729321984
10021264
334
3324
2
24
[0.117, 0.0, 0.126, 0.838, 0.32, 0.083, 0.117,...
[0.001, 1.004, 0.462, 0.862, 0.259, 0.192, 0.1...
453532627729321984
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[439740353870500018, 15839007868620828, 282239...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
17433
3673391202
450999316113584132
10021264
334
453532627729321984
10021264
334
4013
2
24
[0.117, 0.0, 0.126, 0.838, 0.32, 0.083, 0.117,...
[0.791, 1.814, 0.013, 0.438, 0.037, 0.0, 0.412...
453532627729321984
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[439740353870500018, 15839007868620828, 282239...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
17434
3673391202
4995412772592787655
10012320
334
453532627729321984
10021264
334
3416
2
24
[0.117, 0.0, 0.126, 0.838, 0.32, 0.083, 0.117,...
[0.545, 1.177, 0.063, 0.793, 0.013, 0.055, 0.2...
453532627729321984
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[439740353870500018, 15839007868620828, 282239...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
17435
3673391202
433266429406154772
10021264
334
456910280733184030
10012320
334
83174
4
51
[0.448, 2.32, 0.0, 0.182, 0.087, 0.0, 0.376, 1...
[0.001, 1.004, 0.462, 0.862, 0.259, 0.192, 0.1...
456910280733184030
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[5144594509986807823, 439740353870500018, 4535...
[0.2653, 0.9639, 0.1314, 0.9796, 0.1666, 0.129...
17436
3673391202
450999316113584132
10021264
334
456910280733184030
10012320
334
83863
4
51
[0.448, 2.32, 0.0, 0.182, 0.087, 0.0, 0.376, 1...
[0.791, 1.814, 0.013, 0.438, 0.037, 0.0, 0.412...
456910280733184030
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[5144594509986807823, 439740353870500018, 4535...
[0.2653, 0.9639, 0.1314, 0.9796, 0.1666, 0.129...
17437
3673391202
4995412772592787655
10012320
334
456910280733184030
10012320
334
83266
4
51
[0.448, 2.32, 0.0, 0.182, 0.087, 0.0, 0.376, 1...
[0.545, 1.177, 0.063, 0.793, 0.013, 0.055, 0.2...
456910280733184030
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[5144594509986807823, 439740353870500018, 4535...
[0.2653, 0.9639, 0.1314, 0.9796, 0.1666, 0.129...
17438
3673391202
433266429406154772
10021264
334
455221477589586090
10021264
334
3362
1
4
[0.023, 0.31, 0.271, 0.444, 0.353, 0.0, 1.217,...
[0.001, 1.004, 0.462, 0.862, 0.259, 0.192, 0.1...
455221477589586090
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[439740353870500018, 15839007868620828, 282239...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
17439
3673391202
450999316113584132
10021264
334
455221477589586090
10021264
334
4051
1
4
[0.023, 0.31, 0.271, 0.444, 0.353, 0.0, 1.217,...
[0.791, 1.814, 0.013, 0.438, 0.037, 0.0, 0.412...
455221477589586090
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[439740353870500018, 15839007868620828, 282239...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
17440
3673391202
4995412772592787655
10012320
334
455221477589586090
10021264
334
3454
1
4
[0.023, 0.31, 0.271, 0.444, 0.353, 0.0, 1.217,...
[0.545, 1.177, 0.063, 0.793, 0.013, 0.055, 0.2...
455221477589586090
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[439740353870500018, 15839007868620828, 282239...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
17441
3673391202
433266429406154772
10021264
334
9083613970694320
10012320
334
35886
2
8
[0.317, 0.707, 0.068, 1.711, 0.429, 0.101, 0.8...
[0.001, 1.004, 0.462, 0.862, 0.259, 0.192, 0.1...
9083613970694320
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[439740353870500018, 15839007868620828, 282239...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
17442
3673391202
450999316113584132
10021264
334
9083613970694320
10012320
334
36575
2
8
[0.317, 0.707, 0.068, 1.711, 0.429, 0.101, 0.8...
[0.791, 1.814, 0.013, 0.438, 0.037, 0.0, 0.412...
9083613970694320
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[439740353870500018, 15839007868620828, 282239...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
17443
3673391202
4995412772592787655
10012320
334
9083613970694320
10012320
334
35978
2
8
[0.317, 0.707, 0.068, 1.711, 0.429, 0.101, 0.8...
[0.545, 1.177, 0.063, 0.793, 0.013, 0.055, 0.2...
9083613970694320
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[439740353870500018, 15839007868620828, 282239...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
17444
3673391202
433266429406154772
10021264
334
28223939643359401
10012320
334
569644
2
13
[0.162, 1.513, 0.044, 0.483, 0.018, 0.608, 0.1...
[0.001, 1.004, 0.462, 0.862, 0.259, 0.192, 0.1...
28223939643359401
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[439740353870500018, 15839007868620828, 282239...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
17445
3673391202
450999316113584132
10021264
334
28223939643359401
10012320
334
570333
2
13
[0.162, 1.513, 0.044, 0.483, 0.018, 0.608, 0.1...
[0.791, 1.814, 0.013, 0.438, 0.037, 0.0, 0.412...
28223939643359401
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[439740353870500018, 15839007868620828, 282239...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
17446
3673391202
4995412772592787655
10012320
334
28223939643359401
10012320
334
569736
2
13
[0.162, 1.513, 0.044, 0.483, 0.018, 0.608, 0.1...
[0.545, 1.177, 0.063, 0.793, 0.013, 0.055, 0.2...
28223939643359401
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[439740353870500018, 15839007868620828, 282239...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
17447
3673391202
433266429406154772
10021264
334
11335441040720040
10012320
334
58881
1
6
[0.358, 1.042, 0.195, 3.888, 0.099, 0.124, 0.3...
[0.001, 1.004, 0.462, 0.862, 0.259, 0.192, 0.1...
11335441040720040
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[439740353870500018, 15839007868620828, 282239...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
17448
3673391202
450999316113584132
10021264
334
11335441040720040
10012320
334
59570
1
6
[0.358, 1.042, 0.195, 3.888, 0.099, 0.124, 0.3...
[0.791, 1.814, 0.013, 0.438, 0.037, 0.0, 0.412...
11335441040720040
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[439740353870500018, 15839007868620828, 282239...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
17449
3673391202
4995412772592787655
10012320
334
11335441040720040
10012320
334
58973
1
6
[0.358, 1.042, 0.195, 3.888, 0.099, 0.124, 0.3...
[0.545, 1.177, 0.063, 0.793, 0.013, 0.055, 0.2...
11335441040720040
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[439740353870500018, 15839007868620828, 282239...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
17450
3673391202
433266429406154772
10021264
334
439740353870500018
10021264
334
33150
2
10
[0.054, 1.812, 0.477, 0.545, 0.287, 0.0, 1.11,...
[0.001, 1.004, 0.462, 0.862, 0.259, 0.192, 0.1...
439740353870500018
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[439740353870500018, 15839007868620828, 282239...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
17451
3673391202
450999316113584132
10021264
334
439740353870500018
10021264
334
33839
2
10
[0.054, 1.812, 0.477, 0.545, 0.287, 0.0, 1.11,...
[0.791, 1.814, 0.013, 0.438, 0.037, 0.0, 0.412...
439740353870500018
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[439740353870500018, 15839007868620828, 282239...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
17452
3673391202
4995412772592787655
10012320
334
439740353870500018
10021264
334
33242
2
10
[0.054, 1.812, 0.477, 0.545, 0.287, 0.0, 1.11,...
[0.545, 1.177, 0.063, 0.793, 0.013, 0.055, 0.2...
439740353870500018
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[439740353870500018, 15839007868620828, 282239...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
17453
3673391202
433266429406154772
10021264
334
15839007868620828
10012320
334
83074
4
47
[0.499, 0.832, 0.099, 0.362, 0.062, 0.077, 0.2...
[0.001, 1.004, 0.462, 0.862, 0.259, 0.192, 0.1...
15839007868620828
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[439740353870500018, 15839007868620828, 282239...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
17454
3673391202
450999316113584132
10021264
334
15839007868620828
10012320
334
83763
4
47
[0.499, 0.832, 0.099, 0.362, 0.062, 0.077, 0.2...
[0.791, 1.814, 0.013, 0.438, 0.037, 0.0, 0.412...
15839007868620828
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[439740353870500018, 15839007868620828, 282239...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
17455
3673391202
4995412772592787655
10012320
334
15839007868620828
10012320
334
83166
4
47
[0.499, 0.832, 0.099, 0.362, 0.062, 0.077, 0.2...
[0.545, 1.177, 0.063, 0.793, 0.013, 0.055, 0.2...
15839007868620828
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[439740353870500018, 15839007868620828, 282239...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
17456
3673391202
433266429406154772
10021264
334
5144594509986807823
10021264
334
33371
2
15
[0.109, 0.653, 0.021, 1.039, 0.0, 0.298, 0.213...
[0.001, 1.004, 0.462, 0.862, 0.259, 0.192, 0.1...
5144594509986807823
http://a.vpimg2.com/upload/merchandise/pdc/823...
[439740353870500018, 15839007868620828, 282239...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
17457
3673391202
450999316113584132
10021264
334
5144594509986807823
10021264
334
34060
2
15
[0.109, 0.653, 0.021, 1.039, 0.0, 0.298, 0.213...
[0.791, 1.814, 0.013, 0.438, 0.037, 0.0, 0.412...
5144594509986807823
http://a.vpimg2.com/upload/merchandise/pdc/823...
[439740353870500018, 15839007868620828, 282239...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
17458
3673391202
4995412772592787655
10012320
334
5144594509986807823
10021264
334
33463
2
15
[0.109, 0.653, 0.021, 1.039, 0.0, 0.298, 0.213...
[0.545, 1.177, 0.063, 0.793, 0.013, 0.055, 0.2...
5144594509986807823
http://a.vpimg2.com/upload/merchandise/pdc/823...
[439740353870500018, 15839007868620828, 282239...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
17459
3673391202
450999316113584132
10021264
334
450999316113584132
10021264
334
0
11
66
[0.791, 1.814, 0.013, 0.438, 0.037, 0.0, 0.412...
[0.791, 1.814, 0.013, 0.438, 0.037, 0.0, 0.412...
450999316113584132
http://a.vpimg2.com/upload/merchandise/pdcvis/...
[439740353870500018, 15839007868620828, 282239...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
17460 rows × 16 columns
In [119]:
df_buy_user = df.groupby(['user_id', 'buy_spu', 'spu']).count().reset_index()[['user_id', 'buy_spu', 'spu']]
In [120]:
df_buy_user.shape
Out[120]:
(15785, 3)
In [124]:
df_buy_user.head()
Out[124]:
user_id
buy_spu
spu
0
3440325
2898705571343994880
952306123355361280
1
3440325
2898705571343994880
1374237151951519744
2
3440325
2898705571343994880
1392814500414361602
3
3440325
2898705571343994880
2462700831731142656
4
3440325
2898705571343994880
2462982307401474048
In [30]:
df_spu = pd.read_pickle('spu_CF_features.pkl')
In [31]:
df_spu.head()
Out[31]:
spu
CF_item
spu_features
CF_features
ave_CF_fea
0
357872333107204
[8952950888272863232, 1664156381170176000, 284...
[0.035, 0.385, 0.112, 0.014, 0.0, 0.123, 0.438...
[[[0.462, 0.551, 0.068, 0.833, 0.0, 0.0, 0.0, ...
[0.4269, 0.6321, 0.101, 0.9695, 0.2211, 0.131,...
1
357875526680651
[2046769978417582, 461413925257830545, 3255052...
[0.132, 1.678, 0.061, 0.918, 0.462, 0.342, 0.4...
[[[0.357, 2.503, 0.0, 0.641, 0.143, 0.0, 0.104...
[0.4727, 0.8078, 0.0697, 0.5796, 0.3075, 0.009...
2
357882254983171
[459725075493814272, 8582811288237465674, 1976...
[0.026, 0.936, 0.056, 0.614, 0.139, 0.0, 0.302...
[[[1.884, 0.52, 0.0, 3.98, 0.175, 0.008, 0.663...
[0.6206, 0.8754, 0.1066, 0.7549, 0.2387, 0.186...
3
357901107539985
[2466922956389351424, 8459806721299259392, 780...
[0.229, 0.543, 0.132, 0.144, 0.295, 0.018, 0.0...
[[[0.124, 0.819, 0.0, 0.596, 0.306, 0.043, 0.2...
[0.4016, 0.6379, 0.2088, 0.7764, 0.3335, 0.012...
4
639360131194904
[451843765076328474, 81141212316332372, 320394...
[1.113, 0.5, 0.758, 0.218, 0.0, 0.0, 0.335, 1....
[[[0.501, 0.12, 0.0, 0.0, 0.23, 0.108, 0.377, ...
[0.2916, 0.5296, 0.0964, 0.3321, 0.1873, 0.022...
In [14]:
def dot(K, L):
if len(K) != len(L): return 0
return sum(i[0]*i[1] for i in zip(K, L))
def similarity(item_1, item_2):
return dot(item_1, item_2) / np.sqrt(dot(item_1, item_1)*dot(item_2, item_2))
def average(lists):
return [np.mean(i) for i in zip(*[l for l in lists])]
In [138]:
CF_user_fea = df_cal.groupby(['user_id', 'buy_spu'])['ave_CF_fea'].apply(lambda x: average(x))
CF_user_fea = pd.DataFrame(CF_user_fea)
CF_user_fea = CF_user_fea.reset_index()
In [139]:
Ori_user_fea = df_cal.groupby(['user_id', 'buy_spu'])['spu_features'].apply(lambda x: average(x))
Ori_user_fea = pd.DataFrame(Ori_user_fea)
Ori_user_fea = Ori_user_fea.reset_index()
In [158]:
CF_user_fea.head()
Out[158]:
user_id
buy_spu
ave_CF_fea
0
3440325
2898705571343994880
[0.327609375, 0.573775, 0.11804375, 0.87390625...
1
7052311
7957699990364366
[0.307052173913, 0.738013043478, 0.06435217391...
2
7052311
299847271351230626
[0.306652173913, 0.7439, 0.0624434782609, 0.60...
3
7052311
448747521265074449
[0.306817391304, 0.735182608696, 0.06435217391...
4
9254280
3925244893201649664
[0.385093939394, 0.623651515152, 0.12763030303...
In [5]:
user_fea = pd.read_pickle('user_buy_CF_Ori_fea.pkl')
df_spu = pd.read_pickle('spu_CF_features.pkl')
In [169]:
user_fea.head()
Out[169]:
user_id
buy_spu
ave_CF_fea
ave_view_fea
0
3440325
2898705571343994880
[0.327609375, 0.573775, 0.11804375, 0.87390625...
[0.30521875, 0.5995625, 0.167625, 0.99259375, ...
1
7052311
7957699990364366
[0.307052173913, 0.738013043478, 0.06435217391...
[0.320739130435, 0.577217391304, 0.088, 0.6661...
2
7052311
299847271351230626
[0.306652173913, 0.7439, 0.0624434782609, 0.60...
[0.314217391304, 0.620695652174, 0.08865217391...
3
7052311
448747521265074449
[0.306817391304, 0.735182608696, 0.06435217391...
[0.323086956522, 0.60552173913, 0.088, 0.653, ...
4
9254280
3925244893201649664
[0.385093939394, 0.623651515152, 0.12763030303...
[0.356484848485, 0.575484848485, 0.11351515151...
In [171]:
df_spu.head()
Out[171]:
spu
CF_item
spu_features
CF_features
ave_CF_fea
0
357872333107204
[8952950888272863232, 1664156381170176000, 284...
[0.035, 0.385, 0.112, 0.014, 0.0, 0.123, 0.438...
[[[0.462, 0.551, 0.068, 0.833, 0.0, 0.0, 0.0, ...
[0.4269, 0.6321, 0.101, 0.9695, 0.2211, 0.131,...
1
357875526680651
[2046769978417582, 461413925257830545, 3255052...
[0.132, 1.678, 0.061, 0.918, 0.462, 0.342, 0.4...
[[[0.357, 2.503, 0.0, 0.641, 0.143, 0.0, 0.104...
[0.4727, 0.8078, 0.0697, 0.5796, 0.3075, 0.009...
2
357882254983171
[459725075493814272, 8582811288237465674, 1976...
[0.026, 0.936, 0.056, 0.614, 0.139, 0.0, 0.302...
[[[1.884, 0.52, 0.0, 3.98, 0.175, 0.008, 0.663...
[0.6206, 0.8754, 0.1066, 0.7549, 0.2387, 0.186...
3
357901107539985
[2466922956389351424, 8459806721299259392, 780...
[0.229, 0.543, 0.132, 0.144, 0.295, 0.018, 0.0...
[[[0.124, 0.819, 0.0, 0.596, 0.306, 0.043, 0.2...
[0.4016, 0.6379, 0.2088, 0.7764, 0.3335, 0.012...
4
639360131194904
[451843765076328474, 81141212316332372, 320394...
[1.113, 0.5, 0.758, 0.218, 0.0, 0.0, 0.335, 1....
[[[0.501, 0.12, 0.0, 0.0, 0.23, 0.108, 0.377, ...
[0.2916, 0.5296, 0.0964, 0.3321, 0.1873, 0.022...
In [47]:
user_fea['ave_Ori_sim_rank']= user_fea.apply(lambda x: sim_cal(x['buy_spu'],x['ave_view_fea']), axis = 1)
2898705571343994880
7957699990364366
299847271351230626
448747521265074449
3925244893201649664
453532609002410015
4420359388939563031
25690665644495446
4766573611946106883
2823270277605580800
2909964570461929472
4411070714708987927
6926894069614792705
2482122605837119488
2886883622319759360
2913060795180240896
2823270277605580800
2832277476150169600
24001769421647872
2896735246507962368
314483964450287810
1392814500414406660
4397841390802718742
2463545257346113536
7804814445850251264
4070767462512406529
6926894069614792705
2895890821597048832
2474241306483101696
4210379050958020608
2457352807885774848
7018373437045764097
6787001004303990784
4131566057481908225
4612888274761371649
25690661432709125
301817568529408000
4401500565499949068
80015314527277239
290840078882562181
2484655880651984896
449591938442985580
454095538070356542
8664720590950785055
447621605798383646
13868682270638081
2615260342006214656
2829462726381260800
2913060795180240896
2913905219381506048
2481559655864078338
4617954825743179776
24564714406731779
7072416533847396352
4411070714708987927
33853423336108046
9022475203247398916
103096245561765919
1102895235895451648
4121995912075198481
6370980984573702144
84800366075408747
8955484164140015617
2900675896205930496
2882942971953520640
2835936651544625153
2810603903655137280
4120588537191645191
29631292293525510
8897500320610353152
6268857552375823
33008983447224321
2472552456653385728
3534839098272604327
7113270818979840
306321168550178838
4425707413094748161
81704161896398877
2480715230932934656
2898987046254485504
4057256663630299136
4210379050958020608
2450315932750196736
2889416897109704704
4209253154853183512
2891105746980835328
2463545257346113536
2898705571343994880
3735622055772162
2898705571343994880
4210379050958020608
1608142860794818562
2471426556005482496
33290487503762307
448184566666743834
2453130682530897920
4641880197364293632
2465797056472944640
941328597468446721
2457634282835726336
2893639021767663616
2463545257346113536
3925244893201649664
33571915871158274
80015338899632133
1102050800015937536
2885476247461195776
20905574407417865
2836218125824516096
2893639021813923840
4209253154853183622
2474241306483101696
2917845869811523584
6370980984573702144
2462700832436764672
2832840426724958208
2823270277605580800
2835655176583352320
324335591819321344
467606353885155328
2480715230945681408
2914749645016145920
304913827234218339
2909964570434449408
2882661497718759424
4483128308343681024
2834810751655301120
2455663958026235904
2482122605837119488
2819048152931336192
8939440090467495945
305476758874669060
448184566666743834
4641880197364293632
9023882578131013643
2457634282835726336
16964899245101247
6658929891786235905
317580194884001797
454095538070356542
14713103652732928
2456508382980710400
9009808829295501323
2469456231166840832
4328035596179238913
6658929891786235905
20905574407417865
290840072096489614
441710668753739784
29631282732392488
4185609256809488410
4419233488633495552
439740313581539337
8312876783452364800
2886883622319759360
5136713209119145991
3317258936357195776
6936182741965369345
6926894069614792705
97185265860571162
2844662375769276416
964128041583173632
1110495040348078080
8596322085984735235
2818203727958560768
455784430413111323
2827492402281959424
2469456231166840832
1394503350274605056
2821581427656675328
4420640863513980929
1319349531493003264
2455663958026235904
2458760182748074014
1044066957634990080
4139447361057607680
9016845703713148936
7804814445850251264
8965054312271417351
4042338493666074811
4184764831879356439
6946597315984179204
81141212316332372
10209526705188864
447340141736616133
3773248405777813504
443680973169201302
2474241306483101696
2910246045436305408
4617954825743179776
2474241306483101696
2478744906087714816
2896735246507962368
8587877837788569600
81141212316332186
2916157019922952192
3822225051725512705
2889416897109704704
289151240576786489
2474241306483101696
2484655880651984896
2823270277605580800
4483128308343681024
2186292466476613633
2470300656796913664
8749726033542725633
2484374405561708544
74104361364131879
76637636154437685
6948567640935903232
2831996001169256448
2913060795180240896
3822225051725512705
103659233471074440
299847272467533834
2596401518566629376
2889416897109704704
2819892577884098560
8014231828833280000
1686111429343629315
2833684851741020160
4397841390802718742
2474241306483101696
10772464198488196
2474241305768906752
2474241305768906752
4975990997870936065
2457634282773123072
4038116369015414943
2813418653354196992
7804814445850251264
4425425938521231387
357872333107204
1664156381170176000
4324939371432370177
4137758510770995353
33008983447224321
319550534912245928
462539783031898125
2913060795180240896
4419233488633495552
8889056064286547973
1397318100041764864
5143468608560205901
32446069680255002
2450315932750196736
2480996705858625536
4411070714708987927
2466641482094837760
2893076071857147904
4413041039545094157
9038237806216196097
2906586870625374208
2818203727958560768
2893076071857147904
2484374405561708544
18935241846497283
309417417811898397
316735767206387720
2833684851770585088
2813418653354196992
4139447360631259140
25972089290305537
2484655880651984896
4411070714708987927
2908275720576577536
4324939371432370177
8875826745730871302
8949854659256020992
2484374405561708544
2813418653354196992
2474241306483101696
298439895330443294
1037874485481308160
3255897391495548929
82830090185703432
4414166939451928680
8878078545544585221
2458760182748074014
87896619178790912
309980370512814101
4046560614515265536
4069923037579415556
4401500565499949068
106755436261761039
448747540332511261
6926894069614792705
8964209883068268545
4053034538976768004
436644093725405288
2828899777145090048
29349802448457744
288588246810169862
1450798345616744449
7072416533847396352
2457352807885774848
2484655880651984896
7804814445850251264
3749604510847725568
4210379054760026274
2907149820696469504
292810390699348239
966661327701807104
2885194772466008065
2893639021767663616
2916157019922952192
2913060795180240896
77763540604911625
7598774842158772224
2844380900890853376
7233138844953759746
7567249644181057536
4060352892175556947
450154916332462095
3773248405777813504
299847271351230626
8935499435443806210
313921037505220642
441710676888072337
4137758510770995353
4058101092361871515
457754723082887173
2626800816051441664
2474241306483101696
2913905219381506048
450154916332462095
2823270277605580800
11898368760758320
938232376982429699
944706261467725824
1030556121231585280
8949291790987165704
2457634282835726336
2845506800768520192
8969839382602473480
2482122605837119488
6154526728502591488
2913060795162099712
2474241306483101696
2897861146460422144
8889056064286547973
4411070714708987927
22875915877388897
7113270818979840
311950695321739505
1103458172424577024
4351960970611486720
5131365184561647625
4401500565499949068
5120950610423349260
5143468608560205901
2482685555087273984
324054133432799257
319269038510153919
440021810120298856
2894764921674170372
4137758510770995353
105629563299266567
4057256663630299136
8970402337905655820
4070767462512406529
5136713209119145991
2466641482094837760
28786848266952914
97185296913813714
2823270277589291009
2885194772466008065
8970120857579282441
8679075730235432960
4411070714708987927
2834810751636877312
105629563299266567
4209253154853183622
1319349531493003264
357901107539985
4425707413094748161
103096277526925322
105066597356617783
319550539589550085
2812574228476923904
2840721726144196608
2482122605860892672
2450316005653835777
2478463503324852224
2896735246507962368
2898705571343994880
2842692050274074624
2841566150393516033
3772403980847677440
2822425851950043136
4428803637838594048
5003857020565307395
2480715230932934656
2899831471252246528
2821581427656675328
1392814500414406660
32727488731291654
2823270277589291009
2885476247461195776
2902083271113252864
2910246045436305408
8891307868373221383
20061123988918473
97185296913813714
2835655176583352320
4040931118782521514
2813418653354196992
2626800816051441664
2463545257346113536
9646579213860870
8965054312271417351
8955202689163296780
4064012066872795411
8897218838611165185
445369815557148672
2463545257346113536
2844662375769276416
8957173008650510337
9026697332171030534
2466641482094837760
444525426755584009
2484374405561708544
2815951928211386368
433266429406154772
450999316113584132
4995412772592787655
1608142860794818562
2893076071119843328
4641880197364293632
2821862902701461504
2895890821597048832
9008401454411841539
7930915235726753792
444525426755584009
446777176556679168
2458760182748074014
5135305834235592713
972290827227131904
2810603903655137280
324054143798079494
4706619441972056064
2841847626098278400
2893076071119843328
8440666422881349632
450717878632677464
444243941831672034
465073060372287493
1615461210189242372
7653099516274397185
2893639021767663616
2456508382980710400
2823270277605580800
74104361364004926
447058691588489219
4411070714708987927
4040931118782521514
2835936651544625153
91837265020604424
309417401847623994
322365288165343239
4210379050958020608
2838188451373400064
4989783271729762305
299847247939522560
2898705571343994880
7379787313888362497
2833684851742179328
9090592232181542912
463665709926023172
4617954825743179776
1102895235895451648
7069883259058081792
456065900700315688
2885476247461195776
2818203727958560768
80578231855935488
1397036625065005056
2831996001169256448
82830090185703432
4328035596179238913
1400132849808887809
938513825156079641
4411070714708987927
2815951928211386368
9039645182176481286
357901107539985
2835655176583352320
2842129100334465024
7067349984266096640
4209253151051174020
2463545257346113536
2595275618659840000
2835936651544625153
74104320184119307
438895881520357521
453532580309307392
4617954825743179776
440866242101010448
4413885464477257729
298721359433613314
4132691957822554112
2890824271308562432
In [4]:
# Calculate similarity and ranking, return the final result for each buy item.
def sim_cal(buy_item, item):
df_spu['sim'] = df_spu.apply(lambda x: similarity(x['spu_features'], item), axis = 1)
df_spu['rank'] = df_spu['sim'].rank(ascending=False)
print user
return (df_spu[df_spu['spu'] == buy_item]['sim'], df_spu[df_spu['spu'] == buy_item]['rank'])
In [38]:
df_spu.head()
Out[38]:
spu
CF_item
spu_features
CF_features
ave_CF_fea
sim
rank
0
357872333107204
[8952950888272863232, 1664156381170176000, 284...
[0.035, 0.385, 0.112, 0.014, 0.0, 0.123, 0.438...
[[[0.462, 0.551, 0.068, 0.833, 0.0, 0.0, 0.0, ...
[0.4269, 0.6321, 0.101, 0.9695, 0.2211, 0.131,...
0.787449
632.0
1
357875526680651
[2046769978417582, 461413925257830545, 3255052...
[0.132, 1.678, 0.061, 0.918, 0.462, 0.342, 0.4...
[[[0.357, 2.503, 0.0, 0.641, 0.143, 0.0, 0.104...
[0.4727, 0.8078, 0.0697, 0.5796, 0.3075, 0.009...
0.690612
1561.0
2
357882254983171
[459725075493814272, 8582811288237465674, 1976...
[0.026, 0.936, 0.056, 0.614, 0.139, 0.0, 0.302...
[[[1.884, 0.52, 0.0, 3.98, 0.175, 0.008, 0.663...
[0.6206, 0.8754, 0.1066, 0.7549, 0.2387, 0.186...
0.754448
965.0
3
357901107539985
[2466922956389351424, 8459806721299259392, 780...
[0.229, 0.543, 0.132, 0.144, 0.295, 0.018, 0.0...
[[[0.124, 0.819, 0.0, 0.596, 0.306, 0.043, 0.2...
[0.4016, 0.6379, 0.2088, 0.7764, 0.3335, 0.012...
0.692096
1544.0
4
639360131194904
[451843765076328474, 81141212316332372, 320394...
[1.113, 0.5, 0.758, 0.218, 0.0, 0.0, 0.335, 1....
[[[0.501, 0.12, 0.0, 0.0, 0.23, 0.108, 0.377, ...
[0.2916, 0.5296, 0.0964, 0.3321, 0.1873, 0.022...
0.665405
1752.0
In [34]:
df_spu.head()
Out[34]:
spu
CF_item
spu_features
CF_features
ave_CF_fea
sim
rank
0
357872333107204
[8952950888272863232, 1664156381170176000, 284...
[0.035, 0.385, 0.112, 0.014, 0.0, 0.123, 0.438...
[[[0.462, 0.551, 0.068, 0.833, 0.0, 0.0, 0.0, ...
[0.4269, 0.6321, 0.101, 0.9695, 0.2211, 0.131,...
0.787449
632.0
1
357875526680651
[2046769978417582, 461413925257830545, 3255052...
[0.132, 1.678, 0.061, 0.918, 0.462, 0.342, 0.4...
[[[0.357, 2.503, 0.0, 0.641, 0.143, 0.0, 0.104...
[0.4727, 0.8078, 0.0697, 0.5796, 0.3075, 0.009...
0.690612
1561.0
2
357882254983171
[459725075493814272, 8582811288237465674, 1976...
[0.026, 0.936, 0.056, 0.614, 0.139, 0.0, 0.302...
[[[1.884, 0.52, 0.0, 3.98, 0.175, 0.008, 0.663...
[0.6206, 0.8754, 0.1066, 0.7549, 0.2387, 0.186...
0.754448
965.0
3
357901107539985
[2466922956389351424, 8459806721299259392, 780...
[0.229, 0.543, 0.132, 0.144, 0.295, 0.018, 0.0...
[[[0.124, 0.819, 0.0, 0.596, 0.306, 0.043, 0.2...
[0.4016, 0.6379, 0.2088, 0.7764, 0.3335, 0.012...
0.692096
1544.0
4
639360131194904
[451843765076328474, 81141212316332372, 320394...
[1.113, 0.5, 0.758, 0.218, 0.0, 0.0, 0.335, 1....
[[[0.501, 0.12, 0.0, 0.0, 0.23, 0.108, 0.377, ...
[0.2916, 0.5296, 0.0964, 0.3321, 0.1873, 0.022...
0.665405
1752.0
In [221]:
a = sim_cal(3440325, user_fea['ave_CF_fea'][0])
3440325
In [18]:
df_spu
Out[18]:
user_id
view_spu
spu
CF_item
spu_features_x
CF_features
ave_CF_fea_x
CF_user_features
Ori_user_features
0
3440325
952306123355361280
952306123355361280
[2626800816051441664, 107318408860868627, 8886...
[0.631, 1.654, 0.0, 0.253, 0.041, 0.0, 0.103, ...
[[[0.392, 0.326, 0.0, 0.076, 0.171, 0.009, 0.0...
[0.4213, 0.6232, 0.2287, 0.7885, 0.1946, 0.047...
[0.327609375, 0.573775, 0.11804375, 0.87390625...
[0.30521875, 0.5995625, 0.167625, 0.99259375, ...
1
3440325
1374237151951519744
1374237151951519744
[3773248405777813504, 2452849208253480960, 570...
[0.276, 0.458, 0.0, 0.234, 0.062, 0.023, 0.458...
[[[0.166, 0.366, 0.0, 0.075, 0.058, 0.294, 0.5...
[0.2671, 0.4109, 0.0948, 0.6352, 0.1639, 0.120...
[0.327609375, 0.573775, 0.11804375, 0.87390625...
[0.30521875, 0.5995625, 0.167625, 0.99259375, ...
2
3440325
1392814500414361602
1392814500414361602
[18935228309520387, 2531099323969781760, 24694...
[1.066, 0.992, 0.004, 0.868, 0.169, 0.389, 0.1...
[[[0.902, 0.444, 0.0, 0.236, 0.075, 0.259, 0.3...
[0.4135, 0.4454, 0.0279, 1.3677, 0.2129, 0.093...
[0.327609375, 0.573775, 0.11804375, 0.87390625...
[0.30521875, 0.5995625, 0.167625, 0.99259375, ...
3
3440325
2462700831731142656
2462700831731142656
[2825803552328679424, 1397036625065005056, 290...
[0.2, 0.231, 0.302, 0.536, 0.064, 0.0, 0.261, ...
[[[0.318, 0.811, 0.003, 0.248, 0.016, 0.016, 0...
[0.5295, 0.539, 0.1045, 0.9142, 0.1462, 0.0491...
[0.327609375, 0.573775, 0.11804375, 0.87390625...
[0.30521875, 0.5995625, 0.167625, 0.99259375, ...
4
3440325
2462982307401474048
2462982307401474048
[2478463431161782272, 2813981603399778304, 284...
[0.177, 0.029, 0.036, 0.558, 0.393, 0.059, 0.2...
[[[0.146, 0.576, 0.498, 1.403, 0.082, 0.009, 0...
[0.1984, 0.5322, 0.296, 1.4349, 0.4927, 0.0944...
[0.327609375, 0.573775, 0.11804375, 0.87390625...
[0.30521875, 0.5995625, 0.167625, 0.99259375, ...
5
3440325
2467767382049587200
2467767382049587200
[4048530939349401602, 4418107589125877775, 439...
[0.0, 0.345, 0.464, 1.119, 0.452, 0.0, 0.162, ...
[[[0.173, 0.102, 0.096, 0.694, 0.017, 0.062, 0...
[0.4394, 1.0768, 0.1263, 0.7698, 0.3109, 0.124...
[0.327609375, 0.573775, 0.11804375, 0.87390625...
[0.30521875, 0.5995625, 0.167625, 0.99259375, ...
6
3440325
2474241305768906752
2474241305768906752
[7016121635473047552, 1764924422095110144, 116...
[0.146, 0.976, 0.109, 0.529, 0.063, 0.0, 0.151...
[[[0.479, 0.745, 0.0, 2.47, 0.097, 0.066, 0.01...
[0.2691, 0.6029, 0.0289, 0.5591, 0.0743, 0.071...
[0.327609375, 0.573775, 0.11804375, 0.87390625...
[0.30521875, 0.5995625, 0.167625, 0.99259375, ...
7
3440325
2478463431161782272
2478463431161782272
[31320122316476689, 8865130696615878658, 24621...
[0.146, 0.576, 0.498, 1.403, 0.082, 0.009, 0.0...
[[[0.215, 0.422, 0.789, 1.681, 0.27, 0.006, 0....
[0.5018, 0.4025, 0.1455, 1.1491, 0.2165, 0.043...
[0.327609375, 0.573775, 0.11804375, 0.87390625...
[0.30521875, 0.5995625, 0.167625, 0.99259375, ...
8
3440325
2479589331069046784
2479589331069046784
[82548606340628534, 449028976141545475, 246101...
[0.155, 1.389, 0.093, 0.926, 0.0, 0.06, 0.551,...
[[[0.082, 0.086, 0.025, 0.733, 0.102, 0.182, 0...
[0.3344, 0.3601, 0.1528, 0.7989, 0.3655, 0.088...
[0.327609375, 0.573775, 0.11804375, 0.87390625...
[0.30521875, 0.5995625, 0.167625, 0.99259375, ...
9
3440325
2482685555087273984
2482685555087273984
[2905742445755158528, 2906305395717189632, 247...
[0.142, 1.404, 0.044, 1.097, 0.375, 0.004, 0.1...
[[[0.191, 0.539, 0.0, 3.064, 0.279, 0.0, 0.069...
[0.3034, 0.9874, 0.0313, 1.1108, 0.2176, 0.105...
[0.327609375, 0.573775, 0.11804375, 0.87390625...
[0.30521875, 0.5995625, 0.167625, 0.99259375, ...
10
3440325
2813981603399778304
2813981603399778304
[1382681401252843521, 6926894069614792705, 836...
[0.009, 0.633, 0.791, 1.907, 0.136, 0.299, 0.1...
[[[0.255, 1.02, 0.104, 1.042, 0.101, 0.0, 0.31...
[0.1615, 0.3986, 0.0944, 0.6446, 0.2418, 0.078...
[0.327609375, 0.573775, 0.11804375, 0.87390625...
[0.30521875, 0.5995625, 0.167625, 0.99259375, ...
11
3440325
2818203727958560768
2818203727958560768
[33853442734501940, 8434755448369840128, 21727...
[0.036, 0.257, 0.297, 0.502, 0.737, 0.133, 0.2...
[[[0.369, 0.419, 0.017, 0.215, 0.027, 0.0, 0.0...
[0.402, 0.5584, 0.0736, 0.5723, 0.1944, 0.1441...
[0.327609375, 0.573775, 0.11804375, 0.87390625...
[0.30521875, 0.5995625, 0.167625, 0.99259375, ...
12
3440325
2832840426724958208
2832840426724958208
[357901107539985, 2466922956389351424, 2893639...
[0.448, 0.956, 0.0, 0.595, 0.006, 0.0, 0.0, 0....
[[[0.229, 0.543, 0.132, 0.144, 0.295, 0.018, 0...
[0.2371, 0.5816, 0.135, 0.5578, 0.1168, 0.0573...
[0.327609375, 0.573775, 0.11804375, 0.87390625...
[0.30521875, 0.5995625, 0.167625, 0.99259375, ...
13
3440325
2833684851741020160
2833684851741020160
[8379867827911725056, 9022475203247398916, 137...
[0.318, 0.091, 0.12, 1.281, 0.104, 0.0, 0.079,...
[[[0.244, 0.285, 0.014, 0.0, 0.026, 0.172, 0.0...
[0.2194, 0.6747, 0.1041, 0.3989, 0.0962, 0.022...
[0.327609375, 0.573775, 0.11804375, 0.87390625...
[0.30521875, 0.5995625, 0.167625, 0.99259375, ...
14
3440325
2833684851770585088
2833684851770585088
[2830870101950308352, 73822851882692620, 30435...
[0.104, 0.474, 0.554, 1.32, 0.257, 0.12, 0.199...
[[[0.095, 0.286, 0.164, 2.238, 0.189, 0.01, 0....
[0.1338, 0.5107, 0.2366, 0.922, 0.4176, 0.0987...
[0.327609375, 0.573775, 0.11804375, 0.87390625...
[0.30521875, 0.5995625, 0.167625, 0.99259375, ...
15
3440325
2835936651544625153
2835936651544625153
[26535057988575267, 31320122316476689, 2830870...
[0.163, 0.56, 0.154, 0.728, 0.705, 0.02, 0.407...
[[[0.193, 1.084, 0.005, 0.081, 0.18, 0.026, 0....
[0.1611, 0.5368, 0.3609, 0.8776, 0.328, 0.039,...
[0.327609375, 0.573775, 0.11804375, 0.87390625...
[0.30521875, 0.5995625, 0.167625, 0.99259375, ...
16
3440325
2888009522276044800
2888009522276044800
[9365079101353988, 8874700921228554241, 779890...
[0.359, 0.1, 0.0, 1.635, 0.391, 0.021, 0.175, ...
[[[0.347, 1.647, 0.301, 1.77, 0.284, 0.008, 0....
[0.2119, 0.6495, 0.1479, 1.0346, 0.2345, 0.049...
[0.327609375, 0.573775, 0.11804375, 0.87390625...
[0.30521875, 0.5995625, 0.167625, 0.99259375, ...
17
3440325
2888853946481188864
2888853946481188864
[2889416897109704704, 2470300656796913664, 288...
[0.641, 0.096, 0.0, 1.348, 0.056, 0.146, 0.04,...
[[[0.185, 0.789, 0.0, 3.742, 0.117, 0.221, 0.3...
[0.5381, 0.5522, 0.1453, 1.1083, 0.3045, 0.043...
[0.327609375, 0.573775, 0.11804375, 0.87390625...
[0.30521875, 0.5995625, 0.167625, 0.99259375, ...
18
3440325
2897861146460422144
2897861146460422144
[4791624884973387776, 8965054312271417351, 248...
[0.437, 0.568, 0.185, 1.126, 0.171, 0.013, 0.2...
[[[0.2, 0.724, 0.099, 0.215, 0.444, 0.018, 0.0...
[0.2722, 0.4898, 0.0601, 0.5275, 0.2766, 0.086...
[0.327609375, 0.573775, 0.11804375, 0.87390625...
[0.30521875, 0.5995625, 0.167625, 0.99259375, ...
19
3440325
2898705571343994880
2898705571343994880
[4984998197125672960, 1374237151951519744, 461...
[0.356, 0.226, 0.0, 0.289, 0.0, 0.108, 0.033, ...
[[[0.023, 0.72, 0.048, 1.864, 0.05, 0.059, 0.0...
[0.1447, 0.595, 0.0917, 0.553, 0.2508, 0.0339,...
[0.327609375, 0.573775, 0.11804375, 0.87390625...
[0.30521875, 0.5995625, 0.167625, 0.99259375, ...
20
3440325
2907149820696469504
2907149820696469504
[2902364745340342272, 2882661497718759424, 290...
[0.0, 0.07, 0.206, 0.866, 1.489, 0.0, 0.295, 0...
[[[0.005, 0.116, 0.053, 0.944, 0.899, 0.025, 0...
[0.2627, 0.5318, 0.0958, 0.8049, 0.337, 0.0259...
[0.327609375, 0.573775, 0.11804375, 0.87390625...
[0.30521875, 0.5995625, 0.167625, 0.99259375, ...
21
3440325
2910246045436305408
2910246045436305408
[9037674851989819400, 8891307868373221383, 514...
[0.369, 0.123, 0.502, 0.676, 0.062, 0.146, 0.0...
[[[1.315, 0.858, 0.031, 2.212, 0.165, 0.041, 0...
[0.6026, 0.9288, 0.0313, 0.9132, 0.1303, 0.041...
[0.327609375, 0.573775, 0.11804375, 0.87390625...
[0.30521875, 0.5995625, 0.167625, 0.99259375, ...
22
3440325
4210379050958020608
4210379050958020608
[2477619006234062848, 1683296679586492416, 260...
[0.246, 0.156, 0.0, 0.445, 0.0, 0.0, 0.228, 0....
[[[0.258, 0.513, 0.222, 0.793, 0.0, 0.018, 0.6...
[0.3776, 0.6246, 0.107, 0.9195, 0.1724, 0.121,...
[0.327609375, 0.573775, 0.11804375, 0.87390625...
[0.30521875, 0.5995625, 0.167625, 0.99259375, ...
23
3440325
4402344990027759740
4402344990027759740
[2834810751655301120, 10490965571211268, 28134...
[0.296, 0.877, 0.218, 0.762, 0.12, 0.0, 0.287,...
[[[0.681, 0.656, 0.002, 1.893, 0.518, 0.403, 0...
[0.5198, 0.5066, 0.0748, 1.8006, 0.2601, 0.18,...
[0.327609375, 0.573775, 0.11804375, 0.87390625...
[0.30521875, 0.5995625, 0.167625, 0.99259375, ...
24
3440325
4617954825743179776
4617954825743179776
[2454256583135850496, 82548606340628534, 24815...
[0.516, 0.359, 0.057, 1.836, 0.135, 0.046, 0.0...
[[[0.925, 0.324, 0.006, 0.806, 0.148, 0.07, 0....
[0.4451, 0.5159, 0.0397, 1.1986, 0.1909, 0.095...
[0.327609375, 0.573775, 0.11804375, 0.87390625...
[0.30521875, 0.5995625, 0.167625, 0.99259375, ...
25
3440325
6370980984573702144
6370980984573702144
[3751856307547738112, 3919896868644163585, 293...
[0.215, 0.566, 0.0, 0.193, 0.131, 0.003, 0.049...
[[[0.239, 0.194, 0.033, 1.028, 0.387, 0.0, 0.5...
[0.2909, 0.6154, 0.0359, 0.6726, 0.2104, 0.027...
[0.327609375, 0.573775, 0.11804375, 0.87390625...
[0.30521875, 0.5995625, 0.167625, 0.99259375, ...
26
3440325
7067349984266096640
7067349984266096640
[2842129100334465024, 8748037099529564160, 454...
[0.067, 2.088, 0.356, 0.353, 0.0, 0.0, 0.063, ...
[[[0.015, 0.306, 0.108, 0.529, 0.815, 0.0, 0.0...
[0.3972, 0.3939, 0.0771, 1.0561, 0.3029, 0.124...
[0.327609375, 0.573775, 0.11804375, 0.87390625...
[0.30521875, 0.5995625, 0.167625, 0.99259375, ...
27
3440325
8748037099529564160
8748037099529564160
[7650566158662352896, 322083767632121856, 3085...
[0.337, 0.365, 0.327, 2.561, 0.055, 0.029, 0.0...
[[[0.211, 0.184, 0.684, 0.902, 0.293, 0.0, 0.3...
[0.1998, 0.4616, 0.1685, 0.7098, 0.1504, 0.017...
[0.327609375, 0.573775, 0.11804375, 0.87390625...
[0.30521875, 0.5995625, 0.167625, 0.99259375, ...
28
3440325
8880048865031782401
8880048865031782401
[29068318645403648, 4762070012410028032, 22594...
[0.19, 0.636, 0.0, 0.823, 0.037, 0.0, 0.0, 1.7...
[[[0.132, 0.085, 0.135, 0.399, 0.191, 0.022, 0...
[0.3028, 0.5953, 0.0484, 0.5979, 0.1877, 0.032...
[0.327609375, 0.573775, 0.11804375, 0.87390625...
[0.30521875, 0.5995625, 0.167625, 0.99259375, ...
29
3440325
8884270989682438144
8884270989682438144
[2914749645016145920, 8513287054947958785, 174...
[0.102, 0.733, 0.016, 0.553, 0.0, 0.554, 0.11,...
[[[0.054, 0.04, 0.031, 0.101, 0.003, 0.175, 0....
[0.4666, 0.2496, 0.1716, 0.4442, 0.2748, 0.156...
[0.327609375, 0.573775, 0.11804375, 0.87390625...
[0.30521875, 0.5995625, 0.167625, 0.99259375, ...
...
...
...
...
...
...
...
...
...
...
12748
3850083334
90711384989950008
90711384989950008
[11616913604988929, 90711384989950008, 9465203...
[0.164, 0.505, 0.002, 0.133, 0.002, 0.047, 0.4...
[[[0.0, 0.712, 0.059, 0.002, 0.021, 0.006, 1.0...
[0.3111, 1.2012, 0.0353, 0.3724, 0.1363, 0.109...
[0.309531707317, 1.14683658537, 0.038948780487...
[0.436902439024, 1.0433902439, 0.0373902439024...
12749
3850083334
94652034663977078
94652034663977078
[11616913604988929, 90711384989950008, 9465203...
[0.645, 2.036, 0.0, 0.482, 0.183, 0.0, 0.689, ...
[[[0.0, 0.712, 0.059, 0.002, 0.021, 0.006, 1.0...
[0.3111, 1.2012, 0.0353, 0.3724, 0.1363, 0.109...
[0.309531707317, 1.14683658537, 0.038948780487...
[0.436902439024, 1.0433902439, 0.0373902439024...
12750
3850083334
94652034664017923
94652034664017923
[11616913604988929, 90711384989950008, 9465203...
[0.899, 0.608, 0.02, 0.789, 0.056, 0.0, 0.273,...
[[[0.0, 0.712, 0.059, 0.002, 0.021, 0.006, 1.0...
[0.3111, 1.2012, 0.0353, 0.3724, 0.1363, 0.109...
[0.309531707317, 1.14683658537, 0.038948780487...
[0.436902439024, 1.0433902439, 0.0373902439024...
12751
3850083334
98592684337909783
98592684337909783
[11616913604988929, 90711384989950008, 9465203...
[0.142, 1.038, 0.0, 0.318, 0.159, 0.024, 0.328...
[[[0.0, 0.712, 0.059, 0.002, 0.021, 0.006, 1.0...
[0.3111, 1.2012, 0.0353, 0.3724, 0.1363, 0.109...
[0.309531707317, 1.14683658537, 0.038948780487...
[0.436902439024, 1.0433902439, 0.0373902439024...
12752
3850083334
100844484151509052
100844484151509052
[11616913604988929, 90711384989950008, 9465203...
[0.031, 0.568, 0.0, 0.026, 0.316, 0.0, 0.228, ...
[[[0.0, 0.712, 0.059, 0.002, 0.021, 0.006, 1.0...
[0.3111, 1.2012, 0.0353, 0.3724, 0.1363, 0.109...
[0.309531707317, 1.14683658537, 0.038948780487...
[0.436902439024, 1.0433902439, 0.0373902439024...
12753
3850083334
100844484151595034
100844484151595034
[11616913604988929, 90711384989950008, 9465203...
[0.206, 0.348, 0.097, 0.197, 0.503, 0.062, 0.5...
[[[0.0, 0.712, 0.059, 0.002, 0.021, 0.006, 1.0...
[0.3111, 1.2012, 0.0353, 0.3724, 0.1363, 0.109...
[0.309531707317, 1.14683658537, 0.038948780487...
[0.436902439024, 1.0433902439, 0.0373902439024...
12754
3850083334
103096283965345803
103096283965345803
[11616913604988929, 90711384989950008, 9465203...
[0.433, 0.338, 0.0, 0.687, 0.09, 0.042, 0.324,...
[[[0.0, 0.712, 0.059, 0.002, 0.021, 0.006, 1.0...
[0.3111, 1.2012, 0.0353, 0.3724, 0.1363, 0.109...
[0.309531707317, 1.14683658537, 0.038948780487...
[0.436902439024, 1.0433902439, 0.0373902439024...
12755
3850083334
105911033732436052
105911033732436052
[11616913604988929, 90711384989950008, 9465203...
[0.178, 0.609, 0.0, 0.688, 0.012, 0.022, 0.114...
[[[0.0, 0.712, 0.059, 0.002, 0.021, 0.006, 1.0...
[0.3111, 1.2012, 0.0353, 0.3724, 0.1363, 0.109...
[0.309531707317, 1.14683658537, 0.038948780487...
[0.436902439024, 1.0433902439, 0.0373902439024...
12756
3850083334
107036933639155767
107036933639155767
[11616913604988929, 90711384989950008, 9465203...
[0.274, 1.165, 0.044, 0.139, 0.166, 0.344, 0.0...
[[[0.0, 0.712, 0.059, 0.002, 0.021, 0.006, 1.0...
[0.3111, 1.2012, 0.0353, 0.3724, 0.1363, 0.109...
[0.309531707317, 1.14683658537, 0.038948780487...
[0.436902439024, 1.0433902439, 0.0373902439024...
12757
3850083334
290277140899606590
290277140899606590
[11616913604988929, 90711384989950008, 9465203...
[0.259, 0.903, 0.151, 0.411, 0.049, 0.223, 0.3...
[[[0.0, 0.712, 0.059, 0.002, 0.021, 0.006, 1.0...
[0.3111, 1.2012, 0.0353, 0.3724, 0.1363, 0.109...
[0.309531707317, 1.14683658537, 0.038948780487...
[0.436902439024, 1.0433902439, 0.0373902439024...
12758
3850083334
292810415690018846
292810415690018846
[11616913604988929, 90711384989950008, 9465203...
[0.0, 1.22, 0.0, 0.269, 0.728, 0.009, 0.059, 0...
[[[0.0, 0.712, 0.059, 0.002, 0.021, 0.006, 1.0...
[0.3111, 1.2012, 0.0353, 0.3724, 0.1363, 0.109...
[0.309531707317, 1.14683658537, 0.038948780487...
[0.436902439024, 1.0433902439, 0.0373902439024...
12759
3850083334
296469590387236881
296469590387236881
[11616913604988929, 90711384989950008, 9465203...
[0.13, 1.219, 0.0, 0.44, 0.342, 0.028, 0.004, ...
[[[0.0, 0.712, 0.059, 0.002, 0.021, 0.006, 1.0...
[0.3111, 1.2012, 0.0353, 0.3724, 0.1363, 0.109...
[0.309531707317, 1.14683658537, 0.038948780487...
[0.436902439024, 1.0433902439, 0.0373902439024...
12760
3850083334
296469590387257359
296469590387257359
[11616913604988929, 90711384989950008, 9465203...
[0.374, 2.05, 0.004, 0.904, 0.002, 0.081, 0.04...
[[[0.0, 0.712, 0.059, 0.002, 0.021, 0.006, 1.0...
[0.3111, 1.2012, 0.0353, 0.3724, 0.1363, 0.109...
[0.309531707317, 1.14683658537, 0.038948780487...
[0.436902439024, 1.0433902439, 0.0373902439024...
12761
3850083334
302943514851590222
302943514851590222
[11616913604988929, 90711384989950008, 9465203...
[0.859, 2.13, 0.0, 0.373, 0.011, 0.0, 0.012, 0...
[[[0.0, 0.712, 0.059, 0.002, 0.021, 0.006, 1.0...
[0.3111, 1.2012, 0.0353, 0.3724, 0.1363, 0.109...
[0.309531707317, 1.14683658537, 0.038948780487...
[0.436902439024, 1.0433902439, 0.0373902439024...
12762
3850083334
456065860347027475
456065860347027475
[11616913604988929, 90711384989950008, 9465203...
[0.038, 0.021, 0.0, 0.947, 0.189, 0.0, 0.567, ...
[[[0.0, 0.712, 0.059, 0.002, 0.021, 0.006, 1.0...
[0.3111, 1.2012, 0.0353, 0.3724, 0.1363, 0.109...
[0.309531707317, 1.14683658537, 0.038948780487...
[0.436902439024, 1.0433902439, 0.0373902439024...
12763
3850083334
462821259788087690
462821259788087690
[11616913604988929, 90711384989950008, 9465203...
[0.522, 1.745, 0.0, 0.269, 0.684, 0.046, 1.135...
[[[0.0, 0.712, 0.059, 0.002, 0.021, 0.006, 1.0...
[0.3111, 1.2012, 0.0353, 0.3724, 0.1363, 0.109...
[0.309531707317, 1.14683658537, 0.038948780487...
[0.436902439024, 1.0433902439, 0.0373902439024...
12764
3673391202
4995412772592787655
4995412772592787655
[28223939643359401, 439740353870500018, 233700...
[0.545, 1.177, 0.063, 0.793, 0.013, 0.055, 0.2...
[[[0.162, 1.513, 0.044, 0.483, 0.018, 0.608, 0...
[0.2653, 0.9639, 0.1314, 0.9796, 0.1666, 0.129...
[0.287178571429, 0.962092857143, 0.13320714285...
[0.324642857143, 1.05078571429, 0.139, 0.8925,...
12765
3673391202
9083613970694320
9083613970694320
[439740353870500018, 15839007868620828, 282239...
[0.317, 0.707, 0.068, 1.711, 0.429, 0.101, 0.8...
[[[0.054, 1.812, 0.477, 0.545, 0.287, 0.0, 1.1...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
[0.287178571429, 0.962092857143, 0.13320714285...
[0.324642857143, 1.05078571429, 0.139, 0.8925,...
12766
3673391202
11335441040720040
11335441040720040
[439740353870500018, 15839007868620828, 282239...
[0.358, 1.042, 0.195, 3.888, 0.099, 0.124, 0.3...
[[[0.054, 1.812, 0.477, 0.545, 0.287, 0.0, 1.1...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
[0.287178571429, 0.962092857143, 0.13320714285...
[0.324642857143, 1.05078571429, 0.139, 0.8925,...
12767
3673391202
15839007868620828
15839007868620828
[439740353870500018, 15839007868620828, 282239...
[0.499, 0.832, 0.099, 0.362, 0.062, 0.077, 0.2...
[[[0.054, 1.812, 0.477, 0.545, 0.287, 0.0, 1.1...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
[0.287178571429, 0.962092857143, 0.13320714285...
[0.324642857143, 1.05078571429, 0.139, 0.8925,...
12768
3673391202
28223939643359401
28223939643359401
[439740353870500018, 15839007868620828, 282239...
[0.162, 1.513, 0.044, 0.483, 0.018, 0.608, 0.1...
[[[0.054, 1.812, 0.477, 0.545, 0.287, 0.0, 1.1...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
[0.287178571429, 0.962092857143, 0.13320714285...
[0.324642857143, 1.05078571429, 0.139, 0.8925,...
12769
3673391202
233700618554818563
233700618554818563
[439740353870500018, 15839007868620828, 282239...
[0.223, 0.956, 0.0, 0.048, 0.061, 0.007, 0.562...
[[[0.054, 1.812, 0.477, 0.545, 0.287, 0.0, 1.1...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
[0.287178571429, 0.962092857143, 0.13320714285...
[0.324642857143, 1.05078571429, 0.139, 0.8925,...
12770
3673391202
433266429406154772
433266429406154772
[437488556136837122, 296188100116926918, 46732...
[0.001, 1.004, 0.462, 0.862, 0.259, 0.192, 0.1...
[[[0.898, 0.571, 0.107, 0.862, 0.459, 0.376, 0...
[0.3493, 0.6946, 0.1288, 1.2265, 0.2617, 0.103...
[0.287178571429, 0.962092857143, 0.13320714285...
[0.324642857143, 1.05078571429, 0.139, 0.8925,...
12771
3673391202
437488556136837122
437488556136837122
[433266429406154772, 296188100116926918, 46732...
[0.898, 0.571, 0.107, 0.862, 0.459, 0.376, 0.0...
[[[0.001, 1.004, 0.462, 0.862, 0.259, 0.192, 0...
[0.2596, 0.7379, 0.1643, 1.2265, 0.2417, 0.085...
[0.287178571429, 0.962092857143, 0.13320714285...
[0.324642857143, 1.05078571429, 0.139, 0.8925,...
12772
3673391202
439740353870500018
439740353870500018
[439740353870500018, 15839007868620828, 282239...
[0.054, 1.812, 0.477, 0.545, 0.287, 0.0, 1.11,...
[[[0.054, 1.812, 0.477, 0.545, 0.287, 0.0, 1.1...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
[0.287178571429, 0.962092857143, 0.13320714285...
[0.324642857143, 1.05078571429, 0.139, 0.8925,...
12773
3673391202
450999316113584132
450999316113584132
[439740353870500018, 15839007868620828, 282239...
[0.791, 1.814, 0.013, 0.438, 0.037, 0.0, 0.412...
[[[0.054, 1.812, 0.477, 0.545, 0.287, 0.0, 1.1...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
[0.287178571429, 0.962092857143, 0.13320714285...
[0.324642857143, 1.05078571429, 0.139, 0.8925,...
12774
3673391202
453532627729321984
453532627729321984
[439740353870500018, 15839007868620828, 282239...
[0.117, 0.0, 0.126, 0.838, 0.32, 0.083, 0.117,...
[[[0.054, 1.812, 0.477, 0.545, 0.287, 0.0, 1.1...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
[0.287178571429, 0.962092857143, 0.13320714285...
[0.324642857143, 1.05078571429, 0.139, 0.8925,...
12775
3673391202
455221477589586090
455221477589586090
[439740353870500018, 15839007868620828, 282239...
[0.023, 0.31, 0.271, 0.444, 0.353, 0.0, 1.217,...
[[[0.054, 1.812, 0.477, 0.545, 0.287, 0.0, 1.1...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
[0.287178571429, 0.962092857143, 0.13320714285...
[0.324642857143, 1.05078571429, 0.139, 0.8925,...
12776
3673391202
456910280733184030
456910280733184030
[5144594509986807823, 439740353870500018, 4535...
[0.448, 2.32, 0.0, 0.182, 0.087, 0.0, 0.376, 1...
[[[0.109, 0.653, 0.021, 1.039, 0.0, 0.298, 0.2...
[0.2653, 0.9639, 0.1314, 0.9796, 0.1666, 0.129...
[0.287178571429, 0.962092857143, 0.13320714285...
[0.324642857143, 1.05078571429, 0.139, 0.8925,...
12777
3673391202
5144594509986807823
5144594509986807823
[439740353870500018, 15839007868620828, 282239...
[0.109, 0.653, 0.021, 1.039, 0.0, 0.298, 0.213...
[[[0.054, 1.812, 0.477, 0.545, 0.287, 0.0, 1.1...
[0.2881, 1.0109, 0.1309, 0.8878, 0.125, 0.1252...
[0.287178571429, 0.962092857143, 0.13320714285...
[0.324642857143, 1.05078571429, 0.139, 0.8925,...
12778 rows × 9 columns
In [177]:
df_spu.head()
Out[177]:
spu
CF_item
spu_features
CF_features
ave_CF_fea
sim
0
357872333107204
[8952950888272863232, 1664156381170176000, 284...
[0.035, 0.385, 0.112, 0.014, 0.0, 0.123, 0.438...
[[[0.462, 0.551, 0.068, 0.833, 0.0, 0.0, 0.0, ...
[0.4269, 0.6321, 0.101, 0.9695, 0.2211, 0.131,...
0.746659
1
357875526680651
[2046769978417582, 461413925257830545, 3255052...
[0.132, 1.678, 0.061, 0.918, 0.462, 0.342, 0.4...
[[[0.357, 2.503, 0.0, 0.641, 0.143, 0.0, 0.104...
[0.4727, 0.8078, 0.0697, 0.5796, 0.3075, 0.009...
0.739002
2
357882254983171
[459725075493814272, 8582811288237465674, 1976...
[0.026, 0.936, 0.056, 0.614, 0.139, 0.0, 0.302...
[[[1.884, 0.52, 0.0, 3.98, 0.175, 0.008, 0.663...
[0.6206, 0.8754, 0.1066, 0.7549, 0.2387, 0.186...
0.764982
3
357901107539985
[2466922956389351424, 8459806721299259392, 780...
[0.229, 0.543, 0.132, 0.144, 0.295, 0.018, 0.0...
[[[0.124, 0.819, 0.0, 0.596, 0.306, 0.043, 0.2...
[0.4016, 0.6379, 0.2088, 0.7764, 0.3335, 0.012...
0.707425
4
639360131194904
[451843765076328474, 81141212316332372, 320394...
[1.113, 0.5, 0.758, 0.218, 0.0, 0.0, 0.335, 1....
[[[0.501, 0.12, 0.0, 0.0, 0.23, 0.108, 0.377, ...
[0.2916, 0.5296, 0.0964, 0.3321, 0.1873, 0.022...
0.653415
In [192]:
df_spu['rank'] = df_spu['sim'].rank(ascending=False)
In [193]:
df_spu[df_spu['spu'] == 7957699990364366]
Out[193]:
spu
CF_item
spu_features
CF_features
ave_CF_fea
sim
rank
65
7957699990364366
[34416347801161914, 313076595256631868, 294499...
[0.299, 0.102, 0.0, 0.329, 0.253, 0.0, 1.051, ...
[[[0.427, 0.269, 0.016, 0.547, 0.09, 0.0, 0.86...
[0.3392, 0.7933, 0.1072, 0.7467, 0.1693, 0.027...
0.739963
1112.0
In [216]:
user_fea
Out[216]:
user_id
buy_spu
ave_CF_fea
ave_view_fea
0
3440325
2898705571343994880
[0.327609375, 0.573775, 0.11804375, 0.87390625...
[0.30521875, 0.5995625, 0.167625, 0.99259375, ...
1
7052311
7957699990364366
[0.307052173913, 0.738013043478, 0.06435217391...
[0.320739130435, 0.577217391304, 0.088, 0.6661...
2
7052311
299847271351230626
[0.306652173913, 0.7439, 0.0624434782609, 0.60...
[0.314217391304, 0.620695652174, 0.08865217391...
3
7052311
448747521265074449
[0.306817391304, 0.735182608696, 0.06435217391...
[0.323086956522, 0.60552173913, 0.088, 0.653, ...
4
9254280
3925244893201649664
[0.385093939394, 0.623651515152, 0.12763030303...
[0.356484848485, 0.575484848485, 0.11351515151...
5
15286946
453532609002410015
[0.347879166667, 0.817225, 0.0848583333333, 0....
[0.308958333333, 0.710041666667, 0.14666666666...
6
32626686
4420359388939563031
[0.17815, 0.741991666667, 0.088075, 0.47872083...
[0.128875, 0.684625, 0.114333333333, 0.3787083...
7
46639224
25690665644495446
[0.320625, 0.63956875, 0.08360625, 0.58983125,...
[0.276375, 0.62375, 0.0773125, 0.4994375, 0.22...
8
46639224
4766573611946106883
[0.32185625, 0.64266875, 0.08503125, 0.58865, ...
[0.2801875, 0.6065, 0.07725, 0.4950625, 0.2181...
9
47836480
2823270277605580800
[0.416597142857, 0.58062, 0.112997142857, 0.87...
[0.436742857143, 0.444428571429, 0.09897142857...
10
47836480
2909964570461929472
[0.325496078431, 0.594509803922, 0.09908823529...
[0.388098039216, 0.567470588235, 0.09990196078...
11
47836480
4411070714708987927
[0.399353333333, 0.56642, 0.126386666667, 0.81...
[0.404833333333, 0.4583, 0.0861833333333, 0.90...
12
47836480
6926894069614792705
[0.419721621622, 0.570637837838, 0.11359459459...
[0.433864864865, 0.409810810811, 0.09394594594...
13
60387856
2482122605837119488
[0.361202777778, 0.595433333333, 0.12032777777...
[0.260972222222, 0.633194444444, 0.10616666666...
14
68726836
2886883622319759360
[0.338261904762, 0.576661904762, 0.13463333333...
[0.193095238095, 0.688047619048, 0.21466666666...
15
82073468
2913060795180240896
[0.445991176471, 0.680444117647, 0.14644411764...
[0.573147058824, 0.7745, 0.0831176470588, 0.91...
16
85939638
2823270277605580800
[0.41885, 0.50228, 0.08361, 0.93755, 0.21682, ...
[0.2711, 0.2286, 0.0741, 0.4116, 0.1769, 0.125...
17
85939638
2832277476150169600
[0.392166666667, 0.500441666667, 0.10114166666...
[0.256916666667, 0.241666666667, 0.12716666666...
18
121339277
24001769421647872
[0.232147619048, 0.66679047619, 0.052357142857...
[0.235142857143, 0.622380952381, 0.03961904761...
19
156267268
2896735246507962368
[0.325731428571, 0.578748571429, 0.12396, 0.74...
[0.210257142857, 0.757085714286, 0.08428571428...
20
185723484
314483964450287810
[0.30986875, 0.73903125, 0.12285625, 0.7108875...
[0.2794375, 0.80675, 0.1433125, 0.521375, 0.22...
21
185723484
1392814500414406660
[0.263157142857, 0.640928571429, 0.13431428571...
[0.321714285714, 0.852714285714, 0.26485714285...
22
203856270
4397841390802718742
[0.244733333333, 0.664491666667, 0.08427083333...
[0.352333333333, 0.597083333333, 0.11625, 0.45...
23
212885228
2463545257346113536
[0.337386363636, 0.499527272727, 0.14955, 0.88...
[0.338181818182, 0.236090909091, 0.19559090909...
24
212885228
7804814445850251264
[0.33618, 0.492032, 0.142464, 0.862412, 0.2442...
[0.36532, 0.23976, 0.17448, 0.84404, 0.1268, 0...
25
239775508
4070767462512406529
[0.373508695652, 0.579843478261, 0.14540434782...
[0.332304347826, 0.491826086957, 0.13821739130...
26
243514462
6926894069614792705
[0.309395238095, 0.494176190476, 0.10145238095...
[0.239904761905, 0.426571428571, 0.11971428571...
27
258441899
2895890821597048832
[0.355970588235, 0.575739215686, 0.14691960784...
[0.433843137255, 0.566431372549, 0.13754901960...
28
262534611
2474241306483101696
[0.416653846154, 0.496253846154, 0.14941538461...
[0.283692307692, 0.298538461538, 0.19176923076...
29
262534611
4210379050958020608
[0.398769230769, 0.506161538462, 0.15313846153...
[0.280846153846, 0.284384615385, 0.19115384615...
...
...
...
...
...
472
3994880652
456065900700315688
[0.48564516129, 0.705732258065, 0.105722580645...
[0.461290322581, 0.833967741935, 0.12964516129...
473
3994880652
2885476247461195776
[0.475808333333, 0.667225, 0.107370833333, 0.8...
[0.46425, 0.7905, 0.144583333333, 1.0400833333...
474
4002116091
2818203727958560768
[0.407392592593, 0.561303703704, 0.10495555555...
[0.384851851852, 0.700592592593, 0.11062962963...
475
4014406455
80578231855935488
[0.365156962025, 0.864510126582, 0.06407594936...
[0.281113924051, 0.863215189873, 0.05581012658...
476
4024335256
1397036625065005056
[0.362943243243, 0.56822972973, 0.122794594595...
[0.369027027027, 0.673891891892, 0.13197297297...
477
4034766298
2831996001169256448
[0.390736363636, 0.559842424242, 0.13051515151...
[0.377363636364, 0.547575757576, 0.11406060606...
478
4042991439
82830090185703432
[0.281556862745, 0.67712745098, 0.113092156863...
[0.251019607843, 0.758392156863, 0.14317647058...
479
4049063975
4328035596179238913
[0.311107843137, 0.525758823529, 0.14049803921...
[0.241254901961, 0.474588235294, 0.17821568627...
480
4058255126
1400132849808887809
[0.312129230769, 0.579538461538, 0.14852615384...
[0.205753846154, 0.619523076923, 0.13033846153...
481
4104565142
938513825156079641
[0.384342857143, 0.579791428571, 0.12702, 0.86...
[0.328514285714, 0.504114285714, 0.11591428571...
482
4124119438
4411070714708987927
[0.1606, 0.797983333333, 0.0895833333333, 0.39...
[0.105566666667, 0.6367, 0.114166666667, 0.294...
483
4166653911
2815951928211386368
[0.356520588235, 0.491788235294, 0.12665, 0.89...
[0.269352941176, 0.352617647059, 0.14029411764...
484
4166653911
9039645182176481286
[0.340858333333, 0.507383333333, 0.104575, 0.9...
[0.321666666667, 0.334583333333, 0.17108333333...
485
4170254595
357901107539985
[0.383436842105, 0.558273684211, 0.13532631578...
[0.361789473684, 0.560842105263, 0.08310526315...
486
4170254595
2835655176583352320
[0.371433333333, 0.550511111111, 0.12841111111...
[0.347388888889, 0.577555555556, 0.088, 1.0701...
487
4181920381
2842129100334465024
[0.382138461538, 0.584433333333, 0.11675128205...
[0.578153846154, 0.488512820513, 0.10517948717...
488
4181920381
7067349984266096640
[0.38158974359, 0.57678974359, 0.114741025641,...
[0.579487179487, 0.534205128205, 0.11153846153...
489
4187483197
4209253151051174020
[0.357972340426, 0.519221276596, 0.14021276595...
[0.349489361702, 0.363063829787, 0.14553191489...
490
4187980304
2463545257346113536
[0.332037037037, 0.525759259259, 0.14025925925...
[0.324888888889, 0.458888888889, 0.12962962963...
491
4187980304
2595275618659840000
[0.349644444444, 0.622133333333, 0.13476666666...
[0.297111111111, 0.473555555556, 0.14222222222...
492
4187980304
2835936651544625153
[0.3659375, 0.6187875, 0.13185, 0.889525, 0.23...
[0.310625, 0.4585, 0.15875, 1.491375, 0.360625...
493
4209887493
74104320184119307
[0.243525, 0.81649375, 0.03629375, 0.62634375,...
[0.1970625, 0.8528125, 0.0219375, 0.5444375, 0...
494
4209887493
438895881520357521
[0.243525, 0.81649375, 0.03629375, 0.62634375,...
[0.1944375, 0.73625, 0.0136875, 0.537125, 0.18...
495
4209887493
453532580309307392
[0.232555555556, 0.798638888889, 0.03438333333...
[0.182722222222, 0.882666666667, 0.02222222222...
496
4214766792
4617954825743179776
[0.352743333333, 0.634563333333, 0.12076666666...
[0.319166666667, 0.4516, 0.1445, 1.0819, 0.238...
497
4221824221
440866242101010448
[0.281754545455, 0.464063636364, 0.11341818181...
[0.178909090909, 0.380272727273, 0.05381818181...
498
4221824221
4413885464477257729
[0.284281818182, 0.487518181818, 0.10958181818...
[0.177454545455, 0.458090909091, 0.05527272727...
499
4222905911
298721359433613314
[0.41416, 0.5410925, 0.129385, 0.81894, 0.2228...
[0.36455, 0.425325, 0.1382, 0.925075, 0.21945,...
500
4237674937
4132691957822554112
[0.34906875, 0.52245, 0.04779375, 0.400721875,...
[0.35465625, 0.4585625, 0.03425, 0.402, 0.1338...
501
4290326024
2890824271308562432
[0.379382608696, 0.494604347826, 0.16191304347...
[0.309347826087, 0.423086956522, 0.15504347826...
502 rows × 4 columns
In [49]:
#user_fea.to_pickle('user_fea.pkl')
In [3]:
user_fea = pd.read_pickle('user_fea.pkl')
In [8]:
user_fea.head()
Out[8]:
user_id
buy_spu
ave_CF_fea
ave_view_fea
ave_CF_sim_rank
ave_Ori_sim_rank
0
3440325
2898705571343994880
[0.327609375, 0.573775, 0.11804375, 0.87390625...
[0.30521875, 0.5995625, 0.167625, 0.99259375, ...
([0.799214495018], [215.0])
([0.811977551064], [115.0])
1
7052311
7957699990364366
[0.307052173913, 0.738013043478, 0.06435217391...
[0.320739130435, 0.577217391304, 0.088, 0.6661...
([0.745014365081], [1155.0])
([0.73996321102], [1112.0])
2
7052311
299847271351230626
[0.306652173913, 0.7439, 0.0624434782609, 0.60...
[0.314217391304, 0.620695652174, 0.08865217391...
([0.833736325406], [173.0])
([0.855587371153], [66.0])
3
7052311
448747521265074449
[0.306817391304, 0.735182608696, 0.06435217391...
[0.323086956522, 0.60552173913, 0.088, 0.653, ...
([0.854382169198], [49.0])
([0.853929200306], [84.0])
4
9254280
3925244893201649664
[0.385093939394, 0.623651515152, 0.12763030303...
[0.356484848485, 0.575484848485, 0.11351515151...
([0.730978541607], [1427.0])
([0.752675987128], [535.0])
In [24]:
(float(user_fea['ave_CF_sim_rank'][0][1]))
Out[24]:
215.0
In [25]:
user_fea['ave_CF_sim'] = user_fea.apply(lambda x: float(x['ave_CF_sim_rank'][0]), axis = 1)
In [27]:
user_fea['ave_CF_rank'] = user_fea.apply(lambda x: float(x['ave_CF_sim_rank'][1]), axis = 1)
In [28]:
user_fea['ave_Ori_sim'] = user_fea.apply(lambda x: float(x['ave_Ori_sim_rank'][0]), axis = 1)
In [29]:
user_fea['ave_Ori_rank'] = user_fea.apply(lambda x: float(x['ave_Ori_sim_rank'][1]), axis = 1)
In [33]:
#user_fea.to_pickle('user_fea.pkl')
In [34]:
user_fea.head()
Out[34]:
user_id
buy_spu
ave_CF_fea
ave_view_fea
ave_CF_sim_rank
ave_Ori_sim_rank
ave_CF_sim
ave_CF_rank
ave_Ori_sim
ave_Ori_rank
0
3440325
2898705571343994880
[0.327609375, 0.573775, 0.11804375, 0.87390625...
[0.30521875, 0.5995625, 0.167625, 0.99259375, ...
([0.799214495018], [215.0])
([0.811977551064], [115.0])
0.799214
215.0
0.811978
115.0
1
7052311
7957699990364366
[0.307052173913, 0.738013043478, 0.06435217391...
[0.320739130435, 0.577217391304, 0.088, 0.6661...
([0.745014365081], [1155.0])
([0.73996321102], [1112.0])
0.745014
1155.0
0.739963
1112.0
2
7052311
299847271351230626
[0.306652173913, 0.7439, 0.0624434782609, 0.60...
[0.314217391304, 0.620695652174, 0.08865217391...
([0.833736325406], [173.0])
([0.855587371153], [66.0])
0.833736
173.0
0.855587
66.0
3
7052311
448747521265074449
[0.306817391304, 0.735182608696, 0.06435217391...
[0.323086956522, 0.60552173913, 0.088, 0.653, ...
([0.854382169198], [49.0])
([0.853929200306], [84.0])
0.854382
49.0
0.853929
84.0
4
9254280
3925244893201649664
[0.385093939394, 0.623651515152, 0.12763030303...
[0.356484848485, 0.575484848485, 0.11351515151...
([0.730978541607], [1427.0])
([0.752675987128], [535.0])
0.730979
1427.0
0.752676
535.0
In [36]:
(user_fea['ave_CF_sim']).mean()
Out[36]:
0.7904818444503197
In [37]:
(user_fea['ave_Ori_sim']).mean()
Out[37]:
0.8059018725238667
In [38]:
(user_fea['ave_CF_rank']).mean()
Out[38]:
612.9760956175298
In [39]:
(user_fea['ave_Ori_rank']).mean()
Out[39]:
313.0517928286853
In [68]:
sns.distplot(user_fea[['ave_CF_sim']], bins = 100, color = 'red', hist =False, label = 'CF')
sns.distplot(user_fea[['ave_Ori_sim']], bins = 100, color = 'blue', hist =False, label = 'Ori')
Out[68]:
<matplotlib.axes._subplots.AxesSubplot at 0x12734da90>
In [69]:
sns.distplot(user_fea[['ave_CF_rank']], bins = 100,color = 'red', hist =False, label = 'CF')
sns.distplot(user_fea[['ave_Ori_rank']], bins = 100,color = 'blue', hist =False, label = 'Ori')
Out[69]:
<matplotlib.axes._subplots.AxesSubplot at 0x1274c4d10>
In [ ]:
Content source: walkon302/CDIPS_Recommender
Similar notebooks: