Commit 26a10b06 authored by Connor Hainje's avatar Connor Hainje
Browse files

Update readme

parent 941437ed
......@@ -6,6 +6,45 @@ There are _two_ packages included in this repository: `pidplots` and `pidml`. T
`pidml` is a package for using machine learning to optimize the particle ID performance of the ensemble. This includes a PyTorch network architecture, utilities for working with data, and methods for interpreting the results of training.
## Weight values
Here are the values of the weights, trained on ParticleGun data from
release-05-02-06 using a pion weight of beta = 0.1.
```
wgt = np.array(
# SVD CDC TOP ARICH ECL KLM
[[0.80897236, 2.2702134 , 0.43437374, 0.5949359 , 2.4642045 , 0.15824968], # e
[1.3629311 , 1.9584922 , 0.42866027, 0.6106054 , 1.9623914 , 0.48289147], # mu
[1.0637493 , 1.4330192 , 0.42645234, 0.59815615, 2.0181189 , 0.18273243], # pi
[1.7925866 , 1.9082524 , 0.42230165, 0.604627 , 1.662844 , 0.21941555], # K
[1.7190353 , 1.86573 , 0.41387647, 0.64555 , 1.963171 , 0.22059433], # p
[1.264708 , 2.026095 , 0.38130292, 0.6930469 , 4.0849915 , 0.14938803]] # d
)
```
The simplest way to use these for _any_ dataset is to merely multiply these
weights by the corresponding detector log-likelihood columns in your dataset.
For example, if you have a DataFrame containing your data, multiply the
TOP_logLikelihood_e column by 0.43437374, the TOP/e weight. Then, recompute the
likelihoods. Possible Python code to do this:
```python
# assume data is stored in a dataframe called 'data'
# assume log-likelihoods are in columns called 'logl_{detector}_{particle}'
for i, part in enumerate(particles):
for j, det in enumerate(detectors):
data[f'logl_{det}_{part}'] *= wgt[i, j]
likelihoods = np.stack([
np.exp(np.sum(data[[f'logl_{det}_{part}' for det in detectors]].values, axis=1))
for part in particles
], axis=-1)
likelihood_ratios = likelihoods / np.sum(likelihoods, axis=1, keepdims=True)
# likelihood_ratios[0] = e PID,
# likelihood_ratios[1] = mu PID, etc.
```
## Installation
Installation is simple using `pip`.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment