simetenn / uncertainpy

Uncertainpy: a Python toolbox for uncertainty quantification and sensitivity analysis, tailored towards computational neuroscience.
http://uncertainpy.readthedocs.io
GNU General Public License v3.0
220 stars 50 forks source link

The confidence level #40

Open piotrt75 opened 4 years ago

piotrt75 commented 4 years ago

Hi, Is the 'prediction interval' same as 'confidence level' ? If yes, then is there a way to set it to 95% (k~2) ? Thanks, Piotr

simetenn commented 4 years ago

Hi Piotr,

The prediction interval and confidence interval are related but not the same. You can find a more detailed explanation here:

https://towardsdatascience.com/how-confidence-and-prediction-intervals-work-4592019576d8

A summary from that article:

"The prediction interval predicts in what range a future individual observation will fall, while a confidence interval shows the likely range of values associated with some statistical parameter of the data, such as the population mean."

Unfortunatly there is no good way of changing from 90 to 95% prediction interval, but it can easily be changed from whithin the Uncertainpy code. You need to look at uncertainpy/src/uncertainpy/core/uncertainty_calculations.py.

If you are using polynomial chaos expansion you change (in the analyse_pce function):

data[feature].percentile_5 = np.percentile(U_mc[feature], 5, -1)
data[feature].percentile_95 = np.percentile(U_mc[feature], 95, -1)

to:

data[feature].percentile_5 = np.percentile(U_mc[feature], 2.5, -1)
data[feature].percentile_95 = np.percentile(U_mc[feature], 97.5, -1)

And if you are using monte carlo you change (in the monte_carlo function):

data[feature].percentile_5 = np.percentile(masked_evaluations, 5,
data[feature].percentile_95 = np.percentile(masked_evaluations, 95, 0)

to:

data[feature].percentile_5 = np.percentile(masked_evaluations, 2.5,
data[feature].percentile_95 = np.percentile(masked_evaluations, 97.5, 0)