12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- #!/bin/sh
- set -x
- begin_date=$1
- end_date=$2
- model_name=$3
- train_dim=$4
- hdfs_path=$5
- PROJECT_HOME=/root/zhaohp/recommend-emr-dataprocess
- HADOOP=/opt/apps/HADOOP-COMMON/hadoop-common-current/bin/hadoop
- MODEL_PATH=${PROJECT_HOME}/model/recommend
- FM_TRAIN=/root/sunmingze/alphaFM/bin/fm_train
- train_date=$begin_date
- main() {
- end_date=$(date -d "$end_date +1 day" +%Y%m%d)
-
- while [ "$train_date" != "$end_date" ]; do
- echo "==================== 开始训练 $train_date 模型 ===================="
- if [ "$train_date" == "$begin_date" ]; then
- $HADOOP fs -text ${hdfs_path}/${train_date}/* | ${FM_TRAIN} -m ${MODEL_PATH}/${model_name}_${train_date}.txt -dim ${train_dim} -core 8
- else
- yesterday=$(date -d "$train_date -1 day" +%Y%m%d)
- $HADOOP fs -text ${hdfs_path}/${train_date}/* | ${FM_TRAIN} -m ${MODEL_PATH}/${model_name}_${train_date}.txt -dim ${train_dim} -core 8 -im ${MODEL_PATH}/${model_name}_${yesterday}.txt
- fi
- echo -e "==================== 训练 $train_date 模型结束 ====================\n\n\n\n\n\n"
- train_date=$(date -d "$train_date +1 day" +%Y%m%d)
- done
- }
- main
|