def benchmark(args, predictor, X):
    total = 0.0
    for _ in range(args.iterations):
        gc.collect()
        start = datetime.now()
        predictor.predict(X)
        end = datetime.now()
        total += total_seconds(end - start)
    return total / args.iterations
Exemplo n.º 2
0
def benchmark(args, predictor, X):
    total = 0.0
    for _ in range(args.iterations):
        gc.collect()
        start = datetime.now()
        predictor.predict(X)
        end = datetime.now()
        total += total_seconds(end - start)
    return total / args.iterations
Exemplo n.º 3
0
def bench_isotonic_regression(Y):
    """
    Runs a single iteration of isotonic regression on the input data,
    and reports the total time taken (in seconds).
    """
    gc.collect()

    tstart = datetime.now()
    isotonic_regression(Y)
    delta = datetime.now() - tstart
    return total_seconds(delta)
Exemplo n.º 4
0
def bench_isotonic_regression(Y):
    """
    Runs a single iteration of isotonic regression on the input data,
    and reports the total time taken (in seconds).
    """
    gc.collect()

    tstart = datetime.now()
    isotonic_regression(Y)
    delta = datetime.now() - tstart
    return total_seconds(delta)
Exemplo n.º 5
0
    dimensions = 500 * np.arange(1, n_iter + 1)

    for i in range(n_iter):

        print 'Iteration %s of %s' % (i, n_iter)

        n_samples, n_features = 10 * i + 3, 10 * i + 3

        X = np.random.randn(n_samples, n_features)
        Y = np.random.randn(n_samples)

        start = datetime.now()
        ridge = linear_model.Ridge(alpha=1.)
        ridge.fit(X, Y)
        time_ridge[i] = total_seconds(datetime.now() - start)

        start = datetime.now()
        ols = linear_model.LinearRegression()
        ols.fit(X, Y)
        time_ols[i] = total_seconds(datetime.now() - start)

        start = datetime.now()
        lasso = linear_model.LassoLars()
        lasso.fit(X, Y)
        time_lasso[i] = total_seconds(datetime.now() - start)

    pl.xlabel('Dimesions')
    pl.ylabel('Time (in seconds)')
    pl.plot(dimensions, time_ridge, color='r')
    pl.plot(dimensions, time_ols, color='g')
Exemplo n.º 6
0
def test_total_seconds():
    delta = (datetime.datetime(2012, 1, 1, 5, 5, 1)
             - datetime.datetime(2012, 1, 1, 5, 5, 4))
    assert_equal(86397, total_seconds(delta))
Exemplo n.º 7
0
    dimensions = 500 * np.arange(1, n_iter + 1)

    for i in range(n_iter):

        print('Iteration %s of %s' % (i, n_iter))

        n_samples, n_features = 10 * i + 3, 10 * i + 3

        X = np.random.randn(n_samples, n_features)
        Y = np.random.randn(n_samples)

        start = datetime.now()
        ridge = linear_model.Ridge(alpha=1.)
        ridge.fit(X, Y)
        time_ridge[i] = total_seconds(datetime.now() - start)

        start = datetime.now()
        ols = linear_model.LinearRegression()
        ols.fit(X, Y)
        time_ols[i] = total_seconds(datetime.now() - start)

        start = datetime.now()
        lasso = linear_model.LassoLars()
        lasso.fit(X, Y)
        time_lasso[i] = total_seconds(datetime.now() - start)

    pl.figure('scikit-learn GLM benchmark results')
    pl.xlabel('Dimensions')
    pl.ylabel('Time (s)')
    pl.plot(dimensions, time_ridge, color='r')
Exemplo n.º 8
0
def test_total_seconds():
    delta = (datetime.datetime(2012, 1, 1, 5, 5, 1) -
             datetime.datetime(2012, 1, 1, 5, 5, 4))
    assert_equal(86397, total_seconds(delta))