|
@@ -0,0 +1,78 @@
|
|
|
+#!/bin/sh
|
|
|
+set -ex
|
|
|
+
|
|
|
+source /root/anaconda3/bin/activate py37
|
|
|
+
|
|
|
+# nohup sh handle_rov.sh > "$(date +%Y%m%d_%H%M%S)_handle_rov.log" 2>&1 &
|
|
|
+
|
|
|
+# 原始数据table name
|
|
|
+table='alg_recsys_sample_all'
|
|
|
+today="$(date +%Y%m%d)"
|
|
|
+today_early_3="$(date -d '3 days ago' +%Y%m%d)"
|
|
|
+#table='alg_recsys_sample_all_test'
|
|
|
+# 处理分区配置 推荐数据间隔一天生产,所以5日0点使用3日0-23点数据生产new模型数据
|
|
|
+begin_early_2_Str="$(date -d '2 days ago' +%Y%m%d)"
|
|
|
+end_early_2_Str="$(date -d '2 days ago' +%Y%m%d)"
|
|
|
+beginHhStr=00
|
|
|
+endHhStr=23
|
|
|
+max_hour=05
|
|
|
+max_minute=00
|
|
|
+# 各节点产出hdfs文件绝对路径
|
|
|
+# 源数据文件
|
|
|
+originDataPath=/dw/recommend/model/13_sample_data/
|
|
|
+# 特征值
|
|
|
+valueDataPath=/dw/recommend/model/14_feature_data/
|
|
|
+# 特征分桶
|
|
|
+bucketDataPath=/dw/recommend/model/16_train_data/
|
|
|
+# 模型数据路径
|
|
|
+MODEL_PATH=/root/joe/recommend-emr-dataprocess/model
|
|
|
+# 预测路径
|
|
|
+PREDICT_PATH=/root/joe/recommend-emr-dataprocess/predict
|
|
|
+# 历史线上正在使用的模型数据路径
|
|
|
+LAST_MODEL_HOME=/root/joe/model_online
|
|
|
+# 模型数据文件前缀
|
|
|
+model_name=akaqjl8
|
|
|
+# fm模型
|
|
|
+FM_HOME=/root/sunmingze/alphaFM/bin
|
|
|
+# hadoop
|
|
|
+HADOOP=/opt/apps/HADOOP-COMMON/hadoop-common-current/bin/hadoop
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ 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
|
|
|
+
|
|
|
+$HADOOP fs -text ${bucketDataPath}/20240703/* | ${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}/20240703/* | ${FM_HOME}/bin/fm_predict -m ${MODEL_PATH}/${model_name}_20240703.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
|