def fetch_predict_estimator(task_type, config, X_train, y_train, weight_balance=0, data_balance=0, combined=False): # Build the ML estimator. from solnml.components.utils.balancing import get_weights, smote _fit_params = {} config_dict = config.get_dictionary().copy() if weight_balance == 1: _init_params, _fit_params = get_weights(y_train, config['estimator'], None, {}, {}) for key, val in _init_params.items(): config_dict[key] = val if data_balance == 1: X_train, y_train = smote(X_train, y_train) if task_type in CLS_TASKS: if combined: from solnml.utils.combined_evaluator import get_estimator else: from solnml.components.evaluators.cls_evaluator import get_estimator else: from solnml.components.evaluators.reg_evaluator import get_estimator _, estimator = get_estimator(config_dict) estimator.fit(X_train, y_train, **_fit_params) return estimator
def fetch_predict_estimator(task_type, estimator_id, config, X_train, y_train, weight_balance=0, data_balance=0): # Build the ML estimator. from solnml.components.utils.balancing import get_weights, smote _fit_params = {} config_dict = config.copy() if weight_balance == 1: _init_params, _fit_params = get_weights(y_train, estimator_id, None, {}, {}) for key, val in _init_params.items(): config_dict[key] = val if data_balance == 1: X_train, y_train = smote(X_train, y_train) if task_type in CLS_TASKS: from solnml.components.evaluators.cls_evaluator import get_estimator elif task_type in RGS_TASKS: from solnml.components.evaluators.rgs_evaluator import get_estimator _, estimator = get_estimator(config_dict, estimator_id) estimator.fit(X_train, y_train, **_fit_params) return estimator
def get_fit_params(self, y, estimator): from solnml.components.utils.balancing import get_weights _init_params, _fit_params = get_weights(y, estimator, None, {}, {}) return _init_params, _fit_params