# get the scores returned from the model
dataset1 <- maml.mapInputPort(1) # class: data.frame

#set thresholds for classification
threshold1 <- 0.60
threshold2 <- 0.45
positives <- which(dataset1["Scored Probabilities"] > threshold1)
negatives <- which(dataset1["Scored Probabilities"] < threshold2)
neutrals <- which(dataset1["Scored Probabilities"] <= threshold1 &
dataset1["Scored Probabilities"] >= threshold2)

new.labels <- matrix(nrow=length(dataset1["Scored Probabilities"]),
ncol=1)
new.labels[positives] <- "positive"
new.labels[negatives] <- "negative"
new.labels[neutrals] <- "neutral"

data.set <- data.frame(assigned=new.labels,
confidence=dataset1["Scored Probabilities"])
colnames(data.set) <- c('Sentiment', 'Score')

# Select data.frame to be sent to the output Dataset port
maml.mapOutputPort("data.set");