def test_model(model, X, y, error_fn=None, score_fn=None, search_params=None, verbose=True): maybe_print('Training model...', verbose) if search_params is not None: validator = cv.DataFrameCV(model, search_params, n_folds=args.nfolds, error_fn=error_fn, score_fn=score_fn, verbose=verbose) validator.fit(X, y) err = validator.best_result else: err = cv.cv_dataframe(model, X, y, err_fn, score_fn, n_folds=args.nfolds, verbose=verbose) return err
def train_model(model, X, y, parameters=None, verbose=True): if parameters is None: parameters = {} else: parameters = parse_parameters(parameters) model.set_params(**parameters) maybe_print('Fitting model...', verbose) model.fit(X, y) maybe_print('Done!', verbose) return model
def setup_model(source, builder, objective_fn, verbose=True): maybe_print('Building events...', verbose) X = builder.build_events(source) maybe_print('Calculating objective...', verbose) y = objective_fn(X) return (X, y)