Module: SVMKit::Base::Regressor
- Included in:
- Ensemble::AdaBoostRegressor, Ensemble::RandomForestRegressor, LinearModel::Lasso, LinearModel::LinearRegression, LinearModel::Ridge, LinearModel::SVR, NearestNeighbors::KNeighborsRegressor, PolynomialModel::FactorizationMachineRegressor, Tree::DecisionTreeRegressor
- Defined in:
- lib/svmkit/base/regressor.rb
Overview
Module for all regressors in SVMKit.
Instance Method Summary collapse
-
#fit ⇒ Object
An abstract method for fitting a model.
-
#predict ⇒ Object
An abstract method for predicting labels.
-
#score(x, y) ⇒ Float
Calculate the coefficient of determination for the given testing data.
Instance Method Details
#fit ⇒ Object
An abstract method for fitting a model.
11 12 13 |
# File 'lib/svmkit/base/regressor.rb', line 11 def fit raise NotImplementedError, "#{__method__} has to be implemented in #{self.class}." end |
#predict ⇒ Object
An abstract method for predicting labels.
16 17 18 |
# File 'lib/svmkit/base/regressor.rb', line 16 def predict raise NotImplementedError, "#{__method__} has to be implemented in #{self.class}." end |
#score(x, y) ⇒ Float
Calculate the coefficient of determination for the given testing data.
25 26 27 28 29 30 31 |
# File 'lib/svmkit/base/regressor.rb', line 25 def score(x, y) SVMKit::Validation.check_sample_array(x) SVMKit::Validation.check_tvalue_array(y) SVMKit::Validation.check_sample_tvalue_size(x, y) evaluator = SVMKit::EvaluationMeasure::R2Score.new evaluator.score(y, predict(x)) end |