Framework Introduction
7 Stages Introduction
Stage 1: Problem Definition
Stage 2: Data Collection
Stage 3: Data Preparation
Stage 4: Data Visualization
Stage 5: Machine Learning Modeling
Stage 6: Feature Engineering
Stage 7: Model Deployment
Framework Introduction
#set working directory> path <- "C:/Users/satish/Desktop/Data/TRIAL"> setwd(path)
Read emails into syuzhet
|
|
1
2
|
Emails <- data.frame(dbGetQuery(database,"SELECT *
FROM Emails"))
library('syuzhet')
|
Do sentiment analysis of the email
|
|
1
2
3
4
5
6
7
8
9
10
11
|
d<-get_nrc_sentiment(Emails$RawText)
td<-data.frame(t(d))
td_new <- data.frame(rowSums(td[2:7945]))
#The function rowSums computes column sums across rows for
each level of a grouping variable.
#Transformation and cleaning
names(td_new)[1] <- "count"
td_new <- cbind("sentiment"
= rownames(td_new), td_new)
rownames(td_new) <- NULL
td_new2<-td_new[1:8,]
|
Graph the sentiment analysis in ggplot2
|
|
1
2
3
|
#Visualisation
library("ggplot2")
qplot(sentiment, data=td_new2, weight=count,
geom="bar",fill=sentiment)+ggtitle("Email sentiments")
|
# Transform and clean the textlibrary("tm")docs <- Corpus(VectorSource(textdata))
To stem text, we will need another library also, known as SnowballC which will shared in my another blog.
|
Framework Introduction 7 Stages Introduction Stage 1: Problem Definition Stage 2: Data Collection Stage 3: Data Preparation Stage 4: Data Vi...