-
Notifications
You must be signed in to change notification settings - Fork 1
/
useLinearGPSModel.p
29 lines (21 loc) · 921 Bytes
/
useLinearGPSModel.p
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
27
28
29
import sys # system
import numpy as np # numpy
import pandas as pd # pandas
from sklearn.preprocessing import StandardScaler # normalisation library
from sklearn import linear_model as lm # linear model library
from joblib import dump, load # model persistance library
# model deployment:
# load saved model from disk
gpsSpeedLReg = load('./models/gpsSpeedLReg.model')
def predictGPSSpeed(inputFrame):
return gpsSpeedLReg.predict(inputFrame)
# inputPDF is inserted into program space by KDB
inputPDF.drop(['GPSspeedkph'], axis=1, inplace=True)
scale = StandardScaler() # create scaler object
inputPDF = scale.fit_transform(inputPDF) # normalise dataset
# get predictions from model deployed model
gpsSpeedPredictions = predictGPSSpeed(inputPDF)
print("Number of predictions: " + str(len(gpsSpeedPredictions)))
print("Predictions:")
for x in gpsSpeedPredictions:
print("{0:.2f}".format(x) + 'kph')