Exemplo n.º 1
0
def test_miner_init_smoke(miner_df):
    logcf = lambda row, x: mvn.logpdf(x, np.zeros(2), np.eye(len(x)))
    miner = MInER(miner_df, logcf, ['x_2', 'x_3'], n_models=2, use_mp=False)
    miner.init_models()
    assert hasattr(miner, '_logcf')
    assert hasattr(miner, '_miner_cols')
    assert hasattr(miner, '_miner_col_idxs')
    assert not hasattr(miner, 'combat_wombat')
Exemplo n.º 2
0
def test_fit_smoke(miner_df):
    logcf = lambda row, x: mvn.logpdf(x, np.zeros(2), np.eye(len(x)))
    miner = MInER(miner_df, logcf, ['x_2', 'x_3'], n_models=2, use_mp=False)
    miner.init_models()
    miner.fit(1, 5)

    assert(not np.any(np.isnan(miner._df['x_2'].values)))
    assert(not np.any(np.isnan(miner._df['x_3'].values)))
Exemplo n.º 3
0
def test_miner_init_smoke(miner_df):
    logcf = lambda row, x: mvn.logpdf(x, np.zeros(2), np.eye(len(x)))
    miner = MInER(miner_df, logcf, ['x_2', 'x_3'], n_models=2, use_mp=False)
    miner.init_models()
    assert hasattr(miner, '_logcf')
    assert hasattr(miner, '_miner_cols')
    assert hasattr(miner, '_miner_col_idxs')
    assert not hasattr(miner, 'combat_wombat')
Exemplo n.º 4
0
def test_convert_uniform_column_to_normal(miner_df):
    logcf = lambda row, x: norm.logpdf(x[0], 0, 1)
    miner = MInER(miner_df, logcf, ['x_2'], n_models=2, use_mp=False)
    miner.init_models()
    miner.fit(20, 10)

    assert(not np.any(np.isnan(miner._df['x_2'].values)))
    assert(not np.any(np.isnan(miner._df['x_3'].values)))

    assert(normaltest(miner._df['x_2'])[1] > .05)
    assert(normaltest(miner._df['x_3'])[1] < .05)
Exemplo n.º 5
0
def test_fit_changes_data_sometimes_one_col(miner_df):
    df = copy.deepcopy(miner_df)
    logcf = lambda row, x: 0.0
    miner = MInER(miner_df, logcf, ['x_2'], n_models=2, use_mp=False)
    miner.init_models()
    miner.fit(1, 5)

    assert(not np.any(np.isnan(miner._df['x_2'].values)))
    assert(not np.any(np.isnan(miner._df['x_3'].values)))

    for i in range(miner._n_cols):
        assert(miner._df['x_1'].ix[i] == df['x_1'].ix[i])
        assert(miner._df['x_2'].ix[i] != df['x_2'].ix[i])
        assert(miner._df['x_3'].ix[i] == df['x_3'].ix[i])
Exemplo n.º 6
0
def test_miner_changes_columns_differently(miner_df):
    df = copy.deepcopy(miner_df)
    logcf = lambda row, x: 0.0

    x_02 = df.loc[0, 'x_2']
    x_03 = df.loc[0, 'x_3']

    miner = MInER(miner_df, logcf, ['x_2', 'x_3'], n_models=2, use_mp=False)
    miner.init_models()
    miner.fit(1, 5)

    assert miner._df.loc[0, 'x_2'] != x_02
    assert miner._df.loc[0, 'x_3'] != x_03
    for i in range(df.shape[0]):
        assert miner._df.loc[i, 'x_2'] != miner._df.loc[i, 'x_3']
Exemplo n.º 7
0
def test_fit_smoke(miner_df):
    logcf = lambda row, x: mvn.logpdf(x, np.zeros(2), np.eye(len(x)))
    miner = MInER(miner_df, logcf, ['x_2', 'x_3'], n_models=2, use_mp=False)
    miner.init_models()
    miner.fit(1, 5)

    assert (not np.any(np.isnan(miner._df['x_2'].values)))
    assert (not np.any(np.isnan(miner._df['x_3'].values)))
Exemplo n.º 8
0
def test_convert_uniform_column_to_normal(miner_df):
    logcf = lambda row, x: norm.logpdf(x[0], 0, 1)
    miner = MInER(miner_df, logcf, ['x_2'], n_models=2, use_mp=False)
    miner.init_models()
    miner.fit(20, 10)

    assert (not np.any(np.isnan(miner._df['x_2'].values)))
    assert (not np.any(np.isnan(miner._df['x_3'].values)))

    assert (normaltest(miner._df['x_2'])[1] > .05)
    assert (normaltest(miner._df['x_3'])[1] < .05)
Exemplo n.º 9
0
def test_fit_changes_data_sometimes_one_col(miner_df):
    df = copy.deepcopy(miner_df)
    logcf = lambda row, x: 0.0
    miner = MInER(miner_df, logcf, ['x_2'], n_models=2, use_mp=False)
    miner.init_models()
    miner.fit(1, 5)

    assert (not np.any(np.isnan(miner._df['x_2'].values)))
    assert (not np.any(np.isnan(miner._df['x_3'].values)))

    for i in range(miner._n_cols):
        assert (miner._df['x_1'].ix[i] == df['x_1'].ix[i])
        assert (miner._df['x_2'].ix[i] != df['x_2'].ix[i])
        assert (miner._df['x_3'].ix[i] == df['x_3'].ix[i])
Exemplo n.º 10
0
def test_miner_changes_columns_differently(miner_df):
    df = copy.deepcopy(miner_df)
    logcf = lambda row, x: 0.0

    x_02 = df.loc[0, 'x_2']
    x_03 = df.loc[0, 'x_3']

    miner = MInER(miner_df, logcf, ['x_2', 'x_3'], n_models=2, use_mp=False)
    miner.init_models()
    miner.fit(1, 5)

    assert miner._df.loc[0, 'x_2'] != x_02
    assert miner._df.loc[0, 'x_3'] != x_03
    for i in range(df.shape[0]):
        assert miner._df.loc[i, 'x_2'] != miner._df.loc[i, 'x_3']