def test_basic_ds_shape_0(self): PI = PredictionIntervals() DS = gf.basic_data_structure() DS.shape = [(100, )] # remove column - code should add it back ndatabatches, ncols = PI._analyze_data_structure(data=DS) self.assertEqual(ndatabatches, 1, msg='Expect 1 batch') self.assertEqual(ncols, [1], msg='Expect [1]')
def pi_setup(): PI = PredictionIntervals() results = gf.setup_pseudo_results() DS = gf.basic_data_structure() PI.setup_prediction_interval_calculation(results=results, data=DS, modelfunction=gf.predmodelfun) return PI, results
def cc_setup(calc_pred_int=True): PI = PredictionIntervals() results = gf.setup_pseudo_results() PI._assign_features_from_results_structure(results=results) testchain, s2chain, lims, sstype, nsample, iisample = PI._setup_generation_requirements( nsample=400, calc_pred_int=calc_pred_int, sstype=0) DS = gf.basic_data_structure() datapred = PI._setup_data_structure_for_prediction(data=DS, ndatabatches=1) return PI, results, testchain, s2chain, lims, sstype, nsample, iisample, datapred
def test_basic_datapred(self): PI = PredictionIntervals() DS = gf.basic_data_structure() datapred = PI._setup_data_structure_for_prediction(data=DS, ndatabatches=1) self.assertTrue(np.array_equal(datapred[0].xdata[0], DS.xdata[0]), msg='Arrays should match') self.assertTrue(np.array_equal(datapred[0].ydata[0], DS.ydata[0]), msg='Arrays should match')
def test_basic_modelfunction(self): PI = PredictionIntervals() DS = gf.basic_data_structure() datapred = PI._setup_data_structure_for_prediction(data=DS, ndatabatches=1) nrow, ncol = PI._determine_shape_of_response( modelfunction=gf.predmodelfun, ndatabatches=1, datapred=datapred, theta=[3.0, 5.0]) self.assertEqual(nrow, [100], msg='Expect [100]') self.assertEqual(ncol, [1], msg='Expect [1]')
def setup_complex_pi(cls): PI = PredictionIntervals() results = gf.setup_pseudo_results() results['s2chain'] = None DS = gf.basic_data_structure() PI.setup_prediction_interval_calculation(results=results, data=DS, modelfunction=gf.predmodelfun) PI.generate_prediction_intervals(sstype=0, nsample=500, calc_pred_int=False, waitbar=False) return PI
def test_generate_credible_intervals(self): PI = PredictionIntervals() results = gf.setup_pseudo_results() results['s2chain'] = None DS = gf.basic_data_structure() PI.setup_prediction_interval_calculation(results=results, data=DS, modelfunction=gf.predmodelfun) PI.generate_prediction_intervals(sstype=None, nsample=500, calc_pred_int=False, waitbar=False) cint = PI.intervals['credible_intervals'] pint = PI.intervals['prediction_intervals'] self.common_set_1(cint, pint)
def test_generate_credible_intervals_with_waitbar(self): PI = PredictionIntervals() results = gf.setup_pseudo_results() results['s2chain'] = None DS = gf.basic_data_structure() PI.setup_prediction_interval_calculation(results=results, data=DS, modelfunction=gf.predmodelfun) PI.generate_prediction_intervals(sstype=None, nsample=500, calc_pred_int=False, waitbar=True) cint = PI.intervals['credible_intervals'] pint = PI.intervals['prediction_intervals'] self.common_set_1(cint, pint) self.assertEqual(PI._PredictionIntervals__wbarstatus.percentage(3), 3.0, msg='Expect 3.0')
def test_setup_pi_calc_with_s2chain_none(self): PI = PredictionIntervals() DS = gf.basic_data_structure() results = gf.setup_pseudo_results() results['s2chain'] = None PI.setup_prediction_interval_calculation(results=results, data=DS, modelfunction=gf.predmodelfun) self.assertEqual(PI._PredictionIntervals__ndatabatches, 1, msg='Expect ndatabatches = 1') self.assertEqual(PI.modelfunction, gf.predmodelfun, msg='Functions should match') self.assertFalse(hasattr(PI, '_PredictionIntervals__s2chain_index'), msg='Expect False') self.assertTrue(np.array_equal(PI._PredictionIntervals__chain, results['chain']), msg='Arrays should match')
def test_basic_ds(self): PI = PredictionIntervals() DS = gf.basic_data_structure() ndatabatches, ncols = PI._analyze_data_structure(data=DS) self.assertEqual(ndatabatches, 1, msg='Expect 1 batch') self.assertEqual(ncols, [1], msg='Expect [1]')
def setup_interval(cls): PI = PredictionIntervals() DS = gf.basic_data_structure() datapred = PI._setup_data_structure_for_prediction(data=DS, ndatabatches=1) return PI, datapred