Skip to content

Commit

Permalink
updated best metric retrieval API for min and max metric use-case
Browse files Browse the repository at this point in the history
  • Loading branch information
mukeshmk committed Feb 15, 2020
1 parent 382501e commit b8bd5ba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
10 changes: 7 additions & 3 deletions sklearn/fml/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ class URI:

_METRIC = '/metric'
_RETRIEVE = '/retrieve'
_BEST = '/best'
_MAX = '/max'
_MIN = '/min'
_ALL = '/all'

def post_metric(self):
Expand All @@ -12,5 +13,8 @@ def post_metric(self):
def retrieve_all(self):
return self._SERVER + self._METRIC + self._RETRIEVE + self._ALL

def retrieve_best(self):
return self._SERVER + self._METRIC + self._RETRIEVE + self._BEST
def retrieve_best_min(self):
return self._SERVER + self._METRIC + self._RETRIEVE + self._MIN

def retrieve_best_max(self):
return self._SERVER + self._METRIC + self._RETRIEVE + self._MAX
10 changes: 8 additions & 2 deletions sklearn/fml/fml_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,22 @@ def retrieve_all_metrics(self, dataset):

return self._post_msg(URI().retrieve_all(), data)

def retrieve_best_metric(self, dataset):
def retrieve_best_metric(self, dataset, min=True):
"""
Function to retrieve metric that best matches the dataset_hash
@min = True fetch the minimum value of the metric
@min = False fetches the maximum value of the metric
"""
dataset_hash = FMLHash().hashValAndReturnString(dataset)

data = {}
data['dataset_hash'] = dataset_hash

return self._post_msg(URI().retrieve_best(), data)
if min:
return self._post_msg(URI().retrieve_best_min(), data)
else:
return self._post_msg(URI().retrieve_best_max(), data)


def _test_publish(self, model=linear_model.LinearRegression(), metric_name='RMSE', metric_value='0', dataset='asdfasdfasdfd'):
"""
Expand Down

0 comments on commit b8bd5ba

Please sign in to comment.