-
Notifications
You must be signed in to change notification settings - Fork 2
Drinking Prediction Model
Lee Seunghwa edited this page Jun 26, 2020
·
10 revisions
We can do this to improve the performance of our drinking prediction model.
First of all, you only need to edit '/Project/Python Server/Python Server/train.py'
And, By looking at the items below, you can easily modify your drinking prediction code.
- A function related to this is
data_load()
. - You can change the path of
search("../../../Data", paths)
- And this project recognizes the labeling information using words in the file name.
- Therefore, you can extend to more class prediection by modifying
path.find("class")
def data_load():
paths = []
search("../../../Data", paths)
for path in paths:
if (path.find("drink") != -1):
read("drink", path)
elif (path.find("exercise") != -1 or path.find("work out") != -1):
read("workout", path)
else:
read("nothing", path)
- Data clipping is commonly used to solve problems with insufficient datasets.
- However, this process can cause overfitting problems.
- So if you want to disable the clipping function, delete the code below.
In function read(htype, name)
...
for i in range(0,1000,10):
if (i > max_time - 15):
break;
for j in range(15,121,15):
try:
print("{} ({}~{})".format(name,i , i+j))
data[htype].append({'name':"{} ({}~{})".format(name,i , i+j), 'data': create_clip(temp, i, i + j)})
except:
print("Error")
if (i + j > max_time):
break;
The original dataset is loaded by this.
data[htype].append({'name':name, 'data': create_clip(temp, 0, max_time)})
- This is implemented in the
train()
function. - If the model you want to change follows sklearn's interface, simply change the code below.
model = DecisionTreeClassifier(max_depth=7)
- But you can also take advantage of new libraries like TensorFlow.
- In that case, you need to build a new model in that area.
- In this process, you need a new preprocessing code for your model!!
- These models should also be modified with the predict() code.
- In the code below, write your prediction code according to the model you have implemented.
def predict(data):
global min_max_scaler, model
x = GetFeature(None, data);
if (x is None):
return "Need more data"
x_min_max_scaled = min_max_scaler.transform([x])
return model.predict(x_min_max_scaled)[0]