github.com/pachyderm/pachyderm@v1.13.4/examples/ml/iris/rstats/iris-train-r-lda/train.R (about) 1 library(caret) 2 3 # load the CSV file from the local directory 4 dataset <- read.csv("/pfs/training/iris.csv", header = FALSE) 5 6 # set the column names in the dataset 7 colnames(dataset) <- c("Sepal.Length", 8 "Sepal.Width", 9 "Petal.Length", 10 "Petal.Width", 11 "Species") 12 13 # Run algorithm using 10-fold cross validation 14 control <- trainControl(method = "cv", number = 10) 15 metric <- "Accuracy" 16 17 # SVM 18 set.seed(7) 19 fit.model <- train(form = Species ~ ., 20 data = dataset, 21 method = "lda", 22 metric = metric, 23 trControl = control) 24 25 # save a summary of this model 26 sink("/pfs/out/model.txt", append=FALSE, split=FALSE) 27 print(fit.model) 28 29 # persist the model 30 save(fit.model, file = "/pfs/out/model.rda") 31