iobjectspy.ml.spacetime package

Module contents

class iobjectspy.ml.spacetime.DataPreparation

Bases: object

data preparation process entrance for graph spatial-temporal analysis

static create_adj_mx(input_pts_coords, output_dir, id_col='0', long_col='1', lat_col='2', dist_file=None)

adjacency matrix generation

Parameters:
  • input_pts_coords (str) – input the point coordinates file
  • output_dir (str) – output the directory for adjacency matrix
  • id_col (str) – index of the ‘id’ field, the default is “0”
  • long_col (str) – index of the longitude field, the default is “1”
  • lat_col (str) – index of the latitude field, the default is “2”
  • dist_file (str) – path of the distance information file, includes the ‘from’ node ‘id’ and ‘to’ node ‘id’. And the distance between each ‘from-to’ pairs.
static create_training_data(input_data, output_dir=None, train_rate=0.7, test_rate=0.2, index_col='0', period_len=3, step_rows=12, period_steps=24, period_units='D', add_time_in_period=True)

Training data generation

Parameters:
  • input_data (str) – path of the original tabular data, supports ‘csv’ format. Each column represents a sendort location, and each row represents a moment.
  • output_dir (str) – output directory for training dataset, test dataset and other data.
  • train_rate (float) – the training dataset ratio, the default is 0.7
  • test_rate (float) – the test dataset ratio, default 0.2
  • index_col (str or int) – serial number of the ‘time index’ column, the default is “0”
  • period_len (int) – length of the time period feature, the default is 3
  • step_rows (int) – number of rows in a time step, the default is 12
  • period_steps (int) – number of time steps included in a time period, the default is 24
  • period_units (str) – time period unit, the default is “D”, which means days
  • add_time_in_period – whether to add periodic features, the default is True
  • add_time_in_period – bool
class iobjectspy.ml.spacetime.Trainer(train_data_path, config, epochs=5, batch_size=1, lr=0.01, output_model_path=None, checkpoint_filename=None, **kwargs)

Bases: object

Entry of Deep Learning Training Function

Parameters:
  • train_data_path (str) – training data path
  • config (str) – configuration file path
graphst_regression_train()

training function of graph space-time deep learning

The generated model will be stored in the ‘output_model_path’ you entered

Returns:None
class iobjectspy.ml.spacetime.Inference(input_data_dir, model_path, out_data, location_data_path=None, out_dataset_name='graph_st_predictions', add_index_before=False, fields_as_point=['longitude', 'latitude'])

Bases: object

Entrance of the graph spatio-temporal regression model inference

Parameters:
  • input_data_dir (str) – file directory where the data to be inferred
  • model_path (str) – model storage path
  • out_data (str) – output file path
  • add_index_before (bool) – whether to automatically add a index field as the first column of the ‘location_data’ table when generate the prediction vector result. The default is ‘False’, indicating that the first column of location_data already has index information.
graph_st_regress_infer(**kwargs)

Traffic flow prediction based on graph spatial-temporal regression

The input and output files are ‘numpy’ binary serialized files (*.npz)

Parameters:result_type (list) – return result type
Returns:if ‘location_data_path’ is provided, return the prediction result of the vector dataset, otherwise return the prediction result and GroundTruth list data