Skip to content

code-arrangement for Similarity utilities #53

Closed

Description

@mschrimpf

A Similarity takes as input assembly1, assembly2 and outputs a Score object.

As of now, there are two kinds of similarities:

  1. non-parametric, such as the RDMSimilarity: compute similarity of two assemblies directly
  2. parametric, such as the NeuralFit: first fit on a training set, then predict on a test set and compute similarity based on the predictions

We also have additional utility on top of the simple case:

  1. compute the outer-product of combinations of all adjacent dimensions (i.e. dimensions that are not used for the Similarity such as region).
  2. cross-validate with several folds over a dimension that Similarity is computed over, e.g. object_name as part of presentation

There are several ways to organize the code around this:

  1. sub-classing (this is the way it is organized now): there is a parent class OuterCrossValidationSimilarity that all Similarity classes need to inherit from. This parent class implements (1) and (2) from above and sub-classes only need to implement the simple case. Drawbacks:
    1.1 harder to test since all sub-classes drag the parent code with them
    1.2 we can't just implement apply in our sub-classes but need to adjust the method name
    1.3 we can't compute similarity without the extra baggage, i.e. everything is always cross-validated
  2. chaining: each Similarity class implements exactly one operation in apply. A chain operator then takes all these classes, applies them one after another and outputs only the final result. The result here is a list of assemblies which are then fed into a Score in Similarity.__call__. However, I don't know how to represent parametric and non-parametric similarities with this approach (one has to fit, predict, compare_prediction, the other just has to compare)
  3. extract the computor from Similarity: all the specialized handling ((1) and (2) from utilities) goes into Similarity sub-classes, operation on simplified assemblies goes into a Computor class. Hard to separate the two though, for instance Similarity still needs to call fit, predict etc.

For now, approach (1) works but after NIPS, I would like to revisit the structuring here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions