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

Q: How to preserve dataframe columns alongside predictions? #194

Closed
doctapp opened this issue Mar 1, 2017 · 7 comments
Closed

Q: How to preserve dataframe columns alongside predictions? #194

doctapp opened this issue Mar 1, 2017 · 7 comments

Comments

@doctapp
Copy link

doctapp commented Mar 1, 2017

I've trained a GBM model using the ML bindings. The problem is there's only a "predict" column when predicting. How can we preserve the original dataframe columns? I don't have any context to join back the predictions (I shouldn't need to join btw).
Thanks

@mmalohlava
Copy link
Member

Hi @doctapp,

in H2O we guarantee order of rows - so if you have a frame with rows [A, B, C], then prediction frame will follow the same order [PA, PB, PC].

@mmalohlava
Copy link
Member

mmalohlava commented Mar 1, 2017

If you have H2OFrame DATA and prediction frame P you can write

val dataFrame: H2OFrame = ...
val predFrame: H2OFrame = ...

dataAndPredFrame = dataFrame.add(predFrame)

Note: The result dataAndPredFrame is sharing columns with dataFrame, predFrame. No copy happened.

@doctapp
Copy link
Author

doctapp commented Mar 1, 2017 via email

@mmalohlava
Copy link
Member

@doctapp are you using Scala API? in such case it is another expression after model predict call.

val predFrame = gbmModel.predict(dataFrame)
dataAndPredFrame = dataFrame.add(predFrame)

If you are using R/Python interface you need to use cbind to join both tables together.

@doctapp
Copy link
Author

doctapp commented Mar 1, 2017 via email

@mmalohlava
Copy link
Member

👍 nice!

@mmalohlava
Copy link
Member

We can do that as optional parameter for ML package...

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

No branches or pull requests

3 participants