1
0
mirror of https://github.com/newnius/YAO-optimizer.git synced 2025-12-15 17:06:44 +00:00
This commit is contained in:
2020-06-30 16:59:25 +08:00
parent e4a9ceafe5
commit 3f97840d36
2 changed files with 20 additions and 20 deletions

View File

@@ -76,6 +76,8 @@ def predict(job, features):
values.append(features[feature])
datafile = './data/' + job + '.' + str(random.randint(1000, 9999)) + '.csv'
if not os.path.exists(datafile):
return -1, False
t = ['job']
t.extend(models[job]['features'])
with open(datafile, 'w', newline='') as csvfile:
@@ -99,6 +101,8 @@ def predict(job, features):
for label in models[job]['labels']:
# load the model from disk
modelfile = './data/' + job + '_' + label + '.sav'
if not os.path.exists(modelfile):
return -1, False
model = pickle.load(open(modelfile, 'rb'))
preds = model.predict(test_feature)
predictions[label] = preds[0]