Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add call_fitted_method to Vset #53

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions vflow/vset.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,19 @@ def evaluate(self, *args):
"""
return self._apply_func(*args)

def call_fitted_method(self, *args, method: str, with_uncertainty: bool=False, group_by: list=None):
if not self._fitted:
raise AttributeError('Please fit the Vset object before calling call_fitted_method.')
pred_dict = {}
for k, v in self.fitted_vfuncs.items():
if k != '__prev__':
assert hasattr(v, method), f'{v} does not have a "{method}" method.'
pred_dict[k] = getattr(v, method)
preds = self._apply_func(*args, out_dict=pred_dict)
if with_uncertainty:
return prediction_uncertainty(preds, group_by)
return preds

def __call__(self, *args, n_out: int = None, keys=None, **kwargs):
"""Call args using `_apply_func`, optionally seperating
output dictionary into `n_out` dictionaries with `keys`
Expand Down