Skip to content
This repository has been archived by the owner on Apr 6, 2020. It is now read-only.

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
arifwider committed Dec 20, 2017
1 parent 71a50ae commit 599b7e7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 76 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ script:
- pytest

notifications:
slack: tw-datalab:tySjyrBfi9MdHdiuk5hh8Jbd
slack:
rooms:
- tw-datalab:tySjyrBfi9MdHdiuk5hh8Jbd
on_success: change
on_failure: always
5 changes: 3 additions & 2 deletions src/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ def nwrmsle(predictions, targets, weights):
predictions = np.array([np.nan if x < 0 else x for x in predictions])
elif type(predictions) == pd.Series:
predictions[predictions < 0] = np.nan
targets[targets < 0] = np.nan
targetsf = targets.astype(float)
targetsf[targets < 0] = np.nan
weights = 1 + 0.25 * weights
log_square_errors = (np.log(predictions + 1) - np.log(targets + 1)) ** 2
log_square_errors = (np.log(predictions + 1) - np.log(targetsf + 1)) ** 2
return(np.sqrt(np.sum(weights * log_square_errors) / np.sum(weights)))
70 changes: 0 additions & 70 deletions test/merger_test.py

This file was deleted.

6 changes: 3 additions & 3 deletions test/load_and_split_test.py → test/splitter_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import pandas as pd
sys.path.append(os.path.join('..', 'src'))
sys.path.append(os.path.join('src'))
import load_and_split
import splitter

def test_get_validation_period():
latest_date = pd.to_datetime('2017-11-22')
actual_begin_date, actual_end_date = load_and_split.get_validation_period(latest_date)
actual_begin_date, actual_end_date = splitter.get_validation_period(latest_date)
expected_begin_date = pd.to_datetime('2017-11-01')
expected_end_date = pd.to_datetime('2017-11-16')
assert actual_begin_date == expected_begin_date
Expand All @@ -22,6 +22,6 @@ def test_split_validation_train_by_validation_period():
validation_end_date = pd.to_datetime('2017-11-30')
d = {'date': [date1, date2, date3, date4], 'col2': [3, 4, 5, 6]}
df = pd.DataFrame(data=d)
df_train, df_validation = load_and_split.split_validation_train_by_validation_period(df, validation_begin_date, validation_end_date)
df_train, df_validation = splitter.split_validation_train_by_validation_period(df, validation_begin_date, validation_end_date)
assert df_train.shape[0] == 1
assert df_validation.shape[0] == 2

0 comments on commit 599b7e7

Please sign in to comment.