Seeking advice for fitting a reduced system. Is it always feasible? #576
Unanswered
dariosannino
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I wanted to ask some help to the community for using pysindy in the proper way.
I will firstly give a bit of context:
Let's say that a system is made up of 300 interacting signals (in our case would be 300 time-series), but we reduce to 100 signals because of spatial recording limits or because we consider them to be in the regions that are mostly critical. Among these 100 time-series I can select around n of them (around 20), because I am mostly interested in these signals and because I can appreciate that they account for most of the variance in the signals.
My first idea was to try to fit these time-series to understand how they are interdependent and I tried to do that through the use of a polynomial library, but since it becomes cumbersome I preferred to move to a reduced space of 3 state variables by applying PCA on the 20 time-series.
So, let's say in the end we managed to have just 3 signals and we try to leverage pysindy to understand how their dynamics is coupled.
First thing that I did was to smooth a bit my signals and getting their ground truth derivatives, so that pysindy could go through a more robust fitting process. Here I applied a very strong smoothing hoping that pysindy could have easier life.
Then I prepared everything for the fitting process:
I plotted my pareto curve in order to know which value of
threshold
should be more appropriate for theSTLSQ
optimizer. As you may notice, I used a very low value for thealpha
parameter, because I manually saw that those regions of values were getting close to a reasonable fitting when calling thesimulate()
function. This would mean that we are not actually penalizing a lot large coefficients and we potentially risk to overfit. Hope this is not a big mistake.My pareto curve looks like this and therefore I decide to take
threshold=0.01
for my optimizerHere the main code for the fitting getting a Score on derivatives: 0.6685255985963231. I have also tried with ensemble methods but I guess they did not have good effects because my signals were already smoothed.
Now we come to the extracted equations. These could be pretty long suggesting that the threshold is very low and the degree of the polynomial is maybe too high, causing maybe some problems of interpretability or overfitting. However, both lowering the degree of the polynomial or increasing the threshold often gave me worse results.
In the current model I checked if there is an inherent instability in the linear part of the model, in order to understand if I might need to enforce additional constraints on the model to improve stability.
Here the output suggesting stability:
Linear terms of the Coefficient Matrix:
[[ 0.04212236 -0.40978422 0.58158849]
[ 0.05307033 -0.09734764 0. ]
[-0.02492854 -0.01981616 -0.01571323]]
Eigenvalues of linear term matrix: [-0.00054895+0.18148227j -0.00054895-0.18148227j -0.0698406 +0.j ]
Let's get now to the last two points. Checking the derivatives fitting and the simulation.
I checked my derivatives fitting in such a way:
Here my results, that I guess are not really promising (compared to the examples that I saw on the Lorentz system). That suggests me that while errors accumulates something could go wrong:
Trying to simulate my system starting from the first point of my time-series:
I tried to start from another initial condition and there seems to be instability there:
overflow encountered in reduce
ValueError: Input X contains infinity or a value too large for dtype('float64').
So, it seems that errors accumulates much faster from such initial condition and probably is due to the high degree of the polynomial, but still my impression was that decreasing the degree sometimes gave anyway the same type of error.
What seems to be critical here are the
threshold
,alpha
anddegree
parameters.P.S I am aware that custom library could be developed. So far I tried to concatenate and tensor two libraries together (like the polynomial and the Fourier ones), but I did not obtain good results. In particular the Fourier ones were interacting badly and needed scaling of my signal as far as I remember. Therefore I decided to stick with the polynomials trying to mimic the idea of the Lorentz example, but I don't know if my case is less trivial or I am doing some mistakes.
Hope someone could help
Beta Was this translation helpful? Give feedback.
All reactions