Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
expose max features for normal solver, and improve doc
  • Loading branch information
jkbradley committed Nov 8, 2016
commit 72a9302908ce22052095df4620bddc1f91352a97
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ private[ml] class QuasiNewtonSolver(
* Exception thrown when solving a linear system Ax = b for which the matrix A is non-invertible
* (singular).
*/
private[ml] class SingularMatrixException(message: String, cause: Throwable)
private[spark] class SingularMatrixException(message: String, cause: Throwable)
extends IllegalArgumentException(message, cause) {

def this(message: String) = this(message, null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,13 @@ class LinearRegression @Since("1.3.0") (@Since("1.3.0") override val uid: String
/**
* Set the solver algorithm used for optimization.
* In case of linear regression, this can be "l-bfgs", "normal" and "auto".
* "l-bfgs" denotes Limited-memory BFGS which is a limited-memory quasi-Newton
* optimization method. "normal" denotes using Normal Equation as an analytical
* solution to the linear regression problem.
* The default value is "auto" which means that the solver algorithm is
* selected automatically.
*
* The Normal Equation solver is limited to a few thousand features; when needed,
* [[LinearRegression]] will automatically fall back to iterative optimization methods.
* - "l-bfgs" denotes Limited-memory BFGS which is a limited-memory quasi-Newton
* optimization method.
* - "normal" denotes using Normal Equation as an analytical solution to the linear regression
* problem. This solver is limited to [[LinearRegression.MAX_FEATURES_FOR_NORMAL_SOLVER]].
* - "auto" (default) means that the solver algorithm is selected automatically.
* The Normal Equations solver will be used when possible, but this will automatically fall
* back to iterative optimization methods when needed.
*
* @group setParam
*/
Expand Down Expand Up @@ -407,6 +406,13 @@ object LinearRegression extends DefaultParamsReadable[LinearRegression] {

@Since("1.6.0")
override def load(path: String): LinearRegression = super.load(path)

/**
* When using [[LinearRegression.solver]] == "normal", the solver must limit the number of
* features to at most this number.
Copy link
Contributor

@sethah sethah Nov 8, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor suggestion: perhaps an explanation as to why might be useful. "must limit the number of features to at most this number, because the entire covariance matrix X^T^X will be collected on the driver. This limit helps prevent memory overflow errors."

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do

*/
@Since("2.1.0")
val MAX_FEATURES_FOR_NORMAL_SOLVER: Int = WeightedLeastSquares.MAX_NUM_FEATURES
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAX_NUM_FEATURES_FOR_NORMAL_SOLVER should be better?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer the current name. MAX_NUM_.... is longer but not any clearer to me. I don't feel too strongly about it though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I left out "NUM_" for conciseness.

}

/**
Expand Down