Skip to content

Commit

Permalink
feat(test): use index for faster filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
Caceresenzo committed Apr 19, 2023
1 parent 7172e77 commit d8a74ce
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crunch/__version__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__title__ = 'crunch-cli'
__description__ = 'crunch-cli - CLI of the CrunchDAO Platform'
__version__ = '0.12.2'
__version__ = '0.12.3'
__author__ = 'Enzo CACERES'
__author_email__ = '[email protected]'
__url__ = 'https://github.com/crunchdao/crunch-cli'
9 changes: 6 additions & 3 deletions crunch/command/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ def test(
moons = x_test[moon_column_name].unique()
moons.sort()

for dataframe in [x_train, y_train, x_test]:
dataframe.set_index(moon_column_name, drop=True, inplace=True)

os.makedirs(model_directory_path, exist_ok=True)

predictions: typing.List[pandas.DataFrame] = []
Expand All @@ -58,9 +61,9 @@ def test(
logging.warn('---')
logging.warn('moon: %s (%s/%s)', moon, index + 1, len(moons))

x_train_loop = x_train[x_train[moon_column_name] < moon - embargo]
y_train_loop = y_train[y_train[moon_column_name] < moon - embargo]
x_test_loop = x_test[x_test[moon_column_name] == moon]
x_train_loop = x_train[x_train.index < moon - embargo].reset_index()
y_train_loop = y_train[y_train.index < moon - embargo].reset_index()
x_test_loop = x_test[x_test.index == moon].reset_index()

logging.warn('handler: data_process(%s, %s, %s)', x_train_path, y_train_path, x_test_path)
result = data_process_handler(x_train_loop, y_train_loop, x_test_loop)
Expand Down

0 comments on commit d8a74ce

Please sign in to comment.