Quantcast
Channel: Data Science, Analytics and Big Data discussions - Latest topics
Viewing all articles
Browse latest Browse all 4448

RMongo insert analytic result to db

$
0
0

@arunsadhasivam wrote:

i am trying to learn Rmongo . i used Loan_prediction example. i import train and test to mongo db.
i am trying to train the model by using train data from mongodb. and after analysis and prediction i am trying to update the predicted result back to mongodb.

i am stuck with updating only Loan_status alone to the mongodb table loan_prediction-test which i imported
earlier.
please kindly help me on this.

test<-dbSelect(export,'analytics.loan_prediction_test')

fit <- randomForest(formula, data=train,importance=TRUE, ntree=38)
#colSums(is.na(test))
pred=predict(fit,test)
test$Loan_Status=pred

for( i in 1:nrow(test)){
row <- test[i,]
criteria <- mongo.bson.from.df(row)
objnew <- mongo.bson.from.df(row)
objnew$Loan_Status<-'Y'
mongo.update(mongo,'analytics.loan_prediction_test',
(criteria),
(objNew ),mongo.update.multi)
print(mongo.get.err(mongo))
}

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4448

Trending Articles