예제 #1
0
파일: test_wlra.py 프로젝트: rbassett3/wlra
def test_plra_oracle(simulate):
    x, eta = simulate
    l1 = st.poisson(mu=np.exp(
        wlra.plra(x, rank=3, max_outer_iters=100,
                  check_converged=True))).logpmf(x).sum()
    l0 = st.poisson(mu=np.exp(eta)).logpmf(x).sum()
    assert l1 > l0
예제 #2
0
파일: benchmark.py 프로젝트: aksarkar/scaa
def imputation_score_plra1(x, rank):
    try:
        import wlra
        res = np.exp(wlra.plra(x, rank=rank, max_outer_iters=1))
        return loss(res[x.mask], x.data[x.mask])
    except RuntimeError:
        return [np.nan for f in losses]
예제 #3
0
파일: benchmark.py 프로젝트: aksarkar/scaa
def training_score_plra1(x, rank=10):
    import wlra
    lam = np.exp(wlra.plra(x, rank=rank))
    return st.poisson(mu=lam).logpmf(x).sum()
예제 #4
0
파일: benchmark.py 프로젝트: aksarkar/scaa
def training_score_plra(x, rank):
    import wlra
    return st.poisson(mu=np.exp(
        wlra.plra(x, rank=rank, max_outer_iters=100,
                  check_converged=True))).logpmf(x).sum()
예제 #5
0
파일: benchmark.py 프로젝트: aksarkar/scaa
def generalization_score_plra1(train, test, rank=10, **kwargs):
    import wlra
    lam = np.exp(wlra.plra(train, rank=rank))
    return pois_llik(lam, train, test)
예제 #6
0
파일: test_wlra.py 프로젝트: rbassett3/wlra
def test_plra1_10x():
    import scmodes
    x = scmodes.dataset.read_10x(
        f'/project2/mstephens/aksarkar/projects/singlecell-ideas/data/10xgenomics/b_cells/filtered_matrices_mex/hg19/',
        return_df=True)
    res = wlra.plra(x.values, rank=10, verbose=True)
예제 #7
0
파일: test_wlra.py 프로젝트: rbassett3/wlra
def test_plra_mask(simulate):
    x, eta = simulate
    mask = np.random.uniform(size=x.shape) < 0.25
    x = np.ma.masked_array(x, mask=mask)
    res = wlra.plra(x, 3)
예제 #8
0
파일: test_wlra.py 프로젝트: rbassett3/wlra
def test_plra1_oracle(simulate):
    x, eta = simulate
    l1 = st.poisson(
        mu=np.exp(wlra.plra(x, rank=3, max_outer_iters=1))).logpmf(x).sum()
    l0 = st.poisson(mu=np.exp(eta)).logpmf(x).sum()
    assert l1 > l0
예제 #9
0
파일: test_wlra.py 프로젝트: rbassett3/wlra
def test_plra_assume_rank_1():
    x = np.random.poisson(lam=np.exp(np.random.normal(size=(100, 200))))
    res = wlra.plra(x, 1)
예제 #10
0
파일: test_wlra.py 프로젝트: rbassett3/wlra
def test_plra_shape():
    x = np.ones((100, 200))
    res = wlra.plra(x, 1)
    assert res.shape == (100, 200)