Skip to content

Commit

Permalink
fix flake
Browse files Browse the repository at this point in the history
  • Loading branch information
qianyun210603 committed Jan 9, 2023
1 parent 6bf5465 commit 1b6d12b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions qlib/contrib/report/analysis_model/analysis_model_performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ def __init__(self, N):
self.cuts = {}

def __call__(self, x, i):
l = len(x)
if l not in self.cuts:
per_group_num, remain = divmod(l, N)
sample_len = len(x)
if sample_len not in self.cuts:
per_group_num, remain = divmod(sample_len, N)
per_group_nums = np.ones(N, dtype=int) * per_group_num
if remain > 0:
per_group_nums[: remain - remain // 2] += 1
per_group_nums[-(remain // 2) :] += 1
self.cuts[l] = np.insert(np.cumsum(per_group_nums), 0, 0)
return x[self.cuts[l][i] : self.cuts[l][i + 1]].mean()
self.cuts[sample_len] = np.insert(np.cumsum(per_group_nums), 0, 0)
return x[self.cuts[sample_len][i] : self.cuts[sample_len][i + 1]].mean()

_stratifier = _Stratifier(N)

Expand Down

0 comments on commit 1b6d12b

Please sign in to comment.