Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(7)  |  Call(6)  |  Derive(0)  |  Import(1)

src/m/o/mozsci-HEAD/test/test_inputs.py   mozsci(Download)
        weights = np.array([0.2, 0.1, 2,0.5, 1])
 
        ret = inputs.mean_std_weighted(x)
        self.assertTrue(abs(ret['mean'] - 3.0) < 1e-8)
        self.assertTrue(abs(ret['std'] - np.sqrt(2 * (4 + 1) / 5)) < 1e-8)
 
        ret = inputs.mean_std_weighted(x, np.ones(x.shape))
        self.assertTrue(abs(ret['std'] - np.sqrt(2 * (4 + 1) / 5)) < 1e-8)
 
        ret = inputs.mean_std_weighted(x, weights)
        m = np.sum(weights * x) / np.sum(weights)
        s = np.sqrt(np.sum((x - m)**2 * weights) / np.sum(weights))
        weights = np.array([0.5, 2, 1.55])
 
        ret = inputs.mean_std_weighted(x, weights)
 
        sum_weights = np.sum(weights)

src/m/o/mozsci-HEAD/test/test_evaluation.py   mozsci(Download)
 
from mozsci import evaluation
from mozsci.inputs import mean_std_weighted
 
 
        self.assertTrue(abs(r_no_wgt - r_ones_wgt) < 1e-12)
 
        xm = mean_std_weighted(x, weights)
        ym = mean_std_weighted(y, weights)
        r_wgt = np.sum((x - xm['mean']) * (y - ym['mean']) * weights) / np.sum(weights)