Understanding Sentiment Analysis Graphics in Text Classification (R Script)
The two 'Graphics' outputs refer to two different graphs generated by the R script. The first 'Graphics' output is a word cloud that shows the most frequently occurring words in the tweet text, with the size of each word indicating its frequency. The second 'Graphics' output is a bar chart that shows the distribution of sentiment labels (positive, negative, or neutral) in the dataset. The height of each bar indicates the number of tweets with that sentiment label. These two graphs provide different perspectives on the sentiment analysis results and help to understand the characteristics of the dataset.
Map 1-based optional input ports to variables
dataset <- maml.mapInputPort(1) # class: data.frame
Separate the label and tweet text
sentiment_label <- dataset[[1]] tweet_text <- dataset[[2]]
Replace punctuation, special characters and digits with space
tweet_text <- gsub('[^a-z]', ' ', tweet_text, ignore.case = TRUE)
Convert to lowercase
tweet_text <- sapply(tweet_text, tolower)
data.set <- as.data.frame(cbind(sentiment_label,tweet_text), stringsAsFactors=FALSE)
Load the R script from the Zip port in ./src/
source('src/text.preprocessing.R'); drawWordCloud(tweet_text, sentiment_label, maxWords=50)
Select data.frame to be sent to the output Dataset port
maml.mapOutputPort('data.set')
原文地址: https://www.cveoy.top/t/topic/lfdY 著作权归作者所有。请勿转载和采集!