Class/Object

org.apache.flink.ml.regression

MultipleLinearRegression

Related Docs: object MultipleLinearRegression | package regression

Permalink

class MultipleLinearRegression extends Predictor[MultipleLinearRegression]

Multiple linear regression using the ordinary least squares (OLS) estimator.

The linear regression finds a solution to the problem

y = w_0 + w_1*x_1 + w_2*x_2 ... + w_n*x_n = w_0 + w^T*x

such that the sum of squared residuals is minimized

min_{w, w_0} \sum (y - wT*x - w_0)2

The minimization problem is solved by (stochastic) gradient descent. For each labeled vector (x,y), the gradient is calculated. The weighted average of all gradients is subtracted from the current value w which gives the new value of w_new. The weight is defined as stepsize/math.sqrt(iteration).

The optimization runs at most a maximum number of iterations or, if a convergence threshold has been set, until the convergence criterion has been met. As convergence criterion the relative change of the sum of squared residuals is used:

(S_{k-1} - S_k)/S_{k-1} < \rho

with S_k being the sum of squared residuals in iteration k and \rho being the convergence threshold.

At the moment, the whole partition is used for SGD, making it effectively a batch gradient descent. Once a sampling operator has been introduced, the algorithm can be optimized.

Example:
  1. val mlr = MultipleLinearRegression()
      .setIterations(10)
      .setStepsize(0.5)
      .setConvergenceThreshold(0.001)
    val trainingDS: DataSet[LabeledVector] = ...
    val testingDS: DataSet[Vector] = ...
    mlr.fit(trainingDS)
    val predictions = mlr.predict(testingDS)

    Parameters

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. MultipleLinearRegression
  2. Predictor
  3. Estimator
  4. WithParameters
  5. AnyRef
  6. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new MultipleLinearRegression()

    Permalink

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  8. def evaluate[Testing, PredictionValue](testing: DataSet[Testing], evaluateParameters: ParameterMap = ParameterMap.Empty)(implicit evaluator: EvaluateDataSetOperation[MultipleLinearRegression, Testing, PredictionValue]): DataSet[(PredictionValue, PredictionValue)]

    Permalink

    Evaluates the testing data by computing the prediction value and returning a pair of true label value and prediction value.

    Evaluates the testing data by computing the prediction value and returning a pair of true label value and prediction value. It is important that the implementation chooses a Testing type from which it can extract the true label value.

    Definition Classes
    Predictor
  9. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. def fit[Training](training: DataSet[Training], fitParameters: ParameterMap = ParameterMap.Empty)(implicit fitOperation: FitOperation[MultipleLinearRegression, Training]): Unit

    Permalink

    Fits the estimator to the given input data.

    Fits the estimator to the given input data. The fitting logic is contained in the FitOperation. The computed state will be stored in the implementing class.

    Training

    Type of the training data

    training

    Training data

    fitParameters

    Additional parameters for the FitOperation

    fitOperation

    FitOperation which encapsulates the algorithm logic

    Definition Classes
    Estimator
  11. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  12. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  13. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  14. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  15. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  16. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  17. val parameters: ParameterMap

    Permalink
    Definition Classes
    WithParameters
  18. def predict[Testing, Prediction](testing: DataSet[Testing], predictParameters: ParameterMap = ParameterMap.Empty)(implicit predictor: PredictDataSetOperation[MultipleLinearRegression, Testing, Prediction]): DataSet[Prediction]

    Permalink

    Predict testing data according the learned model.

    Predict testing data according the learned model. The implementing class has to provide a corresponding implementation of PredictDataSetOperation which contains the prediction logic.

    Testing

    Type of the testing data

    Prediction

    Type of the prediction data

    testing

    Testing data which shall be predicted

    predictParameters

    Additional parameters for the prediction

    predictor

    PredictDataSetOperation which encapsulates the prediction logic

    Definition Classes
    Predictor
  19. def setConvergenceThreshold(convergenceThreshold: Double): MultipleLinearRegression

    Permalink
  20. def setIterations(iterations: Int): MultipleLinearRegression

    Permalink
  21. def setLearningRateMethod(learningRateMethod: LearningRateMethodTrait): MultipleLinearRegression

    Permalink
  22. def setStepsize(stepsize: Double): MultipleLinearRegression

    Permalink
  23. def squaredResidualSum(input: DataSet[LabeledVector]): DataSet[Double]

    Permalink
  24. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  25. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  26. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  27. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  28. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  29. var weightsOption: Option[DataSet[WeightVector]]

    Permalink

Inherited from WithParameters

Inherited from AnyRef

Inherited from Any

Ungrouped