Skip to content

Commit 0fff835

Browse files
committed
BUG: sort all data prior to running model
1 parent 62ef1b7 commit 0fff835

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

bayesalpha/author_model.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ def __init__(self, data):
4040
self.num_backtests = data.meta_code_id.nunique()
4141

4242
# Which algos correspond to which authors?
43-
df = (data.sort_values(['meta_user_id',
44-
'meta_algorithm_id',
45-
'meta_code_id'])
46-
.loc[:, ['meta_user_id', 'meta_algorithm_id']]
43+
df = (data.loc[:, ['meta_user_id', 'meta_algorithm_id']]
4744
.drop_duplicates(subset='meta_algorithm_id', keep='first')
4845
.reset_index()
4946
.meta_user_id
@@ -200,7 +197,12 @@ def fit_authors(data,
200197
if sampler_type not in {'mcmc', 'vi'}:
201198
raise ValueError("sampler_type not in {'mcmc', 'vi'}")
202199

200+
# Check data and sort
203201
_check_data(data)
202+
data = (data.sort_values(['meta_user_id',
203+
'meta_algorithm_id',
204+
'meta_code_id'])
205+
.reset_index(drop=True))
204206

205207
if seed is None:
206208
seed = int(random.getrandbits(31))

0 commit comments

Comments
 (0)