Package org.apache.spark.ml.regression
Class LinearRegressionModel
Object
org.apache.spark.ml.PipelineStage
org.apache.spark.ml.Transformer
org.apache.spark.ml.Model<M>
org.apache.spark.ml.PredictionModel<FeaturesType,M>
 
org.apache.spark.ml.regression.RegressionModel<Vector,LinearRegressionModel>
 
org.apache.spark.ml.regression.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,- PredictorParams,- LinearRegressionParams,- GeneralMLWritable,- HasTrainingSummary<LinearRegressionTrainingSummary>,- Identifiable,- MLWritable
public class LinearRegressionModel
extends RegressionModel<Vector,LinearRegressionModel>
implements LinearRegressionParams, GeneralMLWritable, HasTrainingSummary<LinearRegressionTrainingSummary> 
Model produced by 
LinearRegression.- See Also:
- 
Nested Class SummaryNested classes/interfaces inherited from interface org.apache.spark.internal.Loggingorg.apache.spark.internal.Logging.LogStringContext, org.apache.spark.internal.Logging.SparkShellLoggingFilter
- 
Method SummaryModifier and TypeMethodDescriptionfinal IntParamParam for suggested depth for treeAggregate (>= 2).Creates a copy of this instance with the same UID and some extra params.final DoubleParamParam for the ElasticNet mixing parameter, in range [0, 1].final DoubleParamepsilon()The shape parameter to control the amount of robustness.Evaluates the model on a test dataset.final BooleanParamParam for whether to fit an intercept term.doublestatic LinearRegressionModelloss()The loss function to be optimized.final DoubleParamParam for Maximum memory in MB for stacking input data into blocks.final IntParammaxIter()Param for maximum number of iterations (>= 0).intReturns the number of features the model was trained on.doublePredict label for the given features.static MLReader<LinearRegressionModel>read()final DoubleParamregParam()Param for regularization parameter (>= 0).doublescale()solver()The solver algorithm for optimization.final BooleanParamParam for whether to standardize the training features before fitting the model.summary()Gets summary (e.g.final DoubleParamtol()Param for the convergence tolerance for iterative algorithms (>= 0).toString()uid()An immutable unique ID for the object and its derivatives.Param for weight column name.write()Returns aGeneralMLWriterinstance for this ML instance.Methods inherited from class org.apache.spark.ml.PredictionModelfeaturesCol, labelCol, predictionCol, setFeaturesCol, setPredictionCol, transform, transformSchemaMethods inherited from class org.apache.spark.ml.Transformertransform, transform, transformMethods inherited from class org.apache.spark.ml.PipelineStageparamsMethods inherited from class java.lang.Objectequals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.spark.ml.param.shared.HasAggregationDepthgetAggregationDepthMethods inherited from interface org.apache.spark.ml.param.shared.HasElasticNetParamgetElasticNetParamMethods inherited from interface org.apache.spark.ml.param.shared.HasFeaturesColfeaturesCol, getFeaturesColMethods inherited from interface org.apache.spark.ml.param.shared.HasFitInterceptgetFitInterceptMethods inherited from interface org.apache.spark.ml.param.shared.HasLabelColgetLabelCol, labelColMethods inherited from interface org.apache.spark.ml.param.shared.HasMaxBlockSizeInMBgetMaxBlockSizeInMBMethods inherited from interface org.apache.spark.ml.param.shared.HasMaxItergetMaxIterMethods inherited from interface org.apache.spark.ml.param.shared.HasPredictionColgetPredictionCol, predictionColMethods inherited from interface org.apache.spark.ml.param.shared.HasRegParamgetRegParamMethods inherited from interface org.apache.spark.ml.param.shared.HasStandardizationgetStandardizationMethods inherited from interface org.apache.spark.ml.util.HasTrainingSummaryhasSummary, setSummaryMethods inherited from interface org.apache.spark.ml.param.shared.HasWeightColgetWeightColMethods inherited from interface org.apache.spark.ml.regression.LinearRegressionParamsgetEpsilon, validateAndTransformSchemaMethods inherited from interface org.apache.spark.internal.LogginginitializeForcefully, initializeLogIfNecessary, initializeLogIfNecessary, initializeLogIfNecessary$default$2, isTraceEnabled, log, logBasedOnLevel, logDebug, logDebug, logDebug, logDebug, logError, logError, logError, logError, logInfo, logInfo, logInfo, logInfo, logName, LogStringContext, logTrace, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, logWarning, MDC, org$apache$spark$internal$Logging$$log_, org$apache$spark$internal$Logging$$log__$eq, withLogContextMethods inherited from interface org.apache.spark.ml.util.MLWritablesaveMethods inherited from interface org.apache.spark.ml.param.Paramsclear, copyValues, defaultCopy, defaultParamMap, estimateMatadataSize, explainParam, explainParams, extractParamMap, extractParamMap, get, getDefault, getOrDefault, getParam, hasDefault, hasParam, isDefined, isSet, onParamChange, paramMap, params, set, set, set, setDefault, setDefault, shouldOwn
- 
Method Details- 
read
- 
load
- 
solverDescription copied from interface:LinearRegressionParamsThe solver algorithm for optimization. Supported options: "l-bfgs", "normal" and "auto". Default: "auto"- Specified by:
- solverin interface- HasSolver
- Specified by:
- solverin interface- LinearRegressionParams
- Returns:
- (undocumented)
 
- 
lossDescription copied from interface:LinearRegressionParamsThe loss function to be optimized. Supported options: "squaredError" and "huber". Default: "squaredError"- Specified by:
- lossin interface- HasLoss
- Specified by:
- lossin interface- LinearRegressionParams
- Returns:
- (undocumented)
 
- 
epsilonDescription copied from interface:LinearRegressionParamsThe shape parameter to control the amount of robustness. Must be > 1.0. At larger values of epsilon, the huber criterion becomes more similar to least squares regression; for small values of epsilon, the criterion is more similar to L1 regression. Default is 1.35 to get as much robustness as possible while retaining 95% statistical efficiency for normally distributed data. It matches sklearn HuberRegressor and is "M" from A robust hybrid of lasso and ridge regression. Only valid when "loss" is "huber".- Specified by:
- epsilonin interface- LinearRegressionParams
- Returns:
- (undocumented)
 
- 
maxBlockSizeInMBDescription copied from interface:HasMaxBlockSizeInMBParam 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 >= 0..- Specified by:
- maxBlockSizeInMBin interface- HasMaxBlockSizeInMB
- Returns:
- (undocumented)
 
- 
aggregationDepthDescription copied from interface:HasAggregationDepthParam for suggested depth for treeAggregate (>= 2).- Specified by:
- aggregationDepthin interface- HasAggregationDepth
- Returns:
- (undocumented)
 
- 
weightColDescription copied from interface:HasWeightColParam for weight column name. If this is not set or empty, we treat all instance weights as 1.0.- Specified by:
- weightColin interface- HasWeightCol
- Returns:
- (undocumented)
 
- 
standardizationDescription copied from interface:HasStandardizationParam for whether to standardize the training features before fitting the model.- Specified by:
- standardizationin interface- HasStandardization
- Returns:
- (undocumented)
 
- 
fitInterceptDescription copied from interface:HasFitInterceptParam for whether to fit an intercept term.- Specified by:
- fitInterceptin interface- HasFitIntercept
- Returns:
- (undocumented)
 
- 
tolDescription copied from interface:HasTolParam for the convergence tolerance for iterative algorithms (>= 0).
- 
maxIterDescription copied from interface:HasMaxIterParam for maximum number of iterations (>= 0).- Specified by:
- maxIterin interface- HasMaxIter
- Returns:
- (undocumented)
 
- 
elasticNetParamDescription copied from interface:HasElasticNetParamParam 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:
- elasticNetParamin interface- HasElasticNetParam
- Returns:
- (undocumented)
 
- 
regParamDescription copied from interface:HasRegParamParam for regularization parameter (>= 0).- Specified by:
- regParamin interface- HasRegParam
- Returns:
- (undocumented)
 
- 
uidDescription copied from interface:IdentifiableAn immutable unique ID for the object and its derivatives.- Specified by:
- uidin interface- Identifiable
- Returns:
- (undocumented)
 
- 
coefficients
- 
interceptpublic double intercept()
- 
scalepublic double scale()
- 
numFeaturespublic int numFeatures()Description copied from class:PredictionModelReturns the number of features the model was trained on. If unknown, returns -1- Overrides:
- numFeaturesin class- PredictionModel<Vector,- LinearRegressionModel> 
 
- 
summaryGets summary (e.g. residuals, mse, r-squared ) of model on training set. An exception is thrown ifhasSummaryis false.- Specified by:
- summaryin interface- HasTrainingSummary<LinearRegressionTrainingSummary>
- Returns:
- (undocumented)
 
- 
evaluateEvaluates the model on a test dataset.- Parameters:
- dataset- Test dataset to evaluate model on.
- Returns:
- (undocumented)
 
- 
predictDescription copied from class:PredictionModelPredict label for the given features. This method is used to implementtransform()and outputPredictionModel.predictionCol().- Specified by:
- predictin class- PredictionModel<Vector,- LinearRegressionModel> 
- Parameters:
- features- (undocumented)
- Returns:
- (undocumented)
 
- 
copyDescription copied from interface:ParamsCreates a copy of this instance with the same UID and some extra params. Subclasses should implement this method and set the return type properly. SeedefaultCopy().- Specified by:
- copyin interface- Params
- Specified by:
- copyin class- Model<LinearRegressionModel>
- Parameters:
- extra- (undocumented)
- Returns:
- (undocumented)
 
- 
writeReturns aGeneralMLWriterinstance for this ML instance.For LinearRegressionModel, this does NOT currently save the trainingsummary(). An option to savesummary()may be added in the future.This also does not save the Model.parent()currently.- Specified by:
- writein interface- GeneralMLWritable
- Specified by:
- writein interface- MLWritable
- Returns:
- (undocumented)
 
- 
toString- Specified by:
- toStringin interface- Identifiable
- Overrides:
- toStringin class- Object
 
 
-