It would be very nice to re-write onion entirely, in order to
- simplify the code, which is the result of many iterations and trial and errors
- have one single function that does, in the same way, both the univariate and the multivariate cases
- make the plot functions method of some class, in order to avoid passing tons of parameters.
An overview of the final code could be:
- One sigle public class,
Onion(parameters), which has a method Onion.predict(data, t_list) which does onion clustering on data with time resolution delta_t. After the .predict() method has been called, the Onion object has the results in its attributes.
- When an instance of
Onion is created, it creates an instance of OnionParams(parameters), which makes sure that all the necessary hyper-parameters of the analysis are available for the subsequent calculations.
- When
.predict() is called, if creates an instance of OnionData(data), which contains the data and an array for the labels.
- Then, the iterative algorithm of onion clustering is called, using copies of
OnionData to store the clustering at each iteration, until a termination condition is met.
- Results are saved as attributes of the
Onion class. There is no need for the StateUni and StateMulti classes, these information should be stored in a dict. Labels are stored in a np.array of int. Possibly, all the calculations information can be saved in a log attribute to allow easy debugging.
- With this setup, it is then possible to rewrite all the plotting functions as methods of the
Onion class, avoiding a lot of annoying parameters to be passed around.
For the second point: the logic used in the multivariate case should be applied in all cases, because it's faster. This could be the part that takes more effort, and it will change (hopefully, just slightly) the results with respect to the previous versions.
It would be very nice to re-write onion entirely, in order to
An overview of the final code could be:
Onion(parameters), which has a methodOnion.predict(data, t_list)which does onion clustering ondatawith time resolutiondelta_t. After the.predict()method has been called, theOnionobject has the results in its attributes.Onionis created, it creates an instance ofOnionParams(parameters), which makes sure that all the necessary hyper-parameters of the analysis are available for the subsequent calculations..predict()is called, if creates an instance ofOnionData(data), which contains the data and an array for the labels.OnionDatato store the clustering at each iteration, until a termination condition is met.Onionclass. There is no need for theStateUniandStateMulticlasses, these information should be stored in adict. Labels are stored in anp.arrayofint. Possibly, all the calculations information can be saved in alogattribute to allow easy debugging.Onionclass, avoiding a lot of annoying parameters to be passed around.For the second point: the logic used in the multivariate case should be applied in all cases, because it's faster. This could be the part that takes more effort, and it will change (hopefully, just slightly) the results with respect to the previous versions.