Sha256: 5c22d16d4acfbfb528edb5954a839adb197e43c07ec0a273440c3d38d984b126

Contents?: true

Size: 622 Bytes

Versions: 14

Compression:

Stored size: 622 Bytes

Contents

module XGBoost
  class Regressor < Model
    def initialize(n_estimators: 100, objective: "reg:squarederror", importance_type: "gain", **options)
      super
    end

    def fit(x, y, eval_set: nil, early_stopping_rounds: nil, verbose: true)
      dtrain = DMatrix.new(x, label: y)
      evals = Array(eval_set).map.with_index { |v, i| [DMatrix.new(v[0], label: v[1]), "validation_#{i}"] }

      @booster = XGBoost.train(@params, dtrain,
        num_boost_round: @n_estimators,
        early_stopping_rounds: early_stopping_rounds,
        verbose_eval: verbose,
        evals: evals
      )
      nil
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
honzasterba_xgb-0.9.0 lib/xgboost/regressor.rb
xgb-0.9.0 lib/xgboost/regressor.rb
xgb-0.8.0 lib/xgboost/regressor.rb
xgb-0.7.3 lib/xgboost/regressor.rb
xgb-0.7.2 lib/xgboost/regressor.rb
xgb-0.7.1 lib/xgboost/regressor.rb
xgb-0.7.0 lib/xgboost/regressor.rb
xgb-0.6.0 lib/xgboost/regressor.rb
xgb-0.5.3 lib/xgboost/regressor.rb
xgb-0.5.2 lib/xgboost/regressor.rb
xgb-0.5.1 lib/xgboost/regressor.rb
xgb-0.5.0 lib/xgboost/regressor.rb
xgb-0.4.1 lib/xgboost/regressor.rb
xgb-0.4.0 lib/xgboost/regressor.rb