Skip to content

Rewriting everything in a cleaner, better way #16

@matteobecchi

Description

@matteobecchi

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions