Skip to content

Commit

Permalink
Fixing local predictions when no input_fields are defined
Browse files Browse the repository at this point in the history
  • Loading branch information
mmerce committed Jun 7, 2019
1 parent 2e33082 commit 64609c4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion bigml/ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def __init__(self, ensemble,
self.importance = {}
query_string = ONLY_MODEL
no_check_fields = False
self.input_fields = []
if isinstance(ensemble, list):
if all([isinstance(model, Model) for model in ensemble]):
models = ensemble
Expand All @@ -144,6 +145,7 @@ def __init__(self, ensemble,
raise ValueError('Failed to verify the list of models.'
' Check your model id values: %s' %
str(exc))

else:
ensemble = self.get_ensemble_resource(ensemble)
self.resource_id = get_ensemble_id(ensemble)
Expand All @@ -166,7 +168,7 @@ def __init__(self, ensemble,
self.objective_id = ensemble['object'].get("objective_field")
query_string = EXCLUDE_FIELDS
no_check_fields = True
self.input_fields = ensemble['object'].get('input_fields')
self.input_fields = ensemble['object'].get('input_fields')

number_of_models = len(models)
if max_models is None:
Expand Down
10 changes: 8 additions & 2 deletions bigml/modelfields.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,14 @@ def __init__(self, fields, objective_id=None, data_locale=None,
self.inverted_fields = invert_dictionary(fields)
self.fields = {}
self.fields.update(fields)
if not self.input_fields:
self.input_fields = self.fields.keys()
if not (hasattr(self, "input_fields") and self.input_fields):
self.input_fields = [field_id for field_id, field in \
sorted( \
[(field_id, field) for field_id,
field in self.fields.items()],
key=lambda(x): x[1].get("column_number"))
if not self.objective_id or
field_id != self.objective_id]
self.model_fields = {}
self.model_fields.update(
dict([(field_id, field) for field_id, field in \
Expand Down

0 comments on commit 64609c4

Please sign in to comment.