我准备了一个内置glm
的R模型。创建模型后,我将model
和testData
传递给predict
函数。代码如下:
data = read.csv(file = "twitter-dataset.csv")
testData = read.csv(file = "twitter-test-dataset.csv")
model = glm(formula = viral ~ sentiment + postLength + hashTagCount + contentURLCount + likeCount + shareCount + followersCount + followingCount + tweetCount + gender + peakVelocity, data = data)
predict(model, testData)
预测功能的输出是我不明白的。它包括NA
。控制台上predict
的示例输出如下所示:
1 2 3 4 5 6 7
-0.261160126 -0.475512528 0.248612361 -0.384309806 -0.023267727 -0.238602913 NA
8 9 10 11 12 13 14
NA NA NA -0.225554686 NA -0.477842906 -0.192178793
15 16 17 18 19 20 21
NA -0.207955059 -0.172670264 NA -0.123026836 -0.026680875 0.120059375
22 23 24 25 26 27 28
这可能是什么原因?另外,我如何检查模型的准确性?
更新
数据集:input data set
测试数据集:test data set