资源简介
sh-demand-forecast-alg.zip
代码片段和文件信息
#!/usr/bin/python
# -*- coding: UTF-8 -*-
“““
# @Time : 2019/11/6 10:57
# @Author : peng.wang
# @Email : WangPeng4@sfmail.sf-express.com
# @FileName: main.py
# @ProjectName :sh-demand-forecast-alg
“““
import os
import yaml
import warnings
import pandas as pd
import numpy as np
from core import data_handle
from model.stlforcator_train import STLForecastorTrain
from utils.misc import Logger
from utils.util import GetExternalData
warnings.filterwarnings(“ignore“)
log = Logger(log_path=os.path.join(os.path.dirname(os.path.dirname(__file__)) ‘log‘)).logger
with open(os.path.join(os.path.dirname(__file__) ‘config/config.yaml‘)) as fp:
config = yaml.load(fp)
def main(model_name):
“““
main function for run the offline training and validation process output the train error
if the cross-validation selected then give the cross-validation results
:param model_name:
:return:
“““
# load data
id = ‘2703‘
data_path = config[‘DATA‘][‘data_path‘]
time_column = config[‘DATA‘][‘time_column‘]
id_column = config[‘DATA‘][‘id_column‘]
target_column = config[“DATA“][‘target_column‘]
ExternalData = GetExternalData(start_date=‘2018-01-01‘ end_date=‘2019-12-31‘)
df_external = ExternalData.get_external()
data_ins = data_handle.DataHandler(data_path=data_path time_column=time_column id_column=id_column
target_column=target_column multiple_sku=True logger=log)
data_dict = data_ins.df_by_id
df = data_dict[id]
df = df[df[time_column] >= ‘2018-01-01‘]
df.reset_index(inplace=True drop=True)
for model in model_name:
forecastor = STLForecastorTrain(logger=log)
forecastor.model_setup(model_name=model save_model=True feature_selection=False)
forecastor.data_setup(df target_column id_column time_column with_external=True external_df=df_external
external_column=[‘holiday‘] forecast_period=‘1week‘)
result_dict = forecastor.build_model(save_feature=True)
# log.info(‘result_df:‘)
# log.info(result_df)
result_df = result_dict[‘train_result‘]
result_df[‘time‘] = result_dict[‘time‘]
result_df.to_csv(‘train_results.csv‘)
result_dict[‘feature‘].to_csv(‘feature.csv‘)
if __name__ == “__main__“:
main(model_name=[‘XGB‘])
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-12-04 10:49 sh-demand-forecast-alg\
目录 0 2019-12-04 10:44 sh-demand-forecast-alg\.git\
文件 39 2019-12-04 10:44 sh-demand-forecast-alg\.gitignore
文件 323 2019-12-04 10:44 sh-demand-forecast-alg\.git\config
文件 73 2019-12-04 10:44 sh-demand-forecast-alg\.git\desc
文件 23 2019-12-04 10:44 sh-demand-forecast-alg\.git\HEAD
目录 0 2019-12-04 10:44 sh-demand-forecast-alg\.git\hooks\
文件 478 2019-12-04 10:44 sh-demand-forecast-alg\.git\hooks\applypatch-msg.sample
文件 896 2019-12-04 10:44 sh-demand-forecast-alg\.git\hooks\commit-msg.sample
文件 3327 2019-12-04 10:44 sh-demand-forecast-alg\.git\hooks\fsmonitor-watchman.sample
文件 189 2019-12-04 10:44 sh-demand-forecast-alg\.git\hooks\post-update.sample
文件 424 2019-12-04 10:44 sh-demand-forecast-alg\.git\hooks\pre-applypatch.sample
文件 1638 2019-12-04 10:44 sh-demand-forecast-alg\.git\hooks\pre-commit.sample
文件 1348 2019-12-04 10:44 sh-demand-forecast-alg\.git\hooks\pre-push.sample
文件 4898 2019-12-04 10:44 sh-demand-forecast-alg\.git\hooks\pre-reba
文件 544 2019-12-04 10:44 sh-demand-forecast-alg\.git\hooks\pre-receive.sample
文件 1492 2019-12-04 10:44 sh-demand-forecast-alg\.git\hooks\prepare-commit-msg.sample
文件 3610 2019-12-04 10:44 sh-demand-forecast-alg\.git\hooks\update.sample
文件 1863 2019-12-04 10:44 sh-demand-forecast-alg\.git\index
目录 0 2019-12-04 10:44 sh-demand-forecast-alg\.git\info\
文件 240 2019-12-04 10:44 sh-demand-forecast-alg\.git\info\exclude
目录 0 2019-12-04 10:44 sh-demand-forecast-alg\.git\logs\
文件 213 2019-12-04 10:44 sh-demand-forecast-alg\.git\logs\HEAD
目录 0 2019-12-04 10:44 sh-demand-forecast-alg\.git\logs\refs\
目录 0 2019-12-04 10:44 sh-demand-forecast-alg\.git\logs\refs\heads\
文件 213 2019-12-04 10:44 sh-demand-forecast-alg\.git\logs\refs\heads\master
目录 0 2019-12-04 10:44 sh-demand-forecast-alg\.git\logs\refs\remotes\
目录 0 2019-12-04 10:44 sh-demand-forecast-alg\.git\logs\refs\remotes\origin\
文件 213 2019-12-04 10:44 sh-demand-forecast-alg\.git\logs\refs\remotes\origin\HEAD
目录 0 2019-12-04 10:44 sh-demand-forecast-alg\.git\ob
目录 0 2019-12-04 10:44 sh-demand-forecast-alg\.git\ob
............此处省略165个文件信息
相关资源
- vmware_keygen_20180725.zip
- 中国省份和城市对照表及城市分级.
- cudnn8.0.txt
- IWO.rar.zip
- meituan_spider.rar
- pb做监控系统.zip
- 盗号木马源码.rar
- text.hex
- Intouch2014R2-2099.rar
- 老虎机程序v1.1.rar
- ITSS通用标准.pdf
- MUI全套视频教程地址.txt
- ccnbie.doc
- supplyair_2755453.zip
- 中国菜刀.txt
- TCP_Socket.zip
- QQctangyunxiangc.rar
- 东华-表结构资料.zip
- 敏感词词库.txt
- sunnyman2008_10945697.ap14
- Alamouti.zip
- sRGBColorCheckerBoundary.jpg
- 深入性能测试:LoadRunner性能测试、流
- Zookeeper学习.txt
- s.exe
- 编译好的opencv_conrib库.txt
- dr.com5.2.zip
- 新建文本文档.rar
- z6x36z.doc
- tech_video.zip
评论
共有 条评论