-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpredict.js
More file actions
26 lines (23 loc) · 773 Bytes
/
predict.js
File metadata and controls
26 lines (23 loc) · 773 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const request = require('request')
const Student = require('./models/student')
function predictWithFormattedData(data) {
request.post('http://159.203.94.60/',{json: data},function(err,res,body) {
if(!err && res.statusCode == 200) {
console.log(body)
const predictedValue = body.Prediction.predictedValue
let atRisk = false
if(predictedValue <= 10) atRisk = true;
data.predictedValue = predictedValue
data.atRisk = atRisk
const student = new Student(data)
student.save(function(err1){
if(err1) throw err1;
console.log("saved prediction")
console.log(student)
})
} else {
console.log("Error: ",err)
}
})
}
module.exports.predictWithFormattedData = predictWithFormattedData