コード例 #1
0
    def test_nn_regressor_complex_no_exceptions(self):
        encoding = create_test_encoding(
            value_encoding=ValueEncodings.COMPLEX.value,
            prefix_length=2,
            padding=True)
        labelling = create_test_labelling(
            label_type=LabelTypes.REMAINING_TIME.value)

        train_df = complex(self.train_log, labelling, encoding,
                           self.train_add_col)
        test_df = complex(self.test_log, labelling, encoding,
                          self.test_add_col)

        train_df, targets_df = self._drop_columns_and_split(train_df)
        targets_df = targets_df.values.ravel()

        test_df, _ = self._drop_columns_and_split(test_df)

        config = self._get_nn_default_config(
            encoding=ValueEncodings.COMPLEX.value)
        nn_regressor = NNRegressor(**config)

        # with HidePrints():
        nn_regressor.fit(train_df, targets_df)
        nn_regressor.predict(test_df)
コード例 #2
0
def _choose_regressor(job: Job) -> RegressorMixin:
    method, config = get_method_config(job)
    config.pop('regression_method', None)
    print("Using method {} with config {}".format(method, config))
    if method == RegressionMethods.LINEAR.value:
        regressor = LinearRegression(**config)
    elif method == RegressionMethods.RANDOM_FOREST.value:
        regressor = RandomForestRegressor(**config)
    elif method == RegressionMethods.LASSO.value:
        regressor = Lasso(**config)
    elif method == RegressionMethods.XGBOOST.value:
        regressor = XGBRegressor(**config)
    elif method == RegressionMethods.NN.value:
        config['encoding'] = job.encoding.value_encoding
        regressor = NNRegressor(**config)
    else:
        raise ValueError("Unexpected regression method {}".format(method))
    return regressor