コード例 #1
0
def model_predict():
    path_config = global_config.PathConfig()
    param_config = global_config.ParamConfig()
    param_config.set_begin_time('2012-01')
    param_config.set_end_time('2019-5')
    param_config.set_predict_period(1)
    fca = feature_correlation_analysis.FeatureCorrelationAnalysis(
        path_config, param_config)
    fca.feature_correlation_analysis()
    data_coversion.DataCoversion(path_config, param_config).data_coversion()
    data_partitioning.DataPartition(path_config,
                                    param_config).data_partitioning()
    feature_df = fca.initial_attr_data()

    predict_time = datetime.datetime.strptime('2019-6', '%Y-%m')
    data_attr = []
    with open(path_config.attr_intro, mode='r') as f:
        for line in f:
            attr, period = line.split()
            data_attr.append(
                feature_df[attr][predict_time -
                                 dateutil.relativedelta.relativedelta(
                                     months=int(period))])
    data_array = np.array(data_attr)
    data_array = data_array[np.newaxis, :]
    model = BaggingRegression_model.final_Bagging_regression()
    data_value = model.predict(data_array)
    print(data_value)
コード例 #2
0
def initial_data(data_type=1):
    # 用于初始化数据集
    path_config = global_config.PathConfig()
    param_config = global_config.ParamConfig()
    param_config.data_type = data_type  # 数据类型
    param_config.predict_period = 1  # 预测期
    feature_correlation_analysis.FeatureCorrelationAnalysis(
        path_config, param_config).feature_correlation_analysis()
    data_coversion.DataCoversion(path_config, param_config).data_coversion()
コード例 #3
0
 def __init__(self,
              path_config=global_config.PathConfig(),
              param_config=global_config.ParamConfig()):
     self.path_config = path_config
     self.param_config = param_config
コード例 #4
0
 def __init__(self, path_config=global_config.PathConfig(), param_config=global_config.ParamConfig()):
     self.path_config = path_config
     self.param_config = param_config
     self.MAX_PERIOD = self.param_config.corr_max_period
     self.PREDICT_PERIOD = self.param_config.predict_period