Skip to Content
Practical Predictive Analytics
book

Practical Predictive Analytics

by Ralph Winters
June 2017
Beginner to intermediate
576 pages
15h 22m
English
Packt Publishing
Content preview from Practical Predictive Analytics

Simulating the negative cases

We just simulated the positive cases. Now, let's set up some similar code to simulate the non-diabetes patients (outcome=0).

For the negative cases, we will also multiply sample.bin by -1, so that in the future, we know that all the positive sample.bin instances correspond to positive cases and all the negative sample.bin instances correspond to negative ones:

set.seed(123)  nbins2=base::round(n2/400,0) correlationMatrix <- cor(PimaIndians[PimaIndians$diabetes =='neg',1:8])  covarianceMatrix <- stats::cov(PimaIndians[PimaIndians$diabetes =='neg',1:8])  out_sd2 <- as.DataFrame(data.frame(data.frame(  sample.bin=base::sample(1:nbins2,n2,replace=TRUE)*(-1),   outcome=0,  mvrnorm(n2, mu = means.neg, Sigma = matrix(covarianceMatrix, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Data Superstream: Analytics Engineering

Data Superstream: Analytics Engineering

Alistair Croll, Anna Filippova, Emilie Schario, Lewis Davies, Jacob Frackson, Benn Stancil, Nick Acosta, Elizabeth Caley
R: Predictive Analysis

R: Predictive Analysis

Tony Fischetti, Eric Mayor, Rui Miguel Forte
Python: Advanced Predictive Analytics

Python: Advanced Predictive Analytics

Ashish Kumar, Joseph Babcock

Publisher Resources

ISBN: 9781785886188Supplemental Content