Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
ydl_ai_recommender
Overview
Overview
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
闫发泽
ydl_ai_recommender
Commits
2b5c5943
Commit
2b5c5943
authored
Dec 09, 2022
by
柴鹏飞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
补充文档
parent
6697d73b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
3 deletions
+45
-3
README.md
README.md
+35
-3
test.py
bin/test.py
+5
-0
mysql_client.py
src/data/mysql_client.py
+5
-0
No files found.
README.md
View file @
2b5c5943
...
@@ -2,7 +2,38 @@
...
@@ -2,7 +2,38 @@
## 简介
## 简介
推荐咨询师
根据用户的画像信息,推荐咨询师
## 使用
无特殊说明,下面所有的操作均在项目主目录(也就是本文件所在目录)下操作
### 更新特征、索引信息
```
bash
# 1. 从数据库中拉取最新数据到本地
python bin/update.py
-t
load_db_data
# 2. 构建相关特征、索引信息
python bin/update.py
-t
make_embedding
```
### 启动接口服务
```
bash
sh bin/start.sh
```
### 性能测试
```
bash
python bin/test.py
```
## 项目目录介绍
## 项目目录介绍
...
@@ -11,7 +42,7 @@
...
@@ -11,7 +42,7 @@
-
`data`
项目中用到的数据存放目录
-
`data`
项目中用到的数据存放目录
-
`log`
项目内接口、脚本等运行日志存放目录
-
`log`
项目内接口、脚本等运行日志存放目录
-
`src`
项目核心代码目录
-
`src`
项目核心代码目录
-
`
data`
数据相关
-
`
core`
核心代码
-
`
recommender`
核心推荐算法
-
`
data`
数据操作相关代码
-
`service`
推荐算法接口服务
-
`service`
推荐算法接口服务
-
`utils`
公共用到的工具类
-
`utils`
公共用到的工具类
\ No newline at end of file
bin/test.py
View file @
2b5c5943
...
@@ -103,7 +103,12 @@ def evaluation(result_detail):
...
@@ -103,7 +103,12 @@ def evaluation(result_detail):
def
do_test
(
args
):
def
do_test
(
args
):
user_profile_dict
=
load_local_user_profile
()
user_profile_dict
=
load_local_user_profile
()
try
:
old_users
,
test_orders
=
load_test_data
()
old_users
,
test_orders
=
load_test_data
()
except
Exception
as
e
:
logger
.
error
(
'测试数据加载出错,请确认测试数据已经下载到本地,或启动命令中增加参数 "--do_update_test_data"'
,
exc_info
=
True
)
return
recommender
=
UserCFRecommender
(
top_n
=
args
.
top_n
,
k
=
args
.
k
,
is_use_db
=
False
)
recommender
=
UserCFRecommender
(
top_n
=
args
.
top_n
,
k
=
args
.
k
,
is_use_db
=
False
)
...
...
src/data/mysql_client.py
View file @
2b5c5943
...
@@ -11,6 +11,7 @@ class MySQLClient():
...
@@ -11,6 +11,7 @@ class MySQLClient():
def
__init__
(
self
,
host
,
port
,
user
,
password
)
->
None
:
def
__init__
(
self
,
host
,
port
,
user
,
password
)
->
None
:
self
.
logger
=
create_logger
(
__name__
,
'mysql_client.log'
,
is_rotating
=
True
)
self
.
logger
=
create_logger
(
__name__
,
'mysql_client.log'
,
is_rotating
=
True
)
try
:
self
.
connection
=
pymysql
.
connect
(
self
.
connection
=
pymysql
.
connect
(
host
=
host
,
host
=
host
,
port
=
port
,
port
=
port
,
...
@@ -19,6 +20,9 @@ class MySQLClient():
...
@@ -19,6 +20,9 @@ class MySQLClient():
charset
=
'utf8mb4'
,
charset
=
'utf8mb4'
,
cursorclass
=
pymysql
.
cursors
.
DictCursor
cursorclass
=
pymysql
.
cursors
.
DictCursor
)
)
except
Exception
as
e
:
self
.
logger
.
error
(
'数据库连接失败'
,
exc_info
=
True
)
raise
e
self
.
cursor
=
self
.
connection
.
cursor
()
self
.
cursor
=
self
.
connection
.
cursor
()
self
.
logger
.
info
(
'数据库连接成功'
)
self
.
logger
.
info
(
'数据库连接成功'
)
...
@@ -38,6 +42,7 @@ class MySQLClient():
...
@@ -38,6 +42,7 @@ class MySQLClient():
self
.
connection
.
close
()
self
.
connection
.
close
()
self
.
logger
.
info
(
'dataset disconnected'
)
self
.
logger
.
info
(
'dataset disconnected'
)
except
Exception
as
e
:
except
Exception
as
e
:
self
.
logger
.
error
(
'销毁 MySQLClient 失败'
,
exc_info
=
True
)
print
(
e
)
print
(
e
)
...
...
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