Python scipy.stats.nanmean() Examples

The following are 7 code examples of scipy.stats.nanmean(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module scipy.stats , or try the search function .
Example #1
Source File: test_stats.py    From Computable with MIT License 5 votes vote down vote up
def test_nanmean_none(self):
        # Check nanmean when no values are nan.
        m = stats.nanmean(X)
        assert_approx_equal(m, X[4]) 
Example #2
Source File: test_stats.py    From Computable with MIT License 5 votes vote down vote up
def test_nanmean_some(self):
        # Check nanmean when some values only are nan.
        m = stats.nanmean(self.Xsome)
        assert_approx_equal(m, 5.5) 
Example #3
Source File: test_stats.py    From Computable with MIT License 5 votes vote down vote up
def test_nanmean_all(self):
        # Check nanmean when all values are nan.
        olderr = np.seterr(all='ignore')
        try:
            m = stats.nanmean(self.Xall)
        finally:
            np.seterr(**olderr)
        assert_(np.isnan(m)) 
Example #4
Source File: common.py    From opendr with MIT License 5 votes vote down vote up
def nanmean(a, axis):
    # don't call nan_to_num in here, unless you check that
    # occlusion_test.py still works after you do it!
    result = nanmean_impl(a, axis=axis)
    return result 
Example #5
Source File: sf_heatmap.py    From pancanatlas_code_public with MIT License 5 votes vote down vote up
def filter_both_psi(panc_df, gtex_df, min_mean=.05, max_mean=.95):
    panc_mean = stats.nanmean(panc_df.values, 0)
    gtex_mean = stats.nanmean(gtex_df.values, 0)
    mask = (panc_mean > min_mean) * (panc_mean < max_mean) * (gtex_mean > min_mean) * (gtex_mean < max_mean)
    return panc_df.loc[:, mask], gtex_df.loc[:, mask] 
Example #6
Source File: predict.py    From Loan_Default_Prediction with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def load_train_fs():
    # In the validation process, the training data was randomly shuffled firstly. 
    # For the prediction process, there is no need to shuffle the dataset. 
    # Owing to out of memory problem, Gaussian process only use part of training data, the prediction of gaussian process
    # may be a little different from the model,which the training data was shuffled.
    train_fs = np.genfromtxt(open(dir + '/train_v2.csv','rb'), delimiter=',', skip_header=1)
    col_mean = stats.nanmean(train_fs, axis=0)
    inds = np.where(np.isnan(train_fs))
    train_fs[inds] = np.take(col_mean, inds[1])
    train_fs[np.isinf(train_fs)] = 0
    return train_fs


# load test data 
Example #7
Source File: predict.py    From Loan_Default_Prediction with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def load_test_fs():
    test_fs = np.genfromtxt(open(dir + '/test_v2.csv','rb'), delimiter=',', skip_header = 1)
    col_mean = stats.nanmean(test_fs, axis=0)
    inds = np.where(np.isnan(test_fs))
    test_fs[inds] = np.take(col_mean, inds[1])
    test_fs[np.isinf(test_fs)] = 0
    return test_fs

# extract features from test data