I am currently trying to model a Multivariate Random Forest on time series data. The only way I get decent test accuracies on the model is to detrend the data before modelling using the scipy detrend type=constant (the type=linear does not give good accuracies) with the following code:
detrended =signal.detrend(feature, axis=-1, type='constant', bp=0, overwrite_data=True)
After I model the data I want to show the results of the model as the original units before detrending.
I have two questions:
- Is there a way to reverse signal.detrend?
- What exactly does the signal.detrend (type=constant) do to the data?
In the Scipy documentation I am aware of the following:
type{‘linear’, ‘constant’}, optional The type of detrending. If type == 'linear' (default), the result of a linear least-squares fit to data is subtracted from data. If type == 'constant', only the mean of data is subtracted.
However when I look at the data after performing signal.detrend (type=constat) it does not simply subtract the mean from the data as the documentation suggests.
Any guidance on how to reverse the detrend function and what the detrend type=constant does to the data would be greatly appreciated.