LinearRegressor.lasso constructor

LinearRegressor.lasso(
  1. DataFrame trainData,
  2. String targetName, {
  3. int iterationLimit = iterationLimitDefaultValue,
  4. InitialCoefficientsType initialCoefficientType = initialCoefficientsTypeDefaultValue,
  5. double minCoefficientUpdate = minCoefficientsUpdateDefaultValue,
  6. double lambda = lambdaDefaultValue,
  7. bool fitIntercept = fitInterceptDefaultValue,
  8. double interceptScale = interceptScaleDefaultValue,
  9. bool isDataNormalized = isFittingDataNormalizedDefaultValue,
  10. bool collectLearningData = collectLearningDataDefaultValue,
  11. DType dtype = dTypeDefaultValue,
  12. Matrix? initialCoefficients,
})

Lasso regression

Lasso regression is a kind of linear regression which uses L1 (Lasso) regularization.

Coordinate descent is used as an optimization algorithm for this particular implementation of Lasso regression.

trainData A DataFrame with observations that is used by the regressor to learn coefficients of the predicting hyperplane. Must contain targetName column.

targetName A string that serves as a name of the target column containing dependent variables

iterationLimit A number of fitting iterations. Uses as a condition of convergence in the optimization algorithm. Default value is 100.

minCoefficientUpdate A minimum distance between coefficient vectors in two contiguous iterations. Uses as a condition of convergence in the optimization algorithm. If difference between the two vectors is small enough, there is no reason to continue fitting. Default value is 1e-12

lambda L1 (Lasso) regularization coefficient using for feature selection. The greater the value of lambda, the stricter feature selection is.

fitIntercept Whether or not to fit intercept term. Default value is true. Intercept in 2-dimensional space is a bias of the line (relative to X-axis).

interceptScale A value defining a size of the intercept.

isDataNormalized Defines whether the trainData is normalized or not. Normalization should be performed column-wise.

initialCoefficientType Initial coefficients generation way. If initialCoefficients are provided, the parameter will be ignored.

initialCoefficients Coefficients to be used during the first iteration of the optimization algorithm. initialCoefficients should have length that is equal to the number of features in the trainData.

collectLearningData Whether or not to collect learning data, for instance cost function value per each iteration. Affects performance much. If collectLearningData is true, one may access costPerIteration getter in order to evaluate learning process more thoroughly.

dtype A data type for all the numeric values, used by the algorithm. Can affect performance or accuracy of the computations. Default value is DType.float32.

Implementation

factory LinearRegressor.lasso(DataFrame trainData, String targetName,
        {int iterationLimit = iterationLimitDefaultValue,
        InitialCoefficientsType initialCoefficientType =
            initialCoefficientsTypeDefaultValue,
        double minCoefficientUpdate = minCoefficientsUpdateDefaultValue,
        double lambda = lambdaDefaultValue,
        bool fitIntercept = fitInterceptDefaultValue,
        double interceptScale = interceptScaleDefaultValue,
        bool isDataNormalized = isFittingDataNormalizedDefaultValue,
        bool collectLearningData = collectLearningDataDefaultValue,
        DType dtype = dTypeDefaultValue,
        Matrix? initialCoefficients}) =>
    initLinearRegressorModule().get<LinearRegressorFactory>().create(
          fittingData: trainData,
          targetName: targetName,
          optimizerType: LinearOptimizerType.coordinate,
          iterationsLimit: iterationLimit,
          learningRateType: defaultLearningRateType,
          initialCoefficientsType: initialCoefficientType,
          initialLearningRate: initialLearningRateDefaultValue,
          decay: decayDefaultValue,
          dropRate: dropRateDefaultValue,
          minCoefficientsUpdate: minCoefficientUpdate,
          lambda: lambda,
          fitIntercept: fitIntercept,
          interceptScale: interceptScale,
          batchSize: 0,
          initialCoefficients: initialCoefficients,
          isFittingDataNormalized: isDataNormalized,
          collectLearningData: collectLearningData,
          dtype: dtype,
        );