Can't view prediction result with built model in R












0














I'm a beginner with R, and just had some trouble with the prediction function.
I built a Random Forest model with h2o, where the y is 0/1(buy/no buy).
Then, I tried to use the predict() function to apply the model to a new dataset
eg: pre=predict(rf,test_data)



I can see the summary of my prediction result like below:



> summary(pre)
predict p0 p1
0:998 Min. :0.0000 Min. :5.601e-05
1: 97 1st Qu.:0.9989 1st Qu.:5.601e-05
Median :0.9989 Median :5.601e-05
Mean :0.9150 Mean :8.498e-02
3rd Qu.:0.9989 3rd Qu.:5.601e-05
Max. :0.9999 Max. :1.000e+00


But, I couldn't View() my prediction result as a list. Here is what I got when using View(pre):



enter image description here



Ultimately, I'd like to know which row has been predicted as 1(buy), which row has been predicted as 0(no buy). Does anyone know how to resolve this issue?
thanks a lot!










share|improve this question
























  • You just need to print(pre) to see the prediction result for each row.
    – TeeKea
    Nov 23 '18 at 6:15










  • use pre_df <- as.data.frame(pre) to get it in R
    – s.brunel
    Nov 23 '18 at 7:44












  • hi s.brunel, thanks a lot! this works!
    – yixuan
    Nov 26 '18 at 15:40
















0














I'm a beginner with R, and just had some trouble with the prediction function.
I built a Random Forest model with h2o, where the y is 0/1(buy/no buy).
Then, I tried to use the predict() function to apply the model to a new dataset
eg: pre=predict(rf,test_data)



I can see the summary of my prediction result like below:



> summary(pre)
predict p0 p1
0:998 Min. :0.0000 Min. :5.601e-05
1: 97 1st Qu.:0.9989 1st Qu.:5.601e-05
Median :0.9989 Median :5.601e-05
Mean :0.9150 Mean :8.498e-02
3rd Qu.:0.9989 3rd Qu.:5.601e-05
Max. :0.9999 Max. :1.000e+00


But, I couldn't View() my prediction result as a list. Here is what I got when using View(pre):



enter image description here



Ultimately, I'd like to know which row has been predicted as 1(buy), which row has been predicted as 0(no buy). Does anyone know how to resolve this issue?
thanks a lot!










share|improve this question
























  • You just need to print(pre) to see the prediction result for each row.
    – TeeKea
    Nov 23 '18 at 6:15










  • use pre_df <- as.data.frame(pre) to get it in R
    – s.brunel
    Nov 23 '18 at 7:44












  • hi s.brunel, thanks a lot! this works!
    – yixuan
    Nov 26 '18 at 15:40














0












0








0







I'm a beginner with R, and just had some trouble with the prediction function.
I built a Random Forest model with h2o, where the y is 0/1(buy/no buy).
Then, I tried to use the predict() function to apply the model to a new dataset
eg: pre=predict(rf,test_data)



I can see the summary of my prediction result like below:



> summary(pre)
predict p0 p1
0:998 Min. :0.0000 Min. :5.601e-05
1: 97 1st Qu.:0.9989 1st Qu.:5.601e-05
Median :0.9989 Median :5.601e-05
Mean :0.9150 Mean :8.498e-02
3rd Qu.:0.9989 3rd Qu.:5.601e-05
Max. :0.9999 Max. :1.000e+00


But, I couldn't View() my prediction result as a list. Here is what I got when using View(pre):



enter image description here



Ultimately, I'd like to know which row has been predicted as 1(buy), which row has been predicted as 0(no buy). Does anyone know how to resolve this issue?
thanks a lot!










share|improve this question















I'm a beginner with R, and just had some trouble with the prediction function.
I built a Random Forest model with h2o, where the y is 0/1(buy/no buy).
Then, I tried to use the predict() function to apply the model to a new dataset
eg: pre=predict(rf,test_data)



I can see the summary of my prediction result like below:



> summary(pre)
predict p0 p1
0:998 Min. :0.0000 Min. :5.601e-05
1: 97 1st Qu.:0.9989 1st Qu.:5.601e-05
Median :0.9989 Median :5.601e-05
Mean :0.9150 Mean :8.498e-02
3rd Qu.:0.9989 3rd Qu.:5.601e-05
Max. :0.9999 Max. :1.000e+00


But, I couldn't View() my prediction result as a list. Here is what I got when using View(pre):



enter image description here



Ultimately, I'd like to know which row has been predicted as 1(buy), which row has been predicted as 0(no buy). Does anyone know how to resolve this issue?
thanks a lot!







r h2o






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 7:12









Marcus Campbell

2,01921027




2,01921027










asked Nov 23 '18 at 5:42









yixuan

1




1












  • You just need to print(pre) to see the prediction result for each row.
    – TeeKea
    Nov 23 '18 at 6:15










  • use pre_df <- as.data.frame(pre) to get it in R
    – s.brunel
    Nov 23 '18 at 7:44












  • hi s.brunel, thanks a lot! this works!
    – yixuan
    Nov 26 '18 at 15:40


















  • You just need to print(pre) to see the prediction result for each row.
    – TeeKea
    Nov 23 '18 at 6:15










  • use pre_df <- as.data.frame(pre) to get it in R
    – s.brunel
    Nov 23 '18 at 7:44












  • hi s.brunel, thanks a lot! this works!
    – yixuan
    Nov 26 '18 at 15:40
















You just need to print(pre) to see the prediction result for each row.
– TeeKea
Nov 23 '18 at 6:15




You just need to print(pre) to see the prediction result for each row.
– TeeKea
Nov 23 '18 at 6:15












use pre_df <- as.data.frame(pre) to get it in R
– s.brunel
Nov 23 '18 at 7:44






use pre_df <- as.data.frame(pre) to get it in R
– s.brunel
Nov 23 '18 at 7:44














hi s.brunel, thanks a lot! this works!
– yixuan
Nov 26 '18 at 15:40




hi s.brunel, thanks a lot! this works!
– yixuan
Nov 26 '18 at 15:40












2 Answers
2






active

oldest

votes


















0














@s.brunel has the right answer. Keep in mind when writing routines that with binary predictions it will return three variables. Whereas when predicting a continuous variable you get a single variable.






share|improve this answer





























    0














    posting the answer to make it easier to find.



    If you want to use R functions on an H2OFrame you will first need to convert that H2OFrame to an R frame and you can do that as follows for your particular case:



    pre_df <- as.data.frame(pre)


    Please also note that some H2O functions use the same naming convention as R functions, so while you may think the summary() function was an R function it was actually the H2O summary() function which does the same thing as the R function but for an H2OFrame.






    share|improve this answer





















      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53441181%2fcant-view-prediction-result-with-built-model-in-r%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      @s.brunel has the right answer. Keep in mind when writing routines that with binary predictions it will return three variables. Whereas when predicting a continuous variable you get a single variable.






      share|improve this answer


























        0














        @s.brunel has the right answer. Keep in mind when writing routines that with binary predictions it will return three variables. Whereas when predicting a continuous variable you get a single variable.






        share|improve this answer
























          0












          0








          0






          @s.brunel has the right answer. Keep in mind when writing routines that with binary predictions it will return three variables. Whereas when predicting a continuous variable you get a single variable.






          share|improve this answer












          @s.brunel has the right answer. Keep in mind when writing routines that with binary predictions it will return three variables. Whereas when predicting a continuous variable you get a single variable.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 28 '18 at 14:53









          Jsimp

          62




          62

























              0














              posting the answer to make it easier to find.



              If you want to use R functions on an H2OFrame you will first need to convert that H2OFrame to an R frame and you can do that as follows for your particular case:



              pre_df <- as.data.frame(pre)


              Please also note that some H2O functions use the same naming convention as R functions, so while you may think the summary() function was an R function it was actually the H2O summary() function which does the same thing as the R function but for an H2OFrame.






              share|improve this answer


























                0














                posting the answer to make it easier to find.



                If you want to use R functions on an H2OFrame you will first need to convert that H2OFrame to an R frame and you can do that as follows for your particular case:



                pre_df <- as.data.frame(pre)


                Please also note that some H2O functions use the same naming convention as R functions, so while you may think the summary() function was an R function it was actually the H2O summary() function which does the same thing as the R function but for an H2OFrame.






                share|improve this answer
























                  0












                  0








                  0






                  posting the answer to make it easier to find.



                  If you want to use R functions on an H2OFrame you will first need to convert that H2OFrame to an R frame and you can do that as follows for your particular case:



                  pre_df <- as.data.frame(pre)


                  Please also note that some H2O functions use the same naming convention as R functions, so while you may think the summary() function was an R function it was actually the H2O summary() function which does the same thing as the R function but for an H2OFrame.






                  share|improve this answer












                  posting the answer to make it easier to find.



                  If you want to use R functions on an H2OFrame you will first need to convert that H2OFrame to an R frame and you can do that as follows for your particular case:



                  pre_df <- as.data.frame(pre)


                  Please also note that some H2O functions use the same naming convention as R functions, so while you may think the summary() function was an R function it was actually the H2O summary() function which does the same thing as the R function but for an H2OFrame.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 29 '18 at 20:39









                  Lauren

                  3,0111515




                  3,0111515






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53441181%2fcant-view-prediction-result-with-built-model-in-r%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Basket-ball féminin

                      Different font size/position of beamer's navigation symbols template's content depending on regular/plain...

                      I want to find a topological embedding $f : X rightarrow Y$ and $g: Y rightarrow X$, yet $X$ is not...