Пример #1
0
    def test_KCSD2D_cross_validation_five_electrodes(self):
        lambdas = np.array([100.0 / 2**n for n in range(1, 20)])
        n_elec = self.k.elec_pos.shape[0]
        index_generator = LeaveOneOut(n_elec)  #, indices=True)
        self.k.lambd = cv.choose_lambda(lambdas, self.k.sampled_pots,
                                        self.k.k_pot, self.k.elec_pos,
                                        index_generator)

        self.assertGreater(self.k.lambd, 25.0)
Пример #2
0
    def test_KCSD2D_cross_validation_five_electrodes(self):
        lambdas = np.array([100.0/2**n for n in xrange(1, 20)])
        n_elec = self.k.elec_pos.shape[0]
        index_generator = LeaveOneOut(n_elec, indices=True)
        self.k.lambd = cv.choose_lambda(lambdas,
            self.k.sampled_pots,
            self.k.k_pot, self.k.elec_pos,
            index_generator)

        self.assertGreater(self.k.lambd, 25.0)
Пример #3
0
    def test_KCSD_1D_lambda_choice(self):
        """for potentials calculated from model, lambda < 1.0"""

        params = {'sigma': self.sigma, 'source_type': 'gauss_lim',
                  'x_min': -5.0, 'x_max': 10.0, 'h': self.h}
        k = KCSD(self.elec_pos, self.meas_pot, params)
        lambdas = np.array([100.0/2**n for n in xrange(1, 20)])
        n_elec = k.solver.elec_pos.shape[0]
        index_generator = LeaveOneOut(n_elec, indices=True)
        k.solver.lambd = cv.choose_lambda(lambdas, k.solver.sampled_pots,
                                          k.solver.k_pot, k.solver.elec_pos,
                                          index_generator)
        self.assertLess(k.solver.lambd, 1.0)
Пример #4
0
    def test_KCSD_1D_cross_validation_two_electrodes(self):
        """cross validation should promote high lambdas in this case"""

        params = {'x_min': 0.0, 'x_max': 1.0, 'gdX': 0.1,
                  'source_type': 'gauss_lim'}
        k = KCSD(elec_pos=np.array([[0.2], [0.7]]),
                 sampled_pots=np.array([[1.0, 0.5]]).T,
                 params=params)
        k.estimate_pots()
        lambdas = np.array([0.1, 0.5, 1.0])
        n_elec = k.solver.elec_pos.shape[0]
        index_generator = LeaveOneOut(n_elec, indices=True)
        k.solver.lambd = cv.choose_lambda(lambdas, k.solver.sampled_pots,
                                          k.solver.k_pot, k.solver.elec_pos,
                                          index_generator)
        self.assertEquals(k.solver.lambd, 1.0)
Пример #5
0
    def test_KCSD_1D_lambda_choice(self):
        """for potentials calculated from model, lambda < 1.0"""

        params = {
            'sigma': self.sigma,
            'source_type': 'gauss_lim',
            'x_min': -5.0,
            'x_max': 10.0,
            'h': self.h
        }
        k = KCSD(self.elec_pos, self.meas_pot, params)
        lambdas = np.array([100.0 / 2**n for n in range(1, 20)])
        n_elec = k.solver.elec_pos.shape[0]
        index_generator = LeaveOneOut(n_elec)  #, indices=True)
        k.solver.lambd = cv.choose_lambda(lambdas, k.solver.sampled_pots,
                                          k.solver.k_pot, k.solver.elec_pos,
                                          index_generator)
        self.assertLess(k.solver.lambd, 1.0)
Пример #6
0
    def test_KCSD_1D_cross_validation_two_electrodes(self):
        """cross validation should promote high lambdas in this case"""

        params = {
            'x_min': 0.0,
            'x_max': 1.0,
            'gdX': 0.1,
            'source_type': 'gauss_lim'
        }
        k = KCSD(elec_pos=np.array([[0.2], [0.7]]),
                 sampled_pots=np.array([[1.0, 0.5]]).T,
                 params=params)
        k.estimate_pots()
        lambdas = np.array([0.1, 0.5, 1.0])
        n_elec = k.solver.elec_pos.shape[0]
        index_generator = LeaveOneOut(n_elec)  #, indices=True)
        k.solver.lambd = cv.choose_lambda(lambdas, k.solver.sampled_pots,
                                          k.solver.k_pot, k.solver.elec_pos,
                                          index_generator)
        self.assertEqual(k.solver.lambd, 1.0)