Class: Spark::Mllib::LassoWithSGD

Inherits:
RegressionMethodBase show all
Defined in:
lib/spark/mllib/regression/lasso.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
  iterations: 100,
  step: 1.0,
  reg_param: 0.01,
  mini_batch_fraction: 1.0,
  initial_weights: nil,
  intercept: false,
  validate: true
}

Class Method Summary collapse

Class Method Details

.train(rdd, options = {}) ⇒ Object

Train a Lasso 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).

reg_param

The regularizer parameter (default: 0.0).

mini_batch_fraction

Fraction of data to be used for each SGD iteration (default: 1.0).

initial_weights

The initial weights (default: nil).

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)



99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/spark/mllib/regression/lasso.rb', line 99

def self.train(rdd, options={})
  super

  weights, intercept = Spark.jb.call(RubyMLLibAPI.new, 'trainLassoModelWithSGD', rdd,
                                     options[:iterations].to_i,
                                     options[:step].to_f,
                                     options[:reg_param].to_f,
                                     options[:mini_batch_fraction].to_f,
                                     options[:initial_weights],
                                     options[:intercept],
                                     options[:validate])

  LassoModel.new(weights, intercept)
end