Like what you see? Have a play with our trial version.

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Expand
titleText


Concatenate Columns

Joins two columns into one text string.


...

Expand
titleClick to expand...

For Yellowfin to understand and execute R script a slightly different structure will be used in the script discussed below.

Consider a sample script called <R_file_name>.R. The input parameters passed from Yellowfin will be available in a file called <R_file_name>.R.input.csv. Post processing, the R-script should write the results (only one column) back to <R_file_name>.R.result.csv . 

Below is a sample R-Script for Neural Networks. Copy this script and make sure it runs without any errors in R.

Code Block
languagec#
titleSample R-Script : neural-net-script.R
setwd("C:/R/R-3.2.3/bin/x64")
library(rattle)   # To access the weather dataset and utility commands. 
library(magrittr) # For the %>% and %<>% operators. 
building <- TRUE 
scoring  <- ! building 
# A pre-defined value is used to reset the random seed so that results are repeatable. 
crv$seed <- 42  
# Load the data. 
rPATH  <- Sys.getenv("RSCRIPT_PATH") 
rINPUT <- paste0(rPATH ,"/neural-net-script.r.input.csv") 
rOUTPUT <- paste0(rPATH ,"/neural-net-script.r.result.csv") 
dataset <- read.csv(file=rINPUT, header=FALSE, sep=",") 
# Note the user selections.  
# Build the training/validate/test datasets. 
set.seed(crv$seed)  
crs$nobs <- nrow(dataset) # 366 observations  
crs$sample <- crs$train <- sample(nrow(dataset), 0.7*crs$nobs) # 256 observations 
crs$validate <- sample(setdiff(seq_len(nrow(dataset)), crs$train), 0.15*crs$nobs) # 54 observations 
crs$test <- setdiff(setdiff(seq_len(nrow(dataset)), crs$train), crs$validate) # 56 observations 
# The following variable selections have been noted. 
crs$input <- c("V1", "V2", "V3", "V4","V5") 
crs$target  <- "V6" 
#============================================================ 
# Neural Network  
#============================================================ 
 
# Build a neural network model using the nnet package. 
library(nnet, quietly=TRUE) 
# Build the NNet model. 
set.seed(199) 
crs$nnet <- nnet(as.factor(V6) ~ .,data=dataset[crs$sample,c(crs$input, crs$target)],size=10, skip=TRUE, MaxNWts=10000, trace=FALSE, maxit=100) 
#============================================================ 
# Score a dataset.  
#============================================================ 
# Obtain probability scores for the Neural Net model on weather.csv [validate]. 
#crs$pr <- predict(crs$nnet, newdata=dataset[crs$validate, c(crs$input)], type="class") 
#crs$pr <- predict(crs$nnet, newdata=dataset[crs$validate, c(crs$input)], type="class") 
crs$pr <- predict(crs$nnet, newdata=dataset, type="class") 
write.table(crs$pr, file=rOUTPUT, row.names=FALSE, col.names = FALSE) 

 

Calling R-Script

Expand
titleClick to expand...

Once installed, you will be able to use this function through the Advanced Function menu.

 

...