Go to TogaWare.com Home Page. Data Science Desktop Survival Guide
by Graham Williams
Duck Duck Go

Predict Probability

20200607 To extract the probability of it raining tomorrow from the prediction made by the model. For a rpart model we can obtain the probability of it raining tomorrow using stats::predict() with type="prob".

pr.tr <- ds[tr, vars] %>% predict(model, newdata=., type="prob") %>% '['(,2)
pr.tu <- ds[tu, vars] %>% predict(model, newdata=., type="prob") %>% '['(,2)
pr.te <- ds[te, vars] %>% predict(model, newdata=., type="prob") %>% '['(,2)

##         1         2         3         4         5         6 
## 0.1379809 0.1379809 0.1379809 0.7806161 0.1379809 0.1379809

Support further development by purchasing the PDF version of the book.
Other online resources include the GNU/Linux Desktop Survival Guide.
Books available on Amazon include Data Mining with Rattle and Essentials of Data Science.
Popular open source software includes rattle and wajig.
Hosted by Togaware, a pioneer of free and open source software since 1984.
Copyright © 2000-2020 Togaware Pty Ltd. . Creative Commons ShareAlike V4.