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

Making sure that predict always returns a vector or data.frame #26

Open
drsimonj opened this issue Jun 5, 2017 · 3 comments
Open

Making sure that predict always returns a vector or data.frame #26

drsimonj opened this issue Jun 5, 2017 · 3 comments

Comments

@drsimonj
Copy link
Owner

drsimonj commented Jun 5, 2017

predict should always return a set of predicted values that match the data. twidlr can support various tidy functionality by always ensuring that the returned result is a vector or data.frame.

Vector would be returned for a single set of predictions, and a data.frame would be returned for multiple sets of predictions like those generated by naiveBayes or glmnet.

This would support functions similar to modelr's add_predictions, but using twidlr::predict rather than stats::predict, and passing ....

@drsimonj
Copy link
Owner Author

drsimonj commented Jun 5, 2017

This would likely involve a generic function that checks predict output and coerces results to expected output. Eg checks for things like matrices, or data.frames with single values, etc.

@drsimonj
Copy link
Owner Author

drsimonj commented Jun 5, 2017

In the case of a single set of predictions, must consider whether a vector is preferred to a data.frame of one column. By having vector or data.frame, this could lead to confusion, as the output structure is not always the same. On the other hand, having a data.frame of one column is inconvenient in many cases (eg in dplyr::mutate statements).

@drsimonj
Copy link
Owner Author

drsimonj commented Jun 6, 2017

After posting question on Twitter, a few notes came up about cases where this may not apply:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant