sPlot¶
sPlot is reweighting technique frequently used in HEP to reconstruct the distributions of features in mixture. Initial information used is the probabilities obtained after fitting.
hep_ml.splot contains standalone python implementation of this technique. This implementation is brilliantly simple and clear - just as it should be.
Example¶
>>> from hep_ml.splot import compute_sweights
>>> p = pandas.DataFrame({'signal': p_signal, 'bkg', b_bkg})
>>> sWeights = compute_sweights(p)
>>> # plotting reconstructed distribution of some other variable
>>> plt.hist(other_var, weights=sWeights.signal)
>>> plt.hist(other_var, weights=sWeights.bkg)
For more examples and explanations, see notebooks/Splot in repository.
- hep_ml.splot.compute_sweights(probabilities, sample_weight=None)[source]¶
Computes sWeights based on probabilities obtained from distribution fit.
- Parameters
probabilities – pandas.DataFrame with probabilities of shape [n_samples, n_classes]. These probabilities are obtained after fit (typically, mass fit). Pay attention, that for each sample sum of probabilities should be equal to 1.
sample_weight – optionally you can pass weights of events, numpy.array of shape [n_samples]
- Returns
pandas.DataFrame with sWeights of shape [n_samples, n_classes]