libcity.data.dataset.eta_encoder

class libcity.data.dataset.eta_encoder.DeeptteEncoder(config)[source]

Bases: libcity.data.dataset.eta_encoder.abstract_eta_encoder.AbstractETAEncoder

encode(uid, trajectories, dyna_feature_column)[source]

Encode trajectories of user uid.

Parameters
  • uid (int) – The uid of user. If there is no need to encode uid, just keep it.

  • trajectories (list of trajectory) – The trajectories of user. Each trajectory is

  • sequence of spatiotemporal point. The spatiotemporal point is represented by (a) –

  • list. Thus (a) –

    trajectory1 = [

    [dyna_id, type, time, entity_id, traj_id, coordinates/location, properties], [dyna_id, type, time, entity_id, traj_id, coordinates/location, properties], …..

    ]

  • trajectory is represented by a list of lists. For example (a) –

    trajectory1 = [

    [dyna_id, type, time, entity_id, traj_id, coordinates/location, properties], [dyna_id, type, time, entity_id, traj_id, coordinates/location, properties], …..

    ]

  • spatiotemporal tuple contains all useful information in a record of the Raw (Every) –

  • Data (refer to corresponding .dyna file for details) –

  • represented as (are) –

    [
    [ # trajectory1

    [dyna_id, type, time, entity_id, traj_id, coordinates/location, properties], [dyna_id, type, time, entity_id, traj_id, coordinates/location, properties], …

    ], trajectory2, …

    ]

  • dyna_feature_column (dict) – The key is a feature’s name and the value should be corresponding column id in .dyna file.

Returns

The return value of this function is the list of encoded trajectories. Same as the input format, each encoded trajectory should be a tuple, which contains all features extracted from the input trajectory. The encoded trajectory will subsequently be converted to a torch.tensor and then directly input to the model. (see more in libcity.Batch) Take the DeeptteEncoder as an example.

encoded_trajectory = [current_longi, current_lati, current_tim, current_dis, current_state,

uid, weekid, timeid, dist, time]

Please make sure the order of the features in the list is consistent with the order of the features in self.feature_dict.

Return type

list

gen_data_feature()[source]

After encode all trajectories, this method will be called to tell encoder that you can generate the data_feature and pad_item

gen_scalar_data_feature(train_data)[source]
class libcity.data.dataset.eta_encoder.TtpnetEncoder(config)[source]

Bases: libcity.data.dataset.eta_encoder.abstract_eta_encoder.AbstractETAEncoder

encode(uid, trajectories, dyna_feature_column)[source]

Encode trajectories of user uid.

Parameters
  • uid (int) – The uid of user. If there is no need to encode uid, just keep it.

  • trajectories (list of trajectory) – The trajectories of user. Each trajectory is

  • sequence of spatiotemporal point. The spatiotemporal point is represented by (a) –

  • list. Thus (a) –

    trajectory1 = [

    [dyna_id, type, time, entity_id, traj_id, coordinates/location, properties], [dyna_id, type, time, entity_id, traj_id, coordinates/location, properties], …..

    ]

  • trajectory is represented by a list of lists. For example (a) –

    trajectory1 = [

    [dyna_id, type, time, entity_id, traj_id, coordinates/location, properties], [dyna_id, type, time, entity_id, traj_id, coordinates/location, properties], …..

    ]

  • spatiotemporal tuple contains all useful information in a record of the Raw (Every) –

  • Data (refer to corresponding .dyna file for details) –

  • represented as (are) –

    [
    [ # trajectory1

    [dyna_id, type, time, entity_id, traj_id, coordinates/location, properties], [dyna_id, type, time, entity_id, traj_id, coordinates/location, properties], …

    ], trajectory2, …

    ]

  • dyna_feature_column (dict) – The key is a feature’s name and the value should be corresponding column id in .dyna file.

Returns

The return value of this function is the list of encoded trajectories. Same as the input format, each encoded trajectory should be a tuple, which contains all features extracted from the input trajectory. The encoded trajectory will subsequently be converted to a torch.tensor and then directly input to the model. (see more in libcity.Batch) Take the DeeptteEncoder as an example.

encoded_trajectory = [current_longi, current_lati, current_tim, current_dis, current_state,

uid, weekid, timeid, dist, time]

Please make sure the order of the features in the list is consistent with the order of the features in self.feature_dict.

Return type

list

gen_data_feature()[source]

After encode all trajectories, this method will be called to tell encoder that you can generate the data_feature and pad_item

gen_scalar_data_feature(train_data)[source]