예제 #1
0
def evaluate(X_tr, y_tr, X_te, y_te, T):
    grid = sg.RegularGridConfiguration()
    grid.dim_ = 10
    grid.level_ = 4
    grid.t_ = T
    grid.type_ = sg.GridType_ModLinear

    adapt = sg.AdaptivityConfiguration()
    adapt.numRefinements_ = 5
    adapt.noPoints_ = 3

    solv = sg.SLESolverConfiguration()
    solv.maxIterations_ = 50
    solv.eps_ = 1e-5
    solv.threshold_ = 1e-5
    solv.type_ = sg.SLESolverType_CG

    final_solv = solv
    final_solv.maxIterations = 200

    regular = sg.RegularizationConfiguration()
    regular.type_ = sg.RegularizationType_Identity
    regular.exponentBase_ = 1.0
    regular.lambda_ = 1e-3

    ## Create the estimator, train it with the training data and then return the error
    ## for the testing set.
    estimator = sg.RegressionLearner(grid, adapt, solv, final_solv, regular)
    estimator.train(X_tr, y_tr)
    print(estimator.getGridSize())
    return estimator.getMSE(X_te, y_te)
def make_estimator(lambda_reg, prior):
    grid = sg.RegularGridConfiguration()
    grid.dim_ = 4
    grid.level_ = 5
    grid.type_ = sg.GridType_ModLinear

    adapt = sg.AdaptivityConfiguration()
    adapt.numRefinements_ = 5
    adapt.noPoints_ = 3

    solv = sg.SLESolverConfiguration()
    solv.maxIterations_ = 50
    solv.eps_ = 10e-6
    solv.threshold_ = 10e-6
    solv.type_ = sg.SLESolverType_CG

    final_solv = solv
    final_solv.maxIterations = 200

    regular = sg.RegularizationConfiguration()
    regular.type_ = sg.RegularizationType_Diagonal
    regular.exponentBase_ = prior
    regular.lambda_ = lambda_reg

    estimator = sg.RegressionLearner(grid, adapt, solv, final_solv, regular)
    return estimator
예제 #3
0
def make_estimator(penalty, l1_ratio, lambda_reg):
    grid = sg.RegularGridConfiguration()
    grid.dim_ = 10
    grid.level_ = 2
    grid.type_ = sg.GridType_ModLinear

    adapt = sg.AdaptivityConfiguration()
    adapt.numRefinements_ = 0
    adapt.noPoints_ = 0

    solv = sg.SLESolverConfiguration()
    solv.maxIterations_ = 500
    solv.threshold_ = 10e-10
    solv.type_ = sg.SLESolverType_FISTA

    final_solv = solv

    regular = sg.RegularizationConfiguration()
    regular.type_ = penalty
    regular.exponentBase_ = 1.0
    regular.lambda_ = lambda_reg
    regular.l1_ratio_ = l1_ratio

    estimator = sg.RegressionLearner(grid, adapt, solv, final_solv,regular)
    return estimator