我正在尝试在R中建立深度学习模型,并收到错误消息,提示没有可用的训练数据。有人可以帮忙吗?
clothing_reviews <-read.csv(“ C:/ Users / Astrid / Documents / Master BWL / Data Mining mit R / R /Präsentation2 / Womens Clothing Reviews.csv”)%>% + mutate(喜欢= ifelse(评分== 5,1,0), +文字= paste(“ Title”,“ Review.Text”), + text = gsub(“ NA”,“”,text))
瞥见(clothing_reviews) 观察值:28,222 变数:13 $ X“ 0”,“ 1,1080,34 ,,”喜欢这件衣服!太漂亮了我偶然发现... $ Clothing.ID 767,,,,,847,,,,1077,,1077,1095,,,所以我会说这很简单... $年龄33,,,,,47,,,,,24,,53,39,,,,,,,50,,,,41,,,,,,,,... $ Title,,,讨人喜欢的衬衫,,,讨人喜欢的,连衣裙看起来像是人造的... $ Review.Text绝对很棒-柔滑,性感,舒适、、、、这件衬衫... $评分4 、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、 $推荐。IND1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,... $ Positive.Feedback.Count 0,,,,,,,0,,14,2,,,,,,,,,,,,,,,,,,,... $ Division.Name Initmates,,,,General,,,General,General,General Petite,,,... $ Department.Name亲密的,,,上衣,,,连衣裙,连衣裙,连衣裙,,,,,连衣裙... $ Class.Name ......................亲密;;;;;;;;;;;;;;;;;;,,、、 ;;;;;;;;;;;;;;; 、、、、、 ... $喜欢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)+ +指南(填充=假)
reviews_total <-rbind(clothing_reviews $ Liked, + clothing_reviews $ text)
reviews_m <-as.matrix(reviews_total) dimnames(评论_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]) 警告信息: 强制引入的NA
maxlen <-100 max_words <-10000 令牌生成器<-text_tokenizer(num_words = max_words)%>% + fit_text_tokenizer(reviews_train) sequence <-texts_to_sequences(令牌生成器,reviews_train) word_index = tokenizer $ word_index
x_train <-pad_sequences(序列,maxlen = maxlen) y_train <-as.array(reviews_trainlabel)
批处理大小<-20 时代<-12
模型<-keras_model_sequential()%>% + layer_embedding(input_dim = max_words,output_dim = 100)%>% + layer_lstm(单位= 16)%>% + layer_dense(1)%>% + layer_activation(“ Sigmoid”)%>%compile( +损失=“ binary_crossentropy”, +优化程序=“ adam”, +指标=“准确性” +
+)历史记录<-型号%>% +适合( + x_train, + y_train, + batch_size = batch_size, +纪元=纪元, + validation_split = 0.3
py_call_impl(可调用,dots $ args,dots $ keywords)错误: ValueError:空的训练数据。