Class: XGBoost::Regressor
Instance Attribute Summary
Attributes inherited from Model
Instance Method Summary collapse
- #fit(x, y, eval_set: nil, early_stopping_rounds: nil, verbose: true) ⇒ Object
-
#initialize(n_estimators: 100, objective: "reg:squarederror", importance_type: "gain", **options) ⇒ Regressor
constructor
A new instance of Regressor.
Methods inherited from Model
#feature_importances, #load_model, #predict, #save_model
Constructor Details
#initialize(n_estimators: 100, objective: "reg:squarederror", importance_type: "gain", **options) ⇒ Regressor
Returns a new instance of Regressor.
3 4 5 |
# File 'lib/xgboost/regressor.rb', line 3 def initialize(n_estimators: 100, objective: "reg:squarederror", importance_type: "gain", **) super end |
Instance Method Details
#fit(x, y, eval_set: nil, early_stopping_rounds: nil, verbose: true) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/xgboost/regressor.rb', line 7 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 || @early_stopping_rounds, verbose_eval: verbose, evals: evals ) nil end |