Ejemplo n.º 1
0
def onerun(shapefunc, n=250, n_iter=100, n_models=8, subsample_size=None):
    xo, yo = shapefunc(n)

    s1 = pd.Series(xo)
    s2 = pd.Series(yo)
    df = pd.concat([s1, s2], axis=1)
    df.columns = ['x', 'y']

    engine = Engine(df, n_models=n_models, use_mp=True)
    engine.init_models(subsample_size=subsample_size)
    engine.run(n_iter)

    xy = engine.sample(['x', 'y'], n=n)
    xe = xy[:, 0]
    ye = xy[:, 1]

    return xo, yo, xe, ye
Ejemplo n.º 2
0
def onerun(shapefunc, n=250, n_iter=100, n_models=8, subsample_size=None):
    xo, yo = shapefunc(n)

    s1 = pd.Series(xo)
    s2 = pd.Series(yo)
    df = pd.concat([s1, s2], axis=1)
    df.columns = ['x', 'y']

    engine = Engine(df, n_models=n_models, use_mp=True)
    engine.init_models(subsample_size=subsample_size)
    engine.run(n_iter)

    xy = engine.sample(['x', 'y'], n=n)
    xe = xy[:, 0]
    ye = xy[:, 1]

    return xo, yo, xe, ye
Ejemplo n.º 3
0
import seaborn as sns

from baxcat.engine import Engine

x = np.hstack((
    np.random.randn(100) - 6,
    np.random.randn(100)*3,
    np.random.randn(100) + 6,))

s1 = pd.Series(x)
df = pd.DataFrame(s1, columns=['x'])

engine = Engine(df, n_models=8)
engine.init_models()
engine.run(100)
y = engine.sample('x', n=300)

plt.subplot(1, 2, 1)
sns.distplot(x, bins=30, label='original')
sns.distplot(y, bins=30, label='model')
plt.xlim([-10, 10])

engine_sub = Engine(df, n_models=8)
engine_sub.init_models(.5)
engine_sub.run(100)
y = engine_sub.sample('x', n=300)

plt.subplot(1, 2, 2)
sns.distplot(x, bins=30, label='original')
sns.distplot(y, bins=30, label='model')
plt.xlim([-10, 10])
Ejemplo n.º 4
0
        fname = func.__name__
        s = pd.Series([fname] * n)
        df = pd.concat([s, pd.Series(xo), pd.Series(yo)], axis=1)
        df.columns = ['func', 'x', 'y']
        dfs.append(df)

        ax = axes[0, i]
        ax.scatter(xo, yo, color='crimson', alpha=.3)

        ax = axes[1, i]
        ax.scatter(xe, ye, color='gray', alpha=.3)
        ax.set_xlim(axes[0, i].get_xlim())
        ax.set_ylim(axes[0, i].get_ylim())

    df = pd.concat(dfs, ignore_index=True)
    engine = Engine(df, n_models=8)
    engine.init_models()
    engine.run(1000, checkpoint=20)

    dfs = []
    for i, func in enumerate(funcs):
        func_name = func.__name__
        x = engine.sample(['x', 'y'], given=[('func', func_name)], n=n)

        ax = axes[2, i]
        ax.scatter(x[:, 0], x[:, 1], color='navy', alpha=.3)
        ax.set_xlim(axes[0, i].get_xlim())
        ax.set_ylim(axes[0, i].get_ylim())
    plt.show()
Ejemplo n.º 5
0
from baxcat.engine import Engine

x = np.hstack((
    np.random.randn(100) - 6,
    np.random.randn(100) * 3,
    np.random.randn(100) + 6,
))

s1 = pd.Series(x)
df = pd.DataFrame(s1, columns=['x'])

engine = Engine(df, n_models=8)
engine.init_models()
engine.run(100)
y = engine.sample('x', n=300)

plt.subplot(1, 2, 1)
sns.distplot(x, bins=30, label='original')
sns.distplot(y, bins=30, label='model')
plt.xlim([-10, 10])

engine_sub = Engine(df, n_models=8)
engine_sub.init_models(.5)
engine_sub.run(100)
y = engine_sub.sample('x', n=300)

plt.subplot(1, 2, 2)
sns.distplot(x, bins=30, label='original')
sns.distplot(y, bins=30, label='model')
plt.xlim([-10, 10])
Ejemplo n.º 6
0
        fname = func.__name__
        s = pd.Series([fname]*n)
        df = pd.concat([s, pd.Series(xo), pd.Series(yo)], axis=1)
        df.columns = ['func', 'x', 'y']
        dfs.append(df)

        ax = axes[0, i]
        ax.scatter(xo, yo, color='crimson', alpha=.3)

        ax = axes[1, i]
        ax.scatter(xe, ye, color='gray', alpha=.3)
        ax.set_xlim(axes[0, i].get_xlim())
        ax.set_ylim(axes[0, i].get_ylim())

    df = pd.concat(dfs, ignore_index=True)
    engine = Engine(df, n_models=8)
    engine.init_models()
    engine.run(1000, checkpoint=20)

    dfs = []
    for i, func in enumerate(funcs):
        func_name = func.__name__
        x = engine.sample(['x', 'y'], given=[('func', func_name)], n=n)

        ax = axes[2, i]
        ax.scatter(x[:, 0], x[:, 1], color='navy', alpha=.3)
        ax.set_xlim(axes[0, i].get_xlim())
        ax.set_ylim(axes[0, i].get_ylim())
    plt.show()