I am trying to set up a deep learning model in R and received the error message that no training data is available. Could someone please help?
clothing_reviews <- read.csv("C:/Users/Astrid/Documents/Master BWL/Data Mining mit R/R/Präsentation 2/Womens Clothing Reviews.csv") %>% + mutate(Liked = ifelse(Rating == 5, 1, 0), + text = paste("Title", "Review.Text"), + text = gsub("NA", "", text))
glimpse(clothing_reviews) Observations: 28,222 Variables: 13 $ X "0", "1,1080,34,,\"Love this dress! it's sooo pretty. i happened to fi... $ Clothing.ID 767, , , , 847, , , , 1077, , 1077, 1095, , , so i would say it's runni... $ Age 33, , , , 47, , , , 24, , 53, 39, , , , , , 50, , , 41, , , , , , , , , ... $ Title , , , , Flattering shirt, , , , Flattering, , Dress looks like it's made... $ Review.Text Absolutely wonderful - silky and sexy and comfortable, , , , This shirt ... $ Rating 4, , , , 5, , , , 5, , 3, 5, , , , , , 3, , , 5, , , , , , , , , , , , ,... $ Recommended.IND 1, , , , 1, , , , 1, , 0, 1, , , , , , 1, , , 1, , , , , , , , , , , , ,... $ Positive.Feedback.Count 0, , , , 6, , , , 0, , 14, 2, , , , , , 1, , , 0, , , , , , , , , , , , ... $ Division.Name Initmates, , , , General, , , , General, , General, General Petite, , , ... $ Department.Name Intimate, , , , Tops, , , , Dresses, , Dresses, Dresses, , , , , , Dress... $ Class.Name................... Intimates;;;;;;;;;;;;;;;;;;;, , , , Blouses;;;;;;;;;;;;;;;;;;;, , , , Dr... $ Liked 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, ... $ text "Title Review.Text", "Title Review.Text", "Title Review.Text", "Title Re...
clothing_reviews %>% + ggplot(aes(x = factor(Liked), fill = Liked)) + + geom_bar(alpha = 0.8) + + guides(fill = FALSE)
reviews_total<-rbind(clothing_reviews$Liked, + clothing_reviews$text)
reviews_m<-as.matrix(reviews_total) dimnames(reviews_m)<-NULL
set.seed(123) ind<-sample(2,nrow(reviews_m),replace=TRUE,prob=c(0.7,0.3)) reviews_train<-reviews_m[ind==1,1] reviews_test<-reviews_m[ind==2,1] reviews_trainlabel<-as.numeric(reviews_m[ind==1,2]) reviews_testlabel<-as.numeric(reviews_m[ind==2,2]) Warning message: NAs introduced by coercion
maxlen<-100 max_words<-10000 tokenizer<-text_tokenizer(num_words=max_words)%>% + fit_text_tokenizer(reviews_train) sequences<-texts_to_sequences(tokenizer, reviews_train) word_index= tokenizer$word_index
x_train<-pad_sequences(sequences, maxlen=maxlen) y_train<-as.array(reviews_trainlabel)
batch_size <- 20 epochs <- 12
model <- keras_model_sequential()%>% + layer_embedding(input_dim = max_words, output_dim = 100)%>% + layer_lstm(units = 16)%>% + layer_dense(1)%>% + layer_activation("sigmoid")%>% compile( + loss = "binary_crossentropy", + optimizer = "adam", + metrics = "accuracy" +
+ )hist <- model %>% + fit( + x_train, + y_train, + batch_size = batch_size, + epochs = epochs, + validation_split = 0.3
Error in py_call_impl(callable, dots$args, dots$keywords) : ValueError: Empty training data.