Skip to content

Commit

Permalink
improving API
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Leonardo A. Paulino committed Apr 16, 2019
1 parent ff3f885 commit f9bcb5d
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 28 deletions.
7 changes: 1 addition & 6 deletions examples/ensembling.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,4 @@

# Now we can requests the scores
status = engine.request_status()
scores = status['scores']
print('\nScores:', scores)

# We can also get the score of the best id
best_id = status['best_id']
print('\nBest score:', scores[best_id])
print('\nScores:', status['scores'])
14 changes: 5 additions & 9 deletions examples/getting_started.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,14 @@
sleep(5)
status = engine.request_status()

# Let's print the scores of the engine
print('\nScores:', status['scores'])
# Let's print the score of the engine
print('\nScore:', status['score'])

# Okay, let's wait 5 more seconds, shut it down and check if it's running every
# second. The print inside the loop may not be called.
# Okay, let's wait 5 more seconds and shut it down.
print('\nWaiting 5 seconds...')
sleep(5)
engine.interrupt()
while engine.is_running():
print('\nEngine still running')
sleep(1)

# The engine's status is still available. The score may have improved
# The engine's status is still available and the score may have improved
status = engine.request_status()
print('\nScores:', status['scores'])
print('\nScore:', status['score'])
2 changes: 1 addition & 1 deletion examples/lightgbm_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,4 @@ def predict_proba(self, X):
engine.interrupt()

status = engine.request_status()
print('\nScores:', status['scores'])
print('\nScore:', status['score'])
4 changes: 1 addition & 3 deletions examples/on_improvement.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
# Simply printing the best score on improvement. This function must receive a
# dictionary, which is the return of the request_status method.
def on_improvement(status):
best_id = status['best_id']
scores = status['scores']
print('Best score:', scores[best_id])
print('Score:', status['score'])

# Instantiating the engine
engine = Engine(config, on_improvement=on_improvement)
Expand Down
2 changes: 1 addition & 1 deletion examples/parameters_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ def logistic_regression_parameters_rules(parameters):
engine.interrupt()

status = engine.request_status()
print('\nScores', status['scores'])
print('\nScore:', status['score'])
2 changes: 1 addition & 1 deletion miraiml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
>>> from miraiml import SearchSpace, Config, Engine
"""

__version__ = '3.1.6.5'
__version__ = '4.1.6.5'

from .main import SearchSpace, Config, Engine

Expand Down
12 changes: 5 additions & 7 deletions miraiml/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,19 +514,17 @@ def request_status(self):
If no score has been computed yet, returns ``None``. The available
keys for the dictionary are:
* ``'best_id'``: The best id of the engine
* ``'score'``: The score of the best id
* ``'scores'``: A dictionary containing the score of each id
* ``'train_predictions'``: A dataframe containing the predictions of each id for the training dataset
* ``'test_predictions'``: A dataframe containing the predictions of each id for the testing dataset
* ``'predictions'``: A ``pandas.Series`` object containing the\
predictions of the best id for the testing dataset
"""
if self.best_id is None:
return None
return dict(
best_id = self.best_id,
score = self.scores[self.best_id],
scores = self.scores.copy(),
train_predictions = self.train_predictions_df.copy(),
test_predictions = self.test_predictions_df.copy()
predictions = self.test_predictions_df[self.best_id].copy()
)

0 comments on commit f9bcb5d

Please sign in to comment.