elasticNet#

swordfish.function.elasticNet()#

Implement linear regression with elastic net penalty (combined L1 and L2 priors as regularizer).

Minimize the following objective function:

\(\displaystyle{\frac{1}{2*n_-samples}}* \Bigl\lVert{y - Xw} \Bigr\rVert_2^2 + alpha * l1Ratio\Bigl\lVert{w}\Bigr\rVert_1 + \displaystyle{\frac{alpha*(1-l1Ratio)}{2}}\Bigl\lVert{w}\Bigr\rVert_2^2\)

Parameters:
  • ds (Constant) – An in-memory table or a data source usually generated by the sqlDS function.

  • yColName (Constant) – A string indicating the column name of the dependent variable in ds.

  • xColNames (Constant) – A STRING scalar/vector indicating the column names of the independent variables in ds.

  • alpha (Constant, optional) – A floating-point number representing the constant that multiplies the L1-norm. The default value is 1.0.

  • l1Ratio (Constant, optional) – A floating-point number between 0 and 1 indicating the mixing parameter. For l1Ratio = 0 the penalty is an L2 penalty; for l1Ratio = 1 it is an L1 penalty; for 0 < l1Ratio < 1, the penalty is a combination of L1 and L2. The default value is 0.5.

  • intercept (Constant, optional) – A Boolean value indicating whether to include the intercept in the regression. The default value is true.

  • normalize (Constant, optional) – A Boolean value. If true, the regressors will be normalized before regression by subtracting the mean and dividing by the L2-norm. If intercept=false, this parameter will be ignored. The default value is false.

  • maxIter (Constant, optional) – A positive integer indicating the maximum number of iterations. The default value is 1000.

  • tolerance (Constant, optional) – A floating-point number. The iterations stop when the improvement in the objective function value is smaller than tolerance. The default value is 0.0001.

  • positive (Constant, optional) – A Boolean value indicating whether to force the coefficient estimates to be positive. The default value is false.

  • swColName (Constant, optional) – A string indicating a column name of ds. The specified column is used as the sample weight. If it is not specified, the sample weight is treated as 1.

  • checkInput (Constant, optional) –

    A Boolean value. It determines whether to enable validation check for parameters yColName, xColNames, and swColName.

    • If checkInput = true (default), it will check the invalid value for parameters and throw an error if the null value exists.

    • If checkInput = false, the invalid value is not checked.

    It is recommended to specify checkInput = true. If it is false, it must be ensured that there are no invalid values in the input parameters and no invalid values will be generated during intermediate calculations, otherwise the returned model may be inaccurate.