ColtAllen / btyd

Buy Till You Die and Customer Lifetime Value statistical models in Python.
https://btyd.readthedocs.io/
Apache License 2.0
114 stars 9 forks source link

Prediction API #30

Closed ColtAllen closed 2 years ago

ColtAllen commented 2 years ago

Modules: lifetimes.models.__init__.BaseModel class object

Issue: Currently the User API has multiple predictive methods which must have arrays passed in individually as arguments, which is clunky for the end user.

Work Summary: Add a self.predict() function with arguments for each of the predictive methods and their respective inputs. Something like this:

def predict(self, method: str, *args) -> arraylike:

    method_dict = {
        'p_alive': self.conditional_probability_alive
        'n_purchases': self.expected_number_of_purchases_up_to_time
        }

    array_out = method_dict.get(method)(*args)

    return array_out

Other Comments: method_dict will probably need to be defined outside of this method as an object of the model subclass.