示例#1
0
def mbgd():
        X, X_val, y, y_val = data.demo()
        theta = np.array([-1,-1])
        learning_rate = 0.01
        learning_rate_sched = 't'
        time_decay = 0.1
        step_decay=0.5
        step_epochs=2
        exp_decay=0.1             
        precision = 0.001
        maxiter = 10000
        directory = "./test/figures/BGD/"
        i_s=5
        batch_size = 5
        gd = MBGD()
        gd.fit(X=X, y=y, theta=theta,X_val=X_val, y_val=y_val, learning_rate=learning_rate,
               learning_rate_sched=learning_rate_sched, time_decay=time_decay, step_decay=step_decay,
               step_epochs=step_epochs, exp_decay=exp_decay,
               maxiter=maxiter, precision=precision, i_s=i_s) 
        return(gd)
示例#2
0
# %%
import numpy as np
import pandas as pd
import sys
srcdir = "c:\\Users\\John\\Documents\\Data Science\\Libraries\\GradientDescent\\src"
sys.path.append(srcdir)

from GradientDescent import BGD, SGD
from GradientVisual import GradientVisual
import data
#%%
# --------------------------------------------------------------------------- #
#                             SEARCH FUNCTION                                 #
# --------------------------------------------------------------------------- #

X, X_val, y, y_val = data.demo()
alg = 'Stochastic Gradient Descent'
theta = np.array([-1, -1])
learning_rate = 0.01
learning_rate_sched = 'c'
stop_metric = 'j'
time_decay = 0.5
step_decay = 0.5
step_epochs = 2
exp_decay = 0.1
precision = 0.01
maxiter = 5000
i_s = 5
directory = "./test/figures/SGD/"
gd = SGD()
gd.fit(X=X,
示例#3
0
import os
import sys

from IPython.display import HTML
from matplotlib import animation, rc
from matplotlib import rcParams
import numpy as np
import pandas as pd

src = "c:\\Users\\John\\Documents\\Data Science\\Libraries\\GradientDescent\\src"
sys.path.append(src)
from GradientLab import BGDLab
import data

# Data
X, X_val, y, y_val = data.demo(n=500)

# Parameters
theta = np.array([-1, -1])
learning_rate = [1.6]
stop_metric = ['j']
precision = [0.001]
maxiter = 5000
learning_rate_sched = ['t']
time_decay = np.arange(0.01, 1, 0.01)
step_decay = [0.1, 0.01, 0.001]
step_epochs = [2, 5, 10]
exp_decay = [0.1, 0.01, 0.001]
i_s = [10]
directory = "./test/figures/BGD/Lab/"