def __init__(self, parameter_dict, path = ''): self.parameter_dict = parameter_dict if not path: path = parameter_dict['input']['raw_data_path'] file_name = parameter_dict['input']['raw_data_file_name'] feature_choice_list = parameter_dict['input']['feature_choice_str'].split(',') #LOGGING if (not path) and (not file_name): logger1.error("Parameter error, no file name and path!!") sys.exit(0) elif not path: path_now = path = os.path.abspath(__file__) folder_path = get_upper_folder_path(2, path_now) folder_path = os.path.join(folder_path, 'data') path = os.path.join(folder_path, file_name) self.path = path # testing_path, if not customize file_path, assign the training path to testing path self.testing_file_path =parameter_dict['testing']['raw_data_file_path'] self.testing_file_path = self.path self.feature_choice_list = [int(x) for x in feature_choice_list] self.raw_data_dict = parameter_dict['input']['raw_data_dict'] # set a span of the training date self.restrict_training_date = parameter_dict['input']['restrict_training_date'] if self.restrict_training_date: self.training_date_start = parameter_dict['input']['training_date_start'] self.training_date_end = parameter_dict['input']['training_date_end']
def get_upper_folder_path(num, path=''): if not path: path = os.path.dirname(os.path.abspath(__file__)) else: path = os.path.dirname(path) num -= 1 if num > 0: return get_upper_folder_path(num, path=path) else: return path
def get_upper_folder_path(num, path=''): if not path: path = os.path.dirname(os.path.abspath(__file__)) else: path = os.path.dirname(path) num -= 1 if num > 0: return get_upper_folder_path(num, path=path) else: return path import sys import os parent_folder = get_upper_folder_path(1) sys.path.append(os.path.join(parent_folder, 'pjslib')) sys.path.append(os.path.join(parent_folder)) # import from pjslib from general import get_upper_folder_path from general import accepts from logger import logger1, logger_bg, logger_s #================================================ import os import sys import re import json import collections import random from solution import Solution