Skip to content

Commit

Permalink
fixes #19 : issue with encoders not being defined when data is not lo…
Browse files Browse the repository at this point in the history
…aded
  • Loading branch information
mukeshmk committed Jul 20, 2020
1 parent b92826c commit c62cb8e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
# for algorithm predection (at least that's the plan)
fml = fmlearn()

# doing this so that dataload and training of the model happens once at application start.
fml.load_data()
fml.train()

# Create a Metric
@metrics_api.route('', methods=[POST])
def add_metric():
Expand Down Expand Up @@ -115,9 +111,13 @@ def predict_fmlearn():

data = {}

if fml._new_recs == math.inf:
if fml._new_recs == math.inf or len(utils.get_df_from_db()) <= fml.MAX_NEW_RECORDS:
data['response'] = 'Model not trained!'
return json.dumps(data)

if not fml.is_model_trained():
# doing this so that data load and training of the model happens once at application has enough data.
fml.load_data_and_train()

# fetching the encoder for target type for encoding the input data
tt_encoder = fml.get_encoders()[utils.TARGET_TYPE]
Expand Down

0 comments on commit c62cb8e

Please sign in to comment.