From da8bf30a30ad9946c107cad651ef70e0f63e6fce Mon Sep 17 00:00:00 2001 From: Mukesh A Date: Mon, 20 Jul 2020 12:44:12 +0100 Subject: [PATCH] fixes: #19 : modified check for predict_fmlearn() check for model existence --- src/api.py | 2 +- src/fmlearn.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/api.py b/src/api.py index 45ae8ac..6e4e03d 100644 --- a/src/api.py +++ b/src/api.py @@ -115,7 +115,7 @@ def predict_fmlearn(): data = {} - if fml._new_recs == math.inf: + if not fml.is_model_trained(): data['response'] = 'Model not trained!' return json.dumps(data) diff --git a/src/fmlearn.py b/src/fmlearn.py index 72e86d8..a4c7a20 100644 --- a/src/fmlearn.py +++ b/src/fmlearn.py @@ -43,6 +43,9 @@ def new_record_added(self): self._new_recs += 1 return + def is_model_trained(self): + return self._model is not None + def load_data(self): # force new model to be trained once data has been reloaded # retraining of model occurs only when the predict() function is being called