Skip to content

ValueError: The parameter loc has invalid values #353

Description

@a1code

Environment Details

Please indicate the following details about the environment in which you found the bug:

  • SDV version: 0.8.0
  • Python version: 3.7.10
  • Operating System: Google Colaboratory Notebook

Error Description

Dataframe columns :
ticker object
date datetime64[ns]
Close float64
Low float64
High float64
Open float64
Volume float64
ff_co_name object
ff_major_ind_name object
fg_factset_ind object
exchange object
dtype: object

On running model.fit on this time series data, the execution fails with the error message ValueError: The parameter loc has invalid values.

Steps to reproduce

dailytimeseries.csv.zip

  1. Extract the dailytimeseries.csv.zip file.
  2. Run the code below.
    daily_timeseries = pd.read_csv('dailytimeseries.csv')
    entity_columns = ["ticker"]
    context_columns = ["ff_co_name", "ff_major_ind_name", "fg_factset_ind", "exchange"]
    sequence_index = "date"
    model = PAR(entity_columns=entity_columns, context_columns=context_columns, sequence_index=sequence_index,)
    model.fit(daily_timeseries)
/usr/local/lib/python3.7/dist-packages/scipy/stats/_continuous_distns.py:4798: RuntimeWarning: divide by zero encountered in true_divide
  return c**2 / (c**2 - n**2)
/usr/local/lib/python3.7/dist-packages/scipy/stats/_distn_infrastructure.py:2407: RuntimeWarning: invalid value encountered in double_scalars
  Lhat = muhat - Shat*mu
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-29-c1a28f080e61> in <module>()
----> 1 model.fit(daily_timeseries)

5 frames
/usr/local/lib/python3.7/dist-packages/sdv/timeseries/base.py in fit(self, timeseries_data)
    207 
    208         LOGGER.debug('Fitting %s model to table %s', self.__class__.__name__, self._metadata.name)
--> 209         self._fit(transformed)
    210 
    211     def get_metadata(self):

/usr/local/lib/python3.7/dist-packages/sdv/timeseries/deepecho.py in _fit(self, timeseries_data)
     83 
     84         # Validate and fit
---> 85         self._model.fit_sequences(sequences, context_types, data_types)
     86 
     87     def _sample(self, context=None, sequence_length=None):

/usr/local/lib/python3.7/dist-packages/deepecho/models/par.py in fit_sequences(self, sequences, context_types, data_types)
    330 
    331             optimizer.zero_grad()
--> 332             loss = self._compute_loss(X_padded[1:, :, :], Y_padded[:-1, :, :], seq_len)
    333             loss.backward()
    334             if self.verbose:

/usr/local/lib/python3.7/dist-packages/deepecho/models/par.py in _compute_loss(self, X_padded, Y_padded, seq_len)
    368                 for i in range(batch_size):
    369                     dist = torch.distributions.normal.Normal(
--> 370                         mu[:seq_len[i], i], sigma[:seq_len[i], i])
    371                     log_likelihood += torch.sum(dist.log_prob(X_padded[-seq_len[i]:, i, mu_idx]))
    372 

/usr/local/lib/python3.7/dist-packages/torch/distributions/normal.py in __init__(self, loc, scale, validate_args)
     48         else:
     49             batch_shape = self.loc.size()
---> 50         super(Normal, self).__init__(batch_shape, validate_args=validate_args)
     51 
     52     def expand(self, batch_shape, _instance=None):

/usr/local/lib/python3.7/dist-packages/torch/distributions/distribution.py in __init__(self, batch_shape, event_shape, validate_args)
     51                     continue  # skip checking lazily-constructed args
     52                 if not constraint.check(getattr(self, param)).all():
---> 53                     raise ValueError("The parameter {} has invalid values".format(param))
     54         super(Distribution, self).__init__()
     55 

ValueError: The parameter loc has invalid values

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions