quantlab.model.predefined.double_ensemble.sample_weights#
- quantlab.model.predefined.double_ensemble.sample_weights(l_start, l_end, loss_values, k, alpha1, alpha2, bins, decay)[source]#
Qlib’s sample re-weighting (
DEnsembleModel.sample_reweight).l_startandl_endare each sample’s mean percentile loss over the first and the last tenth of the previous sub-model’s trees,loss_valuesits loss under the current ensemble. Withh = alpha1 * pct(-loss) + alpha2 * pct(l_end / l_start), cut intobinsequal-width bins, a sample’s weight is1 / (decay**k * mean(h of its bin) + 0.1).Examples
>>> sample_weights(np.ones(4), np.array([1.0, 0.5, 2.0, 1.0]), np.array([0.1, 0.4, 0.2, 0.3]), ... k=1, alpha1=1.0, alpha2=1.0, bins=2, decay=0.5).round(3) array([1.06 , 1.975, 1.06 , 1.975])