Example #1
0
def lasso():
    """Fit Lasso."""
    print("Fitting LAS...", end=" ", flush=True)
    time.sleep(SLEEP)
    t0 = time.time()
    ls = Lasso()
    ls.fit(X, y)
    print_time(t0, "Done", end="")
Example #2
0
def knn():
    """Fit KNN."""
    print("Fitting KNN...", end=" ", flush=True)
    time.sleep(SLEEP)
    t0 = time.time()
    knn = KNeighborsRegressor()
    knn.fit(X, y)
    print_time(t0, "Done", end="")
Example #3
0
def ensemble():
    """Fit ensemble."""
    print("Fitting ENS...", end=" ", flush=True)
    time.sleep(SLEEP)
    t0 = time.time()
    ens = build_ensemble(shuffle=False, folds=2)
    ens.fit(X, y)
    print_time(t0, "Done", end="")
Example #4
0
def elasticnet():
    """Fit Elastic Net."""
    print("Fitting ELN...", end=" ", flush=True)
    time.sleep(SLEEP)
    t0 = time.time()
    ls = Lasso()
    ls.fit(X, y)
    print_time(t0, "Done", end="")
Example #5
0
                name = e.__class__.__name__
                e = clone(e)

                t0 = perf_counter()
                e.fit(X, y)
                t1 = perf_counter() - t0

                times[n][name].append(t1)

                print('%s (%i) : %6.2fs |' % (name, n, t1),
                      end=" ",
                      flush=True)
            print()
        print()

    print_time(ts, "Benchmark done")

    if PLOT:
        try:
            import matplotlib.pyplot as plt

            plt.ion()
            print("Plotting results...", end=" ", flush=True)

            plt.figure(figsize=(8, 8))

            x = range(STEP, MAX + STEP, STEP)
            cm = [
                plt.cm.rainbow(i)
                for i in np.linspace(0, 1.0, int(3 * len(cores)))
            ]
Example #6
0
@profile
def elasticnet():
    """Fit Elastic Net."""
    print("Fitting ELN...", end=" ", flush=True)
    time.sleep(SLEEP)
    t0 = time.time()
    ls = Lasso()
    ls.fit(X, y)
    print_time(t0, "Done", end="")


if __name__ == '__main__':

    X, y = make_friedman1(MAX, COLS)

    print("\nML-ENSEMBLE\n")
    print("Benchmark of ML-ENSEMBLE memory profile against "
          "Scikit-learn estimators.\n"
          "Data shape: (%i, %i)\n"
          "Data size: %i MB\n" % (MAX, COLS, np.ceil(X.nbytes / 1e+6)))

    ts = time.time()

    lasso()
    knn()
    ensemble()
    elasticnet()

    print_time(ts, "\nProfiling complete.")