liesel-devs / liesel

A probabilistic programming framework
https://liesel-project.org
MIT License
38 stars 2 forks source link

Predictions in Liesel #54

Open jobrachem opened 1 year ago

jobrachem commented 1 year ago

This issue serves as a reminder and a tracker for the discussion about convenience functionality for predictions in Liesel. Currently, we do not really offer much in that regard.

I propose that we could let certain lsl.Group child-classes know about how they want to be used for prediction, for example:

class PSpline(lsl.Group):

    def predict(self, samples, new_data) -> Array:

        coef_samples = samples[self.coef.name]
        basis_matrix = self.basis_matrix.eval_basis_funs(new_data)
        smooth = np.tensordot(
            basis_matrix, coef_samples, axes=([1], [-1])
        )

        return np.moveaxis(smooth, 0, -1) # makes axes fit to samples

What's more, @wiep mentioned that it may be nice to utilize the model graph for predictions.