R Plot estimated conditional probability












0














I am currently following the Harvard EDX machine learning course but don't get how you plot the estimated conditional probability like shown below




Right now I have the following code but haven't been able to figure out how the plot is created. It is a 2-outcome classification prediction, where the dark line seperates both outcomes. This is the code I have thus far for the data



library(dslabs)
data('mnist_27')
train_rpart <- train(y ~ .,
data=mnist_27$train,
method="rpart",
tuneGrid = data.frame(cp=seq(0,0.1, length=25)))
confusionMatrix(predict(train_rpart, mnist_27$test), mnist_27$test$y)









share|improve this question
























  • The code has nothing to do with the plot. What have you tried to produce a sample plot?
    – NelsonGon
    Nov 22 at 15:35










  • To be honest I have tried a lot but don't seem to even approach the right solution. I have also searched off the internet with no result...
    – Sven van Holten
    Nov 22 at 15:46










  • There's probably a function somewhere, defined just for that plot. But if you want to get this by hand, you could start by using expand.grid(x_1 = seq(0,0.6,by = 0.01), x_2 = seq(0,0.6,by = 0.01)) and predicting the model outputs. Then ggplot() + geom_point(aes(x = x_1,y = x_2, colour = predicted_value)) will get you a somewhat similar plot
    – Nutle
    Nov 22 at 21:38


















0














I am currently following the Harvard EDX machine learning course but don't get how you plot the estimated conditional probability like shown below




Right now I have the following code but haven't been able to figure out how the plot is created. It is a 2-outcome classification prediction, where the dark line seperates both outcomes. This is the code I have thus far for the data



library(dslabs)
data('mnist_27')
train_rpart <- train(y ~ .,
data=mnist_27$train,
method="rpart",
tuneGrid = data.frame(cp=seq(0,0.1, length=25)))
confusionMatrix(predict(train_rpart, mnist_27$test), mnist_27$test$y)









share|improve this question
























  • The code has nothing to do with the plot. What have you tried to produce a sample plot?
    – NelsonGon
    Nov 22 at 15:35










  • To be honest I have tried a lot but don't seem to even approach the right solution. I have also searched off the internet with no result...
    – Sven van Holten
    Nov 22 at 15:46










  • There's probably a function somewhere, defined just for that plot. But if you want to get this by hand, you could start by using expand.grid(x_1 = seq(0,0.6,by = 0.01), x_2 = seq(0,0.6,by = 0.01)) and predicting the model outputs. Then ggplot() + geom_point(aes(x = x_1,y = x_2, colour = predicted_value)) will get you a somewhat similar plot
    – Nutle
    Nov 22 at 21:38
















0












0








0







I am currently following the Harvard EDX machine learning course but don't get how you plot the estimated conditional probability like shown below




Right now I have the following code but haven't been able to figure out how the plot is created. It is a 2-outcome classification prediction, where the dark line seperates both outcomes. This is the code I have thus far for the data



library(dslabs)
data('mnist_27')
train_rpart <- train(y ~ .,
data=mnist_27$train,
method="rpart",
tuneGrid = data.frame(cp=seq(0,0.1, length=25)))
confusionMatrix(predict(train_rpart, mnist_27$test), mnist_27$test$y)









share|improve this question















I am currently following the Harvard EDX machine learning course but don't get how you plot the estimated conditional probability like shown below




Right now I have the following code but haven't been able to figure out how the plot is created. It is a 2-outcome classification prediction, where the dark line seperates both outcomes. This is the code I have thus far for the data



library(dslabs)
data('mnist_27')
train_rpart <- train(y ~ .,
data=mnist_27$train,
method="rpart",
tuneGrid = data.frame(cp=seq(0,0.1, length=25)))
confusionMatrix(predict(train_rpart, mnist_27$test), mnist_27$test$y)






r






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 at 15:48









NelsonGon

660115




660115










asked Nov 22 at 15:27









Sven van Holten

217




217












  • The code has nothing to do with the plot. What have you tried to produce a sample plot?
    – NelsonGon
    Nov 22 at 15:35










  • To be honest I have tried a lot but don't seem to even approach the right solution. I have also searched off the internet with no result...
    – Sven van Holten
    Nov 22 at 15:46










  • There's probably a function somewhere, defined just for that plot. But if you want to get this by hand, you could start by using expand.grid(x_1 = seq(0,0.6,by = 0.01), x_2 = seq(0,0.6,by = 0.01)) and predicting the model outputs. Then ggplot() + geom_point(aes(x = x_1,y = x_2, colour = predicted_value)) will get you a somewhat similar plot
    – Nutle
    Nov 22 at 21:38




















  • The code has nothing to do with the plot. What have you tried to produce a sample plot?
    – NelsonGon
    Nov 22 at 15:35










  • To be honest I have tried a lot but don't seem to even approach the right solution. I have also searched off the internet with no result...
    – Sven van Holten
    Nov 22 at 15:46










  • There's probably a function somewhere, defined just for that plot. But if you want to get this by hand, you could start by using expand.grid(x_1 = seq(0,0.6,by = 0.01), x_2 = seq(0,0.6,by = 0.01)) and predicting the model outputs. Then ggplot() + geom_point(aes(x = x_1,y = x_2, colour = predicted_value)) will get you a somewhat similar plot
    – Nutle
    Nov 22 at 21:38


















The code has nothing to do with the plot. What have you tried to produce a sample plot?
– NelsonGon
Nov 22 at 15:35




The code has nothing to do with the plot. What have you tried to produce a sample plot?
– NelsonGon
Nov 22 at 15:35












To be honest I have tried a lot but don't seem to even approach the right solution. I have also searched off the internet with no result...
– Sven van Holten
Nov 22 at 15:46




To be honest I have tried a lot but don't seem to even approach the right solution. I have also searched off the internet with no result...
– Sven van Holten
Nov 22 at 15:46












There's probably a function somewhere, defined just for that plot. But if you want to get this by hand, you could start by using expand.grid(x_1 = seq(0,0.6,by = 0.01), x_2 = seq(0,0.6,by = 0.01)) and predicting the model outputs. Then ggplot() + geom_point(aes(x = x_1,y = x_2, colour = predicted_value)) will get you a somewhat similar plot
– Nutle
Nov 22 at 21:38






There's probably a function somewhere, defined just for that plot. But if you want to get this by hand, you could start by using expand.grid(x_1 = seq(0,0.6,by = 0.01), x_2 = seq(0,0.6,by = 0.01)) and predicting the model outputs. Then ggplot() + geom_point(aes(x = x_1,y = x_2, colour = predicted_value)) will get you a somewhat similar plot
– Nutle
Nov 22 at 21:38



















active

oldest

votes











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%2f53434114%2fr-plot-estimated-conditional-probability%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















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%2f53434114%2fr-plot-estimated-conditional-probability%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

Berounka

Sphinx de Gizeh

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