Class LinearRegressionWorker

  • All Implemented Interfaces:
    ml.shifu.guagua.worker.WorkerComputable<LinearRegressionParams,​LinearRegressionParams>

    public class LinearRegressionWorker
    extends ml.shifu.guagua.worker.AbstractWorkerComputable<LinearRegressionParams,​LinearRegressionParams,​ml.shifu.guagua.hadoop.io.GuaguaWritableAdapter<org.apache.hadoop.io.LongWritable>,​ml.shifu.guagua.hadoop.io.GuaguaWritableAdapter<org.apache.hadoop.io.Text>>
    LinearRegressionWorker defines logic to accumulate local linear regression gradients.

    At first iteration, wait for master to use the consistent initiating model.

    At other iterations, workers include:

    • 1. Update local model by using global model from last step..
    • 2. Accumulate gradients by using local worker input data.
    • 3. Send new local gradients to master by returning parameters.

    WARNING: Input data should be normalized before, or you will get a very bad model.

    • Constructor Detail

      • LinearRegressionWorker

        public LinearRegressionWorker()
    • Method Detail

      • initRecordReader

        public void initRecordReader​(ml.shifu.guagua.io.GuaguaFileSplit fileSplit)
                              throws IOException
        Specified by:
        initRecordReader in class ml.shifu.guagua.worker.AbstractWorkerComputable<LinearRegressionParams,​LinearRegressionParams,​ml.shifu.guagua.hadoop.io.GuaguaWritableAdapter<org.apache.hadoop.io.LongWritable>,​ml.shifu.guagua.hadoop.io.GuaguaWritableAdapter<org.apache.hadoop.io.Text>>
        Throws:
        IOException
      • load

        public void load​(ml.shifu.guagua.hadoop.io.GuaguaWritableAdapter<org.apache.hadoop.io.LongWritable> currentKey,
                         ml.shifu.guagua.hadoop.io.GuaguaWritableAdapter<org.apache.hadoop.io.Text> currentValue,
                         ml.shifu.guagua.worker.WorkerContext<LinearRegressionParams,​LinearRegressionParams> context)
        Specified by:
        load in class ml.shifu.guagua.worker.AbstractWorkerComputable<LinearRegressionParams,​LinearRegressionParams,​ml.shifu.guagua.hadoop.io.GuaguaWritableAdapter<org.apache.hadoop.io.LongWritable>,​ml.shifu.guagua.hadoop.io.GuaguaWritableAdapter<org.apache.hadoop.io.Text>>