libcity.utils.utils

libcity.utils.utils.ensure_dir(dir_path)[source]

Make sure the directory exists, if it does not exist, create it.

Parameters

dir_path (str) – directory path

libcity.utils.utils.get_evaluator(config)[source]

according the config[‘evaluator’] to create the evaluator

Parameters

config (ConfigParser) – config

Returns

the loaded evaluator

Return type

AbstractEvaluator

libcity.utils.utils.get_executor(config, model, data_feature)[source]

according the config[‘executor’] to create the executor

Parameters
Returns

the loaded executor

Return type

AbstractExecutor

libcity.utils.utils.get_local_time()[source]

获取时间

Returns

时间

Return type

datetime

libcity.utils.utils.get_logger(config, name=None)[source]

获取Logger对象

Parameters
Returns

logger

Return type

Logger

libcity.utils.utils.get_model(config, data_feature)[source]

according the config[‘model’] to create the model

Parameters
  • config (ConfigParser) – config

  • data_feature (dict) – feature of the data

Returns

the loaded model

Return type

AbstractModel

libcity.utils.utils.preprocess_data(data, config)[source]

split by input_window and output_window

Parameters

data – shape (T, …)

Returns

(train_size/test_size, input_window, …)

(train_size/test_size, output_window, …)

Return type

np.ndarray

libcity.utils.utils.set_random_seed(seed)[source]

重置随机数种子

Parameters

seed (int) – 种子数

libcity.utils.utils.trans_naming_rule(origin, origin_rule, target_rule)[source]

名字转换规则

Parameters
  • origin (str) – 源命名格式下的变量名

  • origin_rule (str) – 源命名格式,枚举类

  • target_rule (str) – 目标命名格式,枚举类

Returns

转换之后的结果

Return type

target (str)