Skip to content

Commit

Permalink
fixes #19 : issue where the model never gets trained after server sta…
Browse files Browse the repository at this point in the history
…rt with empty dataset
  • Loading branch information
mukeshmk committed Jul 20, 2020
1 parent da8bf30 commit b92826c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def predict_fmlearn():

data = {}

if not fml.is_model_trained():
if fml._new_recs == math.inf:
data['response'] = 'Model not trained!'
return json.dumps(data)

Expand Down
3 changes: 3 additions & 0 deletions src/fmlearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ def predict(self, X_pred):
# or if the retrain flag is set to true because new data has been loaded
if self._retain == True or self._new_recs >= self.MAX_NEW_RECORDS:
self.train()

if not self.is_model_trained():
self.load_data_and_train()

y_pred = self._model.predict(X_pred)

Expand Down

0 comments on commit b92826c

Please sign in to comment.