Machine Learning using R linear regression -
i used r machine learning code. project scenario mentioned below. used mongodb database storage. in mongo db had 1 collection in collection every 5 min. 1 new document added. collection description below.
{ "_id" : objectid("521c980624c8600645ad23c8"), "timestamp" : 1377605638752, "cpuused" : -356962527, "memory" : 2057344858, "hostid" : "200.2.2.2" }
now problem using above documents want predict next 5 min or 10 min or 24 hrs. cpuused , memory values. write r code below
library('rmongo') mg1 <- mongodbconnect('dbname') query <- dbgetquery(mg1,'test',"{'hostid' : '200.2.2.2'}") data1 <- query[] cpu <- query$cpuutilization memory <- query$memory new <- data.frame(data=1377678051) # set timestamp calculating results predict(lm(cpu ~ data1$memory + data1$date ), new, interval="confidence")
but, when execute above code shows me following output
fit lwr upr 1 427815904 -37534223 893166030 2 -110791661 -368195697 146612374 3 137889445 -135982781 411761671 4 -165891990 -445886859 114102880 . . . n
using output don't know cpuused value used predicting values. if 1 knows please me. thank you.
the newdata
parameter of predict needs contain variables used in fit:
new <- data.frame(memory = 1377678051, date=as.date("2013-08-28))
only used prediction, otherwise fitted values.
you can cbind
predicted values new
.
Comments
Post a Comment