|
@@ -31,51 +31,92 @@ PREDICT_PATH=/root/joe/recommend-emr-dataprocess/predict
|
|
# 历史线上正在使用的模型数据路径
|
|
# 历史线上正在使用的模型数据路径
|
|
LAST_MODEL_HOME=/root/joe/model_online
|
|
LAST_MODEL_HOME=/root/joe/model_online
|
|
# 模型数据文件前缀
|
|
# 模型数据文件前缀
|
|
-model_name=akaqjl8
|
|
|
|
|
|
+model_name=aka8
|
|
# fm模型
|
|
# fm模型
|
|
FM_HOME=/root/sunmingze/alphaFM/bin
|
|
FM_HOME=/root/sunmingze/alphaFM/bin
|
|
# hadoop
|
|
# hadoop
|
|
HADOOP=/opt/apps/HADOOP-COMMON/hadoop-common-current/bin/hadoop
|
|
HADOOP=/opt/apps/HADOOP-COMMON/hadoop-common-current/bin/hadoop
|
|
|
|
+OSS_PATH=oss://art-recommend.oss-cn-hangzhou.aliyuncs.com/zhangbo/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 0 对比AUC 前置对比2日模型数据 与 线上模型数据效果对比,如果2日模型优于线上,更新线上模型
|
|
# 0 对比AUC 前置对比2日模型数据 与 线上模型数据效果对比,如果2日模型优于线上,更新线上模型
|
|
-#echo "$(date +%Y-%m-%d_%H-%M-%S)----------step0------------开始对比,新:${MODEL_PATH}/${model_name}_${today_early_3}.txt,与线上online模型数据auc效果"
|
|
|
|
-#$HADOOP fs -text ${bucketDataPath}/${begin_early_2_Str}/* | ${FM_HOME}/bin/fm_predict -m ${LAST_MODEL_HOME}/model_online.txt -dim 8 -core 8 -out ${PREDICT_PATH}/${model_name}_${today}_online.txt
|
|
|
|
-#$HADOOP fs -text ${bucketDataPath}/${begin_early_2_Str}/* | ${FM_HOME}/bin/fm_predict -m ${MODEL_PATH}/${model_name}_${today_early_3}.txt -dim 8 -core 8 -out ${PREDICT_PATH}/${model_name}_${today}_new.txt
|
|
|
|
-#
|
|
|
|
-#online_auc=`cat ${PREDICT_PATH}/${model_name}_${today}_online.txt | /root/sunmingze/AUC/AUC`
|
|
|
|
-#if [ $? -ne 0 ]; then
|
|
|
|
-# echo "推荐线上模型AUC计算失败"
|
|
|
|
-## /root/anaconda3/bin/python ad/ad_monitor_util.py "线上模型AUC计算失败"
|
|
|
|
-# exit 1
|
|
|
|
-#fi
|
|
|
|
-#
|
|
|
|
-#new_auc=`${PREDICT_PATH}/${model_name}_${today}_new.txt | /root/sunmingze/AUC/AUC`
|
|
|
|
-#if [ $? -ne 0 ]; then
|
|
|
|
-# echo "推荐新模型AUC计算失败"
|
|
|
|
-## /root/anaconda3/bin/python ad/ad_monitor_util.py "新模型AUC计算失败"
|
|
|
|
-# exit 1
|
|
|
|
-#fi
|
|
|
|
-#
|
|
|
|
-#
|
|
|
|
-## 1 对比auc数据判断是否更新线上模型
|
|
|
|
-#if [ "$online_auc" \< "$new_auc" ]; then
|
|
|
|
-# echo "新模型优于线上模型: 线上模型AUC: ${online_auc}, 新模型AUC: ${new_auc}"
|
|
|
|
-# # todo 模型格式转换
|
|
|
|
-#
|
|
|
|
-# # todo 模型文件上传OSS
|
|
|
|
-#
|
|
|
|
-# # todo 本地保存最新的线上使用的模型,用于下一次的AUC验证
|
|
|
|
-## /root/anaconda3/bin/python ad/ad_monitor_util.py "新模型优于线上模型: 线上模型AUC: ${online_auc}, 新模型AUC: ${new_auc}"
|
|
|
|
-#else
|
|
|
|
-# echo "新模型不如线上模型: 线上模型AUC: ${online_auc}, 新模型AUC: ${new_auc}"
|
|
|
|
-## /root/anaconda3/bin/python ad/ad_monitor_util.py "新模型不如线上模型: 线上模型AUC: ${online_auc}, 新模型AUC: ${new_auc}"
|
|
|
|
-#fi
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-# 2 判断上游表是否生产完成,最长等待到12点
|
|
|
|
|
|
+echo "$(date +%Y-%m-%d_%H-%M-%S)----------step0------------开始对比,新:${MODEL_PATH}/${model_name}_${today_early_3}.txt,与线上online模型数据auc效果"
|
|
|
|
+$HADOOP fs -text ${bucketDataPath}/${begin_early_2_Str}/* | ${FM_HOME}/fm_predict -m ${LAST_MODEL_HOME}/model_online.txt -dim 8 -core 8 -out ${PREDICT_PATH}/${model_name}_${today}_online.txt
|
|
|
|
+$HADOOP fs -text ${bucketDataPath}/${begin_early_2_Str}/* | ${FM_HOME}/fm_predict -m ${MODEL_PATH}/${model_name}_${today_early_3}.txt -dim 8 -core 8 -out ${PREDICT_PATH}/${model_name}_${today}_new.txt
|
|
|
|
+
|
|
|
|
+online_auc=`cat ${PREDICT_PATH}/${model_name}_${today}_online.txt | /root/sunmingze/AUC/AUC`
|
|
|
|
+if [ $? -ne 0 ]; then
|
|
|
|
+ echo "推荐线上模型AUC计算失败"
|
|
|
|
+# /root/anaconda3/bin/python ad/ad_monitor_util.py "线上模型AUC计算失败"
|
|
|
|
+ exit 1
|
|
|
|
+fi
|
|
|
|
+
|
|
|
|
+new_auc=`cat ${PREDICT_PATH}/${model_name}_${today}_new.txt | /root/sunmingze/AUC/AUC`
|
|
|
|
+if [ $? -ne 0 ]; then
|
|
|
|
+ echo "推荐新模型AUC计算失败"
|
|
|
|
+# /root/anaconda3/bin/python ad/ad_monitor_util.py "新模型AUC计算失败"
|
|
|
|
+ exit 1
|
|
|
|
+fi
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+# 1 对比auc数据判断是否更新线上模型
|
|
|
|
+if [ "$online_auc" \< "$new_auc" ]; then
|
|
|
|
+ echo "新模型优于线上模型: 线上模型AUC: ${online_auc}, 新模型AUC: ${new_auc}"
|
|
|
|
+ # 1.1 模型格式转换
|
|
|
|
+ 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="" 1; i <= 10 && i <= length(fields); i++) {
|
|
|
|
+ line
|
|
|
|
+ for (i = = (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
|
|
|
|
+ # 1.2 模型文件上传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失败"
|
|
|
|
+ exit 1
|
|
|
|
+ fi
|
|
|
|
+ # 1.3 本地保存最新的线上使用的模型,用于下一次的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}"
|
|
|
|
+# /root/anaconda3/bin/python ad/ad_monitor_util.py "新模型不如线上模型: 线上模型AUC: ${online_auc}, 新模型AUC: ${new_auc}"
|
|
|
|
+fi
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+# 2 判断上游表是否生产完成,最长等待到max_hour点
|
|
# shellcheck disable=SC2154
|
|
# shellcheck disable=SC2154
|
|
echo "$(date +%Y-%m-%d_%H-%M-%S)----------step1------------开始校验是否生产完数据,分区信息:beginStr:${begin_early_2_Str}${beginHhStr},endStr:${end_early_2_Str}${endHhStr}"
|
|
echo "$(date +%Y-%m-%d_%H-%M-%S)----------step1------------开始校验是否生产完数据,分区信息:beginStr:${begin_early_2_Str}${beginHhStr},endStr:${end_early_2_Str}${endHhStr}"
|
|
while true; do
|
|
while true; do
|