Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shapes of input data #22

Open
LaurentBerder opened this issue Apr 12, 2023 · 4 comments
Open

Shapes of input data #22

LaurentBerder opened this issue Apr 12, 2023 · 4 comments

Comments

@LaurentBerder
Copy link

LaurentBerder commented Apr 12, 2023

Hi,

I just installed tsl, having been really interested in your code and documentation.

However, I realize that I don't know where to start to create my own dataset. The only examle codes I see are using samples already included inyour library.

If I have these three pandas DataFrame (details of their columns below), how would I go creating my SpatioTemporalDataset object?

  • features: DAY, NODE, NODE_FEATURE_1, NODE_FEATURE_2, NODE_FEATURE_3
  • targets: DAY, NODE, TARGET
  • edges: DAY, ORIGIN, DESTINATION, EDGE_FEATURE
@LaurentBerder
Copy link
Author

The data I'm trying to model is a dynamic graph (my edge features evolve over time).
Based on the documentation, I tried the following:

from tsl.data import SpatioTemporalDataset

connectivity = (
        edges.pivot(index=['DAY', 'ORIGIN'], columns='DESTINATION', values='EDGE_FEATURE'),
        edges[['DAY', 'ORIGIN', 'DESTINATION']].drop_duplicates()
)
dataset = SpatioTemporalDataset(target=pd.pivot(targets, index='DAY', columns='NODE', values='TARGET'),
                                                       connectivity=connectivity,
                                                       horizon=12, window=12, stride=1
)

But that only resulted in the following trace:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/usr/local/lib/python3.9/dist-packages/tsl/data/spatiotemporal_dataset.py in __init__(self, target, index, mask, connectivity, covariates, input_map, target_map, auxiliary_map, scalers, trend, transform, window, horizon, delay, stride, window_lag, horizon_lag, precision, name)
    187         self.edge_index: Optional[Adj] = None
    188         self.edge_weight: Optional[Tensor] = None
--> 189         self.set_connectivity(connectivity)
    190 
    191         # Store covariates (e.g., exogenous and attributes)

/usr/local/lib/python3.9/dist-packages/tsl/data/spatiotemporal_dataset.py in set_connectivity(self, connectivity, target_layout)
    835                 (default: :obj:`None`)
    836         """
--> 837         self.edge_index, self.edge_weight = self._parse_connectivity(
    838             connectivity, target_layout)
    839 

/usr/local/lib/python3.9/dist-packages/tsl/data/mixin.py in _parse_connectivity(self, connectivity, target_layout)
     67             edge_index, edge_weight = connectivity
     68             if edge_weight is not None:
---> 69                 edge_weight = casting.convert_precision_tensor(
     70                     edge_weight, self.precision)
     71         else:

/usr/local/lib/python3.9/dist-packages/tsl/utils/casting.py in convert_precision_tensor(tensor, precision)
     38     precision = precision_stoi(precision)
     39     dtype = tensor.dtype() if isinstance(tensor,
---> 40                                          SparseTensor) else tensor.dtype
     41     # float to float{precision}
     42     if dtype in [torch.float16, torch.float32, torch.float64]:

/usr/local/lib/python3.9/dist-packages/pandas/core/generic.py in __getattr__(self, name)
   5573         """
   5574         # Note: obj.x will always call obj.__getattribute__('x') prior to
-> 5575         # calling obj.__getattr__('x').
   5576         if (
   5577             name not in self._internal_names_set

AttributeError: 'DataFrame' object has no attribute 'dtype'

@ghost
Copy link

ghost commented Aug 18, 2023

@LaurentBerder did you manage to figure this out? I have the same issue.

/cc @andreacini

@LaurentBerder
Copy link
Author

@LaurentBerder did you manage to figure this out? I have the same issue.

Nope, I abandonned the project. Sorry.

@KoperSloper
Copy link

Having the same problem. Still no example of creating your own dataset?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants