logisticRegression#

swordfish.function.logisticRegression()#

Fit a logistic regression model. The result is a dictionary with the following keys: iterations, modelName, coefficients, tolerance, logLikelihood, xColNames and intercept. iterations is the number of iterations, modelName is “Logistic Regression”, coefficients is a vector of the parameter estimates, logLikelihood is the final value of the log likelihood function.

The fitted model can be used as an input for function predict.

Parameters:
  • ds (Constant) – The data source to be trained. It can be generated with function sqlDS.

  • yColName (Constant) – A string indicating the category column name.

  • xColNames (Constant) – A string scalar/vector indicating the names of independent variables.

  • intercept (Constant, optional) – A Boolean scalar indicating whether the regression uses an intercept. The default value is true, which means that a column of 1s is added to the independent variables.

  • initTheta (Constant, optional) – A vector indicating the initial values of the parameters when the iterations begin. The default value is a vector of zeroes with the length of xColNames.size()+intercept.

  • tolerance (Constant, optional) – A numeric scalar. If the difference in the value of the log likelihood functions of 2 adjacent iterations is smaller than tolerance, the iterations would stop. The default value is 0.001.

  • maxIter (Constant, optional) – A positive integer indicating the maximum number of iterations. The iterations will stop if the number of iterations reaches maxIter. The default value is 500.

  • regularizationCoeff (Constant, optional) – A positive number indicating the coefficient of the regularization term. The default value is 1.0.