Class LinearRegressionModel

All Implemented Interfaces:
Serializable, org.apache.spark.internal.Logging, Params, HasAggregationDepth, HasElasticNetParam, HasFeaturesCol, HasFitIntercept, HasLabelCol, HasLoss, HasMaxBlockSizeInMB, HasMaxIter, HasPredictionCol, HasRegParam, HasSolver, HasStandardization, HasTol, HasWeightCol, org.apache.spark.ml.PredictorParams, org.apache.spark.ml.regression.LinearRegressionParams, GeneralMLWritable, org.apache.spark.ml.util.HasTrainingSummary<LinearRegressionTrainingSummary>, Identifiable, MLWritable

public class LinearRegressionModel extends RegressionModel<Vector,LinearRegressionModel> implements org.apache.spark.ml.regression.LinearRegressionParams, GeneralMLWritable, org.apache.spark.ml.util.HasTrainingSummary<LinearRegressionTrainingSummary>
Model produced by LinearRegression.
See Also:
  • Method Details

    • read

      public static MLReader<LinearRegressionModel> read()
    • load

      public static LinearRegressionModel load(String path)
    • solver

      public final Param<String> solver()
      Description copied from interface: HasSolver
      Param for the solver algorithm for optimization.
      Specified by:
      solver in interface HasSolver
      Specified by:
      solver in interface org.apache.spark.ml.regression.LinearRegressionParams
      Returns:
      (undocumented)
    • loss

      public final Param<String> loss()
      Description copied from interface: HasLoss
      Param for the loss function to be optimized.
      Specified by:
      loss in interface HasLoss
      Specified by:
      loss in interface org.apache.spark.ml.regression.LinearRegressionParams
      Returns:
      (undocumented)
    • epsilon

      public final DoubleParam epsilon()
      Specified by:
      epsilon in interface org.apache.spark.ml.regression.LinearRegressionParams
    • maxBlockSizeInMB

      public final DoubleParam maxBlockSizeInMB()
      Description copied from interface: HasMaxBlockSizeInMB
      Param for Maximum memory in MB for stacking input data into blocks. Data is stacked within partitions. If more than remaining data size in a partition then it is adjusted to the data size. Default 0.0 represents choosing optimal value, depends on specific algorithm. Must be &gt;= 0..
      Specified by:
      maxBlockSizeInMB in interface HasMaxBlockSizeInMB
      Returns:
      (undocumented)
    • aggregationDepth

      public final IntParam aggregationDepth()
      Description copied from interface: HasAggregationDepth
      Param for suggested depth for treeAggregate (&gt;= 2).
      Specified by:
      aggregationDepth in interface HasAggregationDepth
      Returns:
      (undocumented)
    • weightCol

      public final Param<String> weightCol()
      Description copied from interface: HasWeightCol
      Param for weight column name. If this is not set or empty, we treat all instance weights as 1.0.
      Specified by:
      weightCol in interface HasWeightCol
      Returns:
      (undocumented)
    • standardization

      public final BooleanParam standardization()
      Description copied from interface: HasStandardization
      Param for whether to standardize the training features before fitting the model.
      Specified by:
      standardization in interface HasStandardization
      Returns:
      (undocumented)
    • fitIntercept

      public final BooleanParam fitIntercept()
      Description copied from interface: HasFitIntercept
      Param for whether to fit an intercept term.
      Specified by:
      fitIntercept in interface HasFitIntercept
      Returns:
      (undocumented)
    • tol

      public final DoubleParam tol()
      Description copied from interface: HasTol
      Param for the convergence tolerance for iterative algorithms (&gt;= 0).
      Specified by:
      tol in interface HasTol
      Returns:
      (undocumented)
    • maxIter

      public final IntParam maxIter()
      Description copied from interface: HasMaxIter
      Param for maximum number of iterations (&gt;= 0).
      Specified by:
      maxIter in interface HasMaxIter
      Returns:
      (undocumented)
    • elasticNetParam

      public final DoubleParam elasticNetParam()
      Description copied from interface: HasElasticNetParam
      Param for the ElasticNet mixing parameter, in range [0, 1]. For alpha = 0, the penalty is an L2 penalty. For alpha = 1, it is an L1 penalty.
      Specified by:
      elasticNetParam in interface HasElasticNetParam
      Returns:
      (undocumented)
    • regParam

      public final DoubleParam regParam()
      Description copied from interface: HasRegParam
      Param for regularization parameter (&gt;= 0).
      Specified by:
      regParam in interface HasRegParam
      Returns:
      (undocumented)
    • uid

      public String uid()
      Description copied from interface: Identifiable
      An immutable unique ID for the object and its derivatives.
      Specified by:
      uid in interface Identifiable
      Returns:
      (undocumented)
    • coefficients

      public Vector coefficients()
    • intercept

      public double intercept()
    • scale

      public double scale()
    • numFeatures

      public int numFeatures()
      Description copied from class: PredictionModel
      Returns the number of features the model was trained on. If unknown, returns -1
      Overrides:
      numFeatures in class PredictionModel<Vector,LinearRegressionModel>
    • summary

      Gets summary (e.g. residuals, mse, r-squared ) of model on training set. An exception is thrown if hasSummary is false.
      Specified by:
      summary in interface org.apache.spark.ml.util.HasTrainingSummary<LinearRegressionTrainingSummary>
      Returns:
      (undocumented)
    • evaluate

      public LinearRegressionSummary evaluate(Dataset<?> dataset)
      Evaluates the model on a test dataset.

      Parameters:
      dataset - Test dataset to evaluate model on.
      Returns:
      (undocumented)
    • predict

      public double predict(Vector features)
      Description copied from class: PredictionModel
      Predict label for the given features. This method is used to implement transform() and output PredictionModel.predictionCol().
      Specified by:
      predict in class PredictionModel<Vector,LinearRegressionModel>
      Parameters:
      features - (undocumented)
      Returns:
      (undocumented)
    • copy

      public LinearRegressionModel copy(ParamMap extra)
      Description copied from interface: Params
      Creates a copy of this instance with the same UID and some extra params. Subclasses should implement this method and set the return type properly. See defaultCopy().
      Specified by:
      copy in interface Params
      Specified by:
      copy in class Model<LinearRegressionModel>
      Parameters:
      extra - (undocumented)
      Returns:
      (undocumented)
    • write

      public GeneralMLWriter write()
      Returns a GeneralMLWriter instance for this ML instance.

      For LinearRegressionModel, this does NOT currently save the training summary(). An option to save summary() may be added in the future.

      This also does not save the Model.parent() currently.

      Specified by:
      write in interface GeneralMLWritable
      Specified by:
      write in interface MLWritable
      Returns:
      (undocumented)
    • toString

      public String toString()
      Specified by:
      toString in interface Identifiable
      Overrides:
      toString in class Object