SoftmaxRegressor constructor

SoftmaxRegressor(
  1. DataFrame trainData,
  2. List<String> targetNames, {
  3. LinearOptimizerType optimizerType = linearOptimizerTypeDefaultValue,
  4. int iterationsLimit = iterationLimitDefaultValue,
  5. double initialLearningRate = initialLearningRateDefaultValue,
  6. double decay = decayDefaultValue,
  7. int dropRate = dropRateDefaultValue,
  8. double minCoefficientsUpdate = minCoefficientsUpdateDefaultValue,
  9. double lambda = lambdaDefaultValue,
  10. int batchSize = batchSizeDefaultValue,
  11. bool fitIntercept = fitInterceptDefaultValue,
  12. double interceptScale = interceptScaleDefaultValue,
  13. LearningRateType learningRateType = learningRateTypeDefaultValue,
  14. bool isFittingDataNormalized = isFittingDataNormalizedDefaultValue,
  15. InitialCoefficientsType initialCoefficientsType = initialCoefficientsTypeDefaultValue,
  16. num positiveLabel = positiveLabelDefaultValue,
  17. num negativeLabel = negativeLabelDefaultValue,
  18. bool collectLearningData = collectLearningDataDefaultValue,
  19. DType dtype = dTypeDefaultValue,
  20. RegularizationType? regularizationType,
  21. Matrix? initialCoefficients,
  22. int? randomSeed,
})

Parameters:

trainData A DataFrame with observations which are used by the classifier to learn coefficients. Must contain targetNames columns.

targetNames A collection of strings that serves as names for the target columns. A target column is a column that is containing class labels.

optimizerType Defines an algorithm of optimization that will be used to find the best coefficients of log-likelihood cost function. Also defines a regularization type.

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

initialLearningRate A value defining velocity of the convergence of the gradient descent optimizer. Default value is 1e-3.

decay The value meaning "speed" of learning rate decrease. Applicable only for LearningRateType.timeBased, LearningRateType.stepBased, and LearningRateType.exponential strategies

dropRate The value that is used as a number of learning iterations after which the learning rate will be decreased. The value is applicable only for LearningRateType.stepBased learning rate; it will be omitted for other learning rate strategies

minCoefficientsUpdate 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 A coefficient of regularization. Uses to prevent the regressor's overfitting. The more the value of lambda, the more regular the coefficients are. Extremely large lambda may decrease the coefficients to nothing, otherwise too small lambda may be a cause of too large absolute values of the coefficients.

regularizationType A way the coefficients of the classifier will be regularized to prevent overfitting of the model.

randomSeed A seed that will be passed to a random value generator used by stochastic optimizers. Will be ignored, if the optimizer isn't stochastic. Remember, each time you run the stochastic regressor with the same parameters but with unspecified randomSeed, you will receive different results. To avoid it, define randomSeed

batchSize A size of data (in rows) that will be used per one fitting iteration. Applicable not for all optimizers. If gradient-based optimizer uses and If batchSize == 1, stochastic mode will be activated; if 1 < batchSize < total number of rows, mini-batch mode will be activated; if batchSize == total number of rows, full-batch mode will be activated.

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) to be learned by the classifier.

interceptScale A value defining a size of the intercept.

learningRateType A value defining a strategy of the learning rate behaviour throughout the whole fitting process.

isFittingDataNormalized Defines, whether the trainData normalized or not. Normalization should be performed column-wise. Normalized data may be required by some optimizers (e.g., for LinearOptimizerType.coordinate)

initialCoefficientsType Defines a type of coefficients (e.g. all zeroes, all random) that will be used in the very first iteration of optimization. By default, all the initial coefficients are equal to zeroes. If initialCoefficients are provided, the parameter will be ignored

initialCoefficients Coefficients to be used in the bery first iteration of the optimization algorithm. initialCoefficients is a Matrix, where the number of columns must be equal to the number of classes (or length of targetNames) and the number of rows must be equal to the number of features in trainData. In other words, every column of initialCoefficients matrix is a vector of coefficients of a certain class.

positiveLabel A value that will be used for the positive class. By default, 1.

negativeLabel A value that will be used for the negative class. By default, 0.

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 SoftmaxRegressor(
  DataFrame trainData,
  List<String> targetNames, {
  LinearOptimizerType optimizerType = linearOptimizerTypeDefaultValue,
  int iterationsLimit = iterationLimitDefaultValue,
  double initialLearningRate = initialLearningRateDefaultValue,
  double decay = decayDefaultValue,
  int dropRate = dropRateDefaultValue,
  double minCoefficientsUpdate = minCoefficientsUpdateDefaultValue,
  double lambda = lambdaDefaultValue,
  int batchSize = batchSizeDefaultValue,
  bool fitIntercept = fitInterceptDefaultValue,
  double interceptScale = interceptScaleDefaultValue,
  LearningRateType learningRateType = learningRateTypeDefaultValue,
  bool isFittingDataNormalized = isFittingDataNormalizedDefaultValue,
  InitialCoefficientsType initialCoefficientsType =
      initialCoefficientsTypeDefaultValue,
  num positiveLabel = positiveLabelDefaultValue,
  num negativeLabel = negativeLabelDefaultValue,
  bool collectLearningData = collectLearningDataDefaultValue,
  DType dtype = dTypeDefaultValue,
  RegularizationType? regularizationType,
  Matrix? initialCoefficients,
  int? randomSeed,
}) =>
    initSoftmaxRegressorModule().get<SoftmaxRegressorFactory>().create(
          trainData: trainData,
          targetNames: targetNames,
          optimizerType: optimizerType,
          iterationsLimit: iterationsLimit,
          initialLearningRate: initialLearningRate,
          decay: decay,
          dropRate: dropRate,
          minCoefficientsUpdate: minCoefficientsUpdate,
          lambda: lambda,
          regularizationType: regularizationType,
          randomSeed: randomSeed,
          batchSize: batchSize,
          fitIntercept: fitIntercept,
          interceptScale: interceptScale,
          learningRateType: learningRateType,
          isFittingDataNormalized: isFittingDataNormalized,
          initialCoefficientsType: initialCoefficientsType,
          initialCoefficients: initialCoefficients,
          positiveLabel: positiveLabel,
          negativeLabel: negativeLabel,
          collectLearningData: collectLearningData,
          dtype: dtype,
        );