def svm_predict(days=10, offset=0, name='YHOO'): N = 30 X = np.arange(N).reshape(N, 1) y = fetchdata.get_data(name).ravel() Z = np.arange(N + offset, N + days + offset).reshape(days, 1) svr_lin = SVR(kernel='linear', C=1e3) y_lin = svr_lin.fit(X, y).predict(Z) return list(y_lin)
def bayes_predict(name='YHOO'): # #read data from db global Y Y = fetchdata.get_data(name) print 'The trend is :' print Y predicted_price = getm(N + 1)[0][0] return predicted_price
def mlp_predict(days, offset, name='YHOO'): N = 30 # Generate sample data X = np.arange(N).reshape(N, 1) y = fetchdata.get_data(name).ravel() Z = np.arange(N + offset, N + days + offset).reshape(days, 1) # Fit regression model mlp_adam = MLPRegressor(algorithm='l-bfgs', activation='logistic') y_log = mlp_adam.fit(X, y).predict(Z) return y_log
def svm_predict(days=10, offset=0, name='YHOO'): N = 30 # Generate sample data X = np.arange(N).reshape(N, 1) y = fetchdata.get_data(name).ravel() Z = np.arange(N + offset, N + days + offset).reshape(days, 1) # Fit regression model svr_rbf = SVR(kernel='rbf', C=1e3, gamma=0.1) # svr_lin = SVR(kernel='linear', C=1e3) # svr_poly = SVR(kernel='poly', C=1e3, degree=2) y_rbf = svr_rbf.fit(X, y).predict(Z) # y_lin = svr_lin.fit(X, y).predict(Z) # y_poly = svr_poly.fit(X, y).predict(Z) # print y_rbf # print y_lin # print y_poly return list(y_rbf)
def reply(): num = request.form.get("From") num = num.replace("whatsapp:", "") print(num) msg_text = request.form.get("Body") if "," in msg_text: pin = msg_text.split(",")[0] date = msg_text.split(",")[1] x = collection.find_one({"NUMBER": num}) try: status = x["status"] except: pass if (bool(x) == False): collection.insert_one({"NUMBER": num, "status": "first"}) msg = MessagingResponse() resp = msg.message( """Hello this is T2 from total technology,developed by roni , to get covid vaccine availability related informaion please follow the below enter your pincode and date separated by comma , for example if your pincode is 1100045 and date you want for 15 th may 2021 , then your input should be 1100045,15-05-2021""") return (str(msg)) else: if (status == "first"): data = get_data(pin, date) msg = MessagingResponse() if (data == "invalid pincode"): resp = msg.message("please entre valid pincode") return (str(msg)) elif (data == "no centre"): resp = msg.message( "no centre found for your given input ,please try again later or else try with find with nearest pincode" ) return (str(msg)) else: if (len(data) < 15): parse_data = json.dumps(data) parse_data = parse_data.replace("{", "") parse_data = parse_data.replace("}", "\n\n") parse_data = parse_data.replace("[", "") parse_data = parse_data.replace("]", "") parse_data = parse_data.replace(",", "\n") resp = msg.message(parse_data) #print(parse_data) return (str(msg)) else: print("abc") resp1 = msg.message( "please fid the pdf for more information") gen_pdf(num, data) resp1.media( "http://48261c041578.ngrok.io/Users/roni/eclipse-workspace/VACCINE_PROJECT/" + num + ".pdf") return (str(msg)) else: msg = MessagingResponse() resp = msg.message( """invalid input , to get covid vaccine availability related informaion please follow the below enter your pincode and date separated by comma , for example if your pincode is 1100045 and date you want for 15 th may 2021 , then your input should be 1100045,15-05-2021""") return (str(msg)) print(num)
return bestLabel def getPredictions(summaries, testSet): predictions = [] for i in range(len(testSet)): result = predict(summaries, testSet[i]) predictions.append(result) return predictions def getAccuracy(testSet, predictions): correct = 0 for i in range(len(testSet)): if testSet[i][-1] == predictions[i]: correct += 1 return (correct/float(len(testSet))) * 100.0 if __name__ == "__main__": _data = fetchdata.get_data('project3_dataset2.txt') # _data = fetchdata.get_data('test.txt') train_data, test_data = seperate_data(_data) print len(train_data), len(test_data) seperated = seperateByClass(train_data) summary = summarizeByClass(seperated) # for key in summary: # print summary[key] predictions = getPredictions(summary, test_data) accuracy = getAccuracy(test_data, predictions) print('Accuracy: {0}%').format(accuracy)