MCPcopy Create free account
hub / github.com/Open-Quant/openquant / _score

Function _score

python/openquant/feature_diagnostics.py:199–231  ·  view source on GitHub ↗
(
    y_true: Sequence[float],
    prob: Sequence[float],
    scoring: str,
    sample_weight: Sequence[float] | None,
)

Source from the content-addressed store, hash-verified

197 while resume < n and intervals[resume][0] <= test_end:
198 resume += 1
199 after = min(n, resume + embargo_n)
200 for i in range(before, after):
201 train_mask[i] = False
202
203 train_idx = [i for i, keep in enumerate(train_mask) if keep]
204 if not train_idx or not test_idx:
205 raise ValueError("PurgedKFold generated an empty train/test fold")
206
207 splits.append((train_idx, test_idx))
208 start = stop
209
210 return splits
211
212
213def _dot(a: Sequence[float], b: Sequence[float]) -> float:
214 return sum(x * y for x, y in zip(a, b))
215
216
217def _sigmoid(z: float) -> float:
218 if z >= 0:
219 ez = exp(-z)
220 return 1.0 / (1.0 + ez)
221 ez = exp(z)
222 return ez / (1.0 + ez)
223
224
225def _solve_linear_system(a: list[list[float]], b: list[float]) -> list[float]:
226 n = len(a)
227 aug = [row[:] + [rhs] for row, rhs in zip(a, b)]
228
229 for col in range(n):
230 pivot = max(range(col, n), key=lambda r: abs(aug[r][col]))
231 if abs(aug[pivot][col]) < _EPS:
232 raise ValueError("Singular linear system")
233 if pivot != col:
234 aug[col], aug[pivot] = aug[pivot], aug[col]

Callers 2

_score_with_perm_groupsFunction · 0.85
sfi_importanceFunction · 0.85

Calls 1

maxFunction · 0.85

Tested by

no test coverage detected