clear all
use http://www.stata-press.com/data/r16/iris, clear

// split the original dataset into training and test 
// dataset which contains 80% and 20% of observations respectively
splitsample, generate(group, replace) split(0.8 0.2) show rseed(16)

// create two frames holding the the two datasets
frame put if group==1, into(training)
frame put if group==2, into(test)

// pass the two frame names into the .py script
// train the model and make predictions
python script pyex.py, args(training test)

// see prediction results in Stata
frame change test 
label values irispr species
label variable irispr predicted
tabulate iris irispr, row
