elasticNetCV#
- swordfish.function.elasticNetCV()#
Implement linear regression with elastic net penalty using 5-fold cross-validation and return a model corresponding to the optimal parameters.
- 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.
alphas (Constant, optional) – A floating-point scalar or vector that represents the coefficient multiplied by the L1 norm penalty term. The default value is [0.01, 0.1, 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.
- Returns:
A dictionary containing the following keys:
modelName: the model name, which is “elasticNetCV” for this method
coefficients: the regression coefficients
intercept: the intercept
dual_gap: the dual gap
tolerance: the tolerance for the optimization
iterations: the number of iterations
xColNames: the column names of the independent variables in the data source
predict: the function used for prediction
alpha: the penalty term for cross-validation
- Return type: