Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
physical
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
physical
Commits
9a80dae2
Commit
9a80dae2
authored
Sep 17, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'gyz' into 'master'
Gyz See merge request
alpha/physical!481
parents
6947ae00
6d5516dc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletion
+13
-1
es.py
libs/es.py
+8
-1
linucb.py
linucb/views/linucb.py
+5
-0
No files found.
libs/es.py
View file @
9a80dae2
...
@@ -411,7 +411,7 @@ class ESPerform(object):
...
@@ -411,7 +411,7 @@ class ESPerform(object):
}
}
},
},
"_source"
:
{
"_source"
:
{
"include"
:
[
"id"
,
"user_id"
]
"include"
:
[
"id"
,
"user_id"
,
"latest_reply_time"
]
},
},
"sort"
:
[
"sort"
:
[
{
"latest_reply_time"
:
{
"order"
:
"desc"
}},
{
"latest_reply_time"
:
{
"order"
:
"desc"
}},
...
@@ -440,8 +440,15 @@ class ESPerform(object):
...
@@ -440,8 +440,15 @@ class ESPerform(object):
for
item
in
result_dict
[
"hits"
]:
for
item
in
result_dict
[
"hits"
]:
topic_id_dict
[
str
(
item
[
"_source"
][
"id"
])]
=
item
[
"_source"
][
"user_id"
]
topic_id_dict
[
str
(
item
[
"_source"
][
"id"
])]
=
item
[
"_source"
][
"user_id"
]
topic_id_dict_latest_reply_time
=
list
()
for
item
in
result_dict
[
"hits"
]:
topic_id_dict_latest_reply_time
.
append
([
item
[
"_source"
][
"id"
],
item
[
"_source"
][
"latest_reply_time"
]])
logging
.
info
(
"topic_id_list:
%
s"
%
str
(
topic_id_dict
))
logging
.
info
(
"topic_id_list:
%
s"
%
str
(
topic_id_dict
))
logging
.
info
(
"linucb_tag_id_list_2_same_tagset_ids:"
+
str
(
tag_id
))
logging
.
info
(
"linucb_tag_id_list_2_same_tagset_ids_2_topics_detail:"
+
str
(
topic_id_dict_latest_reply_time
))
return
topic_id_list
,
topic_id_dict
return
topic_id_list
,
topic_id_dict
except
:
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
...
...
linucb/views/linucb.py
View file @
9a80dae2
...
@@ -11,6 +11,7 @@ import json
...
@@ -11,6 +11,7 @@ import json
import
pickle
import
pickle
from
django.conf
import
settings
from
django.conf
import
settings
from
libs.error
import
logging_exception
from
libs.error
import
logging_exception
from
gm_logging.general
import
log_maidian
class
LinUCB
:
class
LinUCB
:
d
=
2
d
=
2
...
@@ -150,8 +151,12 @@ class LinUCB:
...
@@ -150,8 +151,12 @@ class LinUCB:
ori_redis_tag_data
=
redis_cli
.
hget
(
redis_key
,
tag_id
)
ori_redis_tag_data
=
redis_cli
.
hget
(
redis_key
,
tag_id
)
if
not
ori_redis_tag_data
:
if
not
ori_redis_tag_data
:
log_dict
=
{
"device_id"
:
device_id
,
"tag_id"
:
tag_id
,
"ltype"
:
"create"
,
"biz_type"
:
"lin_tag"
}
log_maidian
(
log_dict
,
'physical'
)
LinUCB
.
init_device_id_linucb_info
(
redis_client
,
redis_prefix
,
device_id
,[
tag_id
])
LinUCB
.
init_device_id_linucb_info
(
redis_client
,
redis_prefix
,
device_id
,[
tag_id
])
else
:
else
:
log_dict
=
{
"device_id"
:
device_id
,
"tag_id"
:
tag_id
,
"ltype"
:
"update"
,
"biz_type"
:
"lin_tag"
}
log_maidian
(
log_dict
,
'physical'
)
ori_redis_tag_dict
=
pickle
.
loads
(
ori_redis_tag_data
)
ori_redis_tag_dict
=
pickle
.
loads
(
ori_redis_tag_data
)
new_Aa_matrix
=
ori_redis_tag_dict
[
"Aa"
]
+
np
.
dot
(
xa
,
xaT
)
new_Aa_matrix
=
ori_redis_tag_dict
[
"Aa"
]
+
np
.
dot
(
xa
,
xaT
)
new_AaI_matrix
=
np
.
linalg
.
solve
(
new_Aa_matrix
,
np
.
identity
(
cls
.
d
))
new_AaI_matrix
=
np
.
linalg
.
solve
(
new_Aa_matrix
,
np
.
identity
(
cls
.
d
))
...
...
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