Open tg2k opened 1 year ago
Hey @tg2k, thanks for using neuralforecast. The data is converted to long format, there are 100 images of 64 pixels, which become 100 unique_ids with 64 timestamps each.
I believe the problem here is that pixels
isn't defined as an exogenous feature and thus isn't being used. By adding:
hist_exog_list=['pixels'],
futr_exog_list=['pixels'],
to both models I get:
MLP Accuracy: 94.3%
NHITS Accuracy: 97.3%
Which shows that adding the pixel values helps the models. Please let us know if this helps.
Thanks @jmoralez. That's helpful, though there seems to be more to it. This technique doesn't help with the AirPassengers example. What I found is that if I call fit()
, I get the 'tuple' object has no attribute 'ndim'
error. If I change the code to use cross_validation()
, it works. The issue seems to be triggered by specifying the val_size
parameter (if I don't pass it, then fit()
runs through). Then, when the code reaches _compute_valid_loss()
it hits this block:
# Validation Loss evaluation
if self.valid_loss.is_distribution_output:
valid_loss = self.valid_loss(
y=outsample_y, distr_args=distr_args, mask=outsample_mask
)
else:
output, _, _ = self._inv_normalization(
y_hat=output, temporal_cols=temporal_cols
)
valid_loss = self.valid_loss(
y=outsample_y, y_hat=output, mask=outsample_mask
)
return valid_loss
The Accuracy()
loss function sets is_distribution_output = false
, causing the _inv_normalization()
call and y_hat
is a Tuple when it expects the ndim
attribute. I'm unclear on whether the call should be using outsample_y
instead of output
, but I tried this in some earlier debugging against my own data, ran into a downstream issue, and stopped there.
I'm also finding that with some of my own code, it seems that using the Auto models may trigger the val_size
check even if not specified. This may be because BaseAuto
has this code:
val_size = val_size if val_size > 0 else self.h
This complicates attempts to work around the error.
It looks as though the code block I posted yesterday is not compatible with the valid_loss=Accuracy()
code, but perhaps this goes undetected if not using an Auto
model and not specifying val_size
?
What happened + What you expected to happen
I ran into trouble attempting to use temporal classification. The example at https://nixtla.github.io/neuralforecast/examples/temporal_classifiers.html struck me as odd, in a few regards:
pixels
column which is neither converted into long format (https://nixtla.github.io/neuralforecast/examples/data_format.html#long-format) nor set up as an exogenous variable (https://nixtla.github.io/neuralforecast/examples/exogenous_variables.html).pixels
column got me the same result, implying that it is not used at all. I think consumers of temporal classification would generally want their primary data to be used, as opposed to the resulting classification values.Although the temporal classfiers code runs, I went looking for more real-world examples. In https://github.com/Nixtla/neuralforecast/issues/385 there was discussion about an example added to
models.nhits.ipynb
(in https://github.com/Nixtla/neuralforecast/commit/4821277708ea4584d61ae5c99e938efc34dc0bf5). This code has since been overwritten (in https://github.com/Nixtla/neuralforecast/commit/37b4b287373ff6009c3453198cf6f3ae862b0a9d) but I decided to extract it and give it a try.In this case, the line
AirPassengersPanel['y'] = 1 * (AirPassengersPanel['trend'] % 12) < 2
leads to a
validation.py
validate_format()
error:The target column ('y') should have a numeric data type, got 'bool')
Changing it to
AirPassengersPanel['y'] = np.where(1 * (AirPassengersPanel['trend'] % 12) < 2, 1, 0)
however, leads me instead to a failure during
fit()
, specifically a_base_windows.py
_inv_normalization()
error ony_hat.ndim == 2
:'tuple' object has no attribute 'ndim'
. Perhaps this is also not a good example, as it has columnsy
,trend
,y_[lag12]
and definesstat_exog_list=['airline1']
(there is no such column, thoughunique_id
in the data set contains both "Airline1" and "Airline2").Is there a clean example demonstrating temporal classification, where it is possible to verify that the results are actually degraded by removing the input data and only having the classifier data present? It would be very helpful to see the data format and whether exogenous variables are used/required.
Versions / Dependencies
neuralforecast 1.64 Python 3.11.6 WSL Ubuntu
Reproduction script
In the first script, try setting
remove_pixels
as True / False to see the results look the same.In the second script, it blows up on the
y_hat.ndim == 2
check.Issue Severity
High: It blocks me from completing my task.