Skip to content

Commit

Permalink
Merge pull request #8 from ottogroup/feature-params-from-data-api
Browse files Browse the repository at this point in the history
Make 'params_from_request' a 'params_from_data', similar to 'sample_from_data'.
  • Loading branch information
alattner committed Jun 16, 2015
2 parents accb989 + 9acc58e commit c9a7890
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions palladium/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def do(self, model, request):
samples.append(self.sample_from_data(model, data))
samples = np.array(samples)

params = self.params_from_request(model, request)
params = self.params_from_data(model, request.args)
y_pred = self.predict(model, samples, **params)
return self.response_from_prediction(y_pred, single=single)

Expand All @@ -120,17 +120,17 @@ def sample_from_data(self, model, data):
values.append(value_type(data[key]))
return np.array(values, dtype=object)

def params_from_request(self, model, request):
def params_from_data(self, model, data):
"""Retrieve additional parameters (keyword arguments) for
``model.predict`` from the request.
``model.predict`` from request *data*.
:param model:
The :class:`~Model` instance to use for making predictions.
:param request:
A werkzeug ``request`` object.
:param data:
A dict-like with the parameter data, typically retrieved
from ``request.args`` or similar.
"""
params = {}
data = request.args
for key, type_name in self.params:
value_type = self.types[type_name]
if key in data:
Expand Down

0 comments on commit c9a7890

Please sign in to comment.