Class: Spark::Mllib::LinearRegressionWithSGD
- Inherits:
-
RegressionMethodBase
- Object
- RegressionMethodBase
- Spark::Mllib::LinearRegressionWithSGD
- Defined in:
- lib/spark/mllib/regression/linear.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ iterations: 100, step: 1.0, mini_batch_fraction: 1.0, initial_weights: nil, reg_param: 0.0, reg_type: nil, intercept: false, validate: true }
Class Method Summary collapse
-
.train(rdd, options = {}) ⇒ Object
Train a linear regression model on the given data.
Class Method Details
.train(rdd, options = {}) ⇒ Object
Train a linear regression model on the given data.
Parameters:
- rdd
-
The training data (RDD instance).
- iterations
-
The number of iterations (default: 100).
- step
-
The step parameter used in SGD (default: 1.0).
- mini_batch_fraction
-
Fraction of data to be used for each SGD iteration (default: 1.0).
- initial_weights
-
The initial weights (default: nil).
- reg_param
-
The regularizer parameter (default: 0.0).
- reg_type
-
The type of regularizer used for training our model (default: nil).
Allowed values:
-
“l1” for using L1 regularization (lasso),
-
“l2” for using L2 regularization (ridge),
-
None for no regularization
-
- intercept
-
Boolean parameter which indicates the use or not of the augmented representation for training data (i.e. whether bias features are activated or not). (default: false)
- validate
-
Boolean parameter which indicates if the algorithm should validate data before training. (default: true)
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/spark/mllib/regression/linear.rb', line 114 def self.train(rdd, ={}) super weights, intercept = Spark.jb.call(RubyMLLibAPI.new, 'trainLinearRegressionModelWithSGD', rdd, [:iterations].to_i, [:step].to_f, [:mini_batch_fraction].to_f, [:initial_weights], [:reg_param].to_f, [:reg_type], [:intercept], [:validate]) LinearRegressionModel.new(weights, intercept) end |