neurospin / pylearn-parsimony_history

Sparse and Structured Machine Learning in Python
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

Algorithms: API and directory structure. #17

Closed tomlof closed 10 years ago

tomlof commented 10 years ago

API

It does not feel good to have the algorithms callable. I don't remember what we wanted to achieve with that. Do you remember?

We currently have the following call sequence:

function = SomeFunction(...)
algorithm = SomeAlgorithm()
beta = algorithm(function, ...)

I propose to change this into:

function = SomeFunction(...)
algorithm = SomeAlgorithm()
beta = algorithm.run(function, ...)

Grammatically, algorithms are run or applied, but I think the verb run is ok to use here.

What do you think?

Directory structure

I propose to do the same kind of change to the algorithms that we have done to the functions. The algorithms file is getting very large, and I think it would be better if we split it in something like the following structure:

algorithms/interfaces.py
algorithms/utils.py
algorithms/implicit.py
algorithms/explicit.py

Interfaces would contain abstract and base classes, utils would contain algorithms that are used everywhere (such as the Bisection algorithm) and other useful things; implicit.py would include algorithms that does not minimise a given function, but have an implicit criterion that is minimised or maximised. This would include e.g. FastSVD, but could include clustering algorithms in the future for instance. Finally, explicit.py would include ISTA, FISTA, ExcessiveGapMethod etc., algorithms that take an explicit function, and minimises it.

What do you think about this?

duchesnay commented 10 years ago

+1 for your proposition

tomlof commented 10 years ago

I have now updated this. I changed interfaces to bases, to avoid confusion with function interfaces.

However, I am not sure about the distinction between implicit and explicit algorithms. Maybe we should have modules for different types of algorithms instead? Such as NIPALS based algorithms in nipals.py, first order descent algorithms in gradient_descent.py and so on.

What do you think?