|
@@ -8,7 +8,8 @@ source /root/anaconda3/bin/activate py37
|
|
|
# 原始数据table name
|
|
|
table='alg_recsys_sample_all'
|
|
|
today="$(date +%Y%m%d)"
|
|
|
-today_early_3="$(date -d '3 days ago' +%Y%m%d)"
|
|
|
+#today_early_3="$(date -d '3 days ago' +%Y%m%d)"
|
|
|
+today_early_3=20240703
|
|
|
#table='alg_recsys_sample_all_test'
|
|
|
# 处理分区配置 推荐数据间隔一天生产,所以5日0点使用3日0-23点数据生产new模型数据
|
|
|
begin_early_2_Str="$(date -d '2 days ago' +%Y%m%d)"
|
|
@@ -66,11 +67,52 @@ fi
|
|
|
# 1 对比auc数据判断是否更新线上模型
|
|
|
if [ "$online_auc" \< "$new_auc" ]; then
|
|
|
echo "新模型优于线上模型: 线上模型AUC: ${online_auc}, 新模型AUC: ${new_auc}"
|
|
|
- # todo 模型格式转换
|
|
|
-
|
|
|
- # todo 模型文件上传OSS
|
|
|
-
|
|
|
- # todo 本地保存最新的线上使用的模型,用于下一次的AUC验证
|
|
|
+ # 模型格式转换
|
|
|
+ cat ${MODEL_PATH}/${model_name}_${today_early_3}.txt |
|
|
|
+ awk -F " " '{
|
|
|
+ if (NR == 1) {
|
|
|
+ print $1"\t"$2
|
|
|
+ } else {
|
|
|
+ split($0, fields, " ");
|
|
|
+ OFS="\t";
|
|
|
+ line=""
|
|
|
+ for (i = 1; i <= 10 && i <= length(fields); i++) {
|
|
|
+ line = (line ? line "\t" : "") fields[i];
|
|
|
+ }
|
|
|
+ print line
|
|
|
+ }
|
|
|
+ }' > ${MODEL_PATH}/${model_name}_${today_early_3}_change.txt
|
|
|
+ if [ $? -ne 0 ]; then
|
|
|
+ echo "新模型文件格式转换失败"
|
|
|
+# /root/anaconda3/bin/python ad/ad_monitor_util.py "新模型文件格式转换失败"
|
|
|
+ exit 1
|
|
|
+ fi
|
|
|
+ # 模型文件上传OSS
|
|
|
+# online_model_path=${OSS_PATH}/${model_name}.txt
|
|
|
+# $HADOOP fs -test -e ${online_model_path}
|
|
|
+# if [ $? -eq 0 ]; then
|
|
|
+# echo "数据存在, 先删除。"
|
|
|
+# $HADOOP fs -rm -r -skipTrash ${online_model_path}
|
|
|
+# else
|
|
|
+# echo "数据不存在"
|
|
|
+# fi
|
|
|
+#
|
|
|
+# $HADOOP fs -put ${MODEL_PATH}/${model_name}_${today_early_3}_change.txt ${online_model_path}
|
|
|
+# if [ $? -eq 0 ]; then
|
|
|
+# echo "推荐模型文件至OSS成功"
|
|
|
+# else
|
|
|
+# echo "推荐模型文件至OSS失败"
|
|
|
+## /root/anaconda3/bin/python ad/ad_monitor_util.py "推荐模型文件至OSS失败"
|
|
|
+# exit 1
|
|
|
+# fi
|
|
|
+ # 本地保存最新的线上使用的模型,用于下一次的AUC验证
|
|
|
+ cp -f ${LAST_MODEL_HOME}/model_online.txt ${LAST_MODEL_HOME}/model_online_$(date +\%Y\%m\%d).txt
|
|
|
+ cp -f ${MODEL_PATH}/${model_name}_${today_early_3}.txt ${LAST_MODEL_HOME}/model_online.txt
|
|
|
+ if [ $? -ne 0 ]; then
|
|
|
+ echo "模型备份失败"
|
|
|
+ /root/anaconda3/bin/python ad/ad_monitor_util.py "模型备份失败 - 最新模型地址: ${MODEL_PATH}/${model_name}_${today_early_1}.txt"
|
|
|
+ exit 1
|
|
|
+ fi
|
|
|
# /root/anaconda3/bin/python ad/ad_monitor_util.py "新模型优于线上模型: 线上模型AUC: ${online_auc}, 新模型AUC: ${new_auc}"
|
|
|
else
|
|
|
echo "新模型不如线上模型: 线上模型AUC: ${online_auc}, 新模型AUC: ${new_auc}"
|