LogisticRegressor class abstract

Logistic regression-based classification.

Logistic regression is an algorithm that solves the binary classification problem. The algorithm uses maximization of the passed data likelihood. In other words, the regressor iteratively tries to select coefficients that makes combination of passed features and the coefficients most likely.

Constructors

LogisticRegressor(DataFrame trainData, String targetName, {LinearOptimizerType optimizerType = LinearOptimizerType.newton, int iterationsLimit = iterationLimitDefaultValue, double initialLearningRate = initialLearningRateDefaultValue, double decay = decayDefaultValue, int dropRate = dropRateDefaultValue, double minCoefficientsUpdate = minCoefficientsUpdateDefaultValue, double probabilityThreshold = probabilityThresholdDefaultValue, double lambda = lambdaDefaultValue, int batchSize = batchSizeDefaultValue, bool fitIntercept = fitInterceptDefaultValue, double interceptScale = interceptScaleDefaultValue, bool isFittingDataNormalized = isFittingDataNormalizedDefaultValue, LearningRateType learningRateType = learningRateTypeDefaultValue, InitialCoefficientsType initialCoefficientsType = initialCoefficientsTypeDefaultValue, num positiveLabel = positiveLabelDefaultValue, num negativeLabel = negativeLabelDefaultValue, bool collectLearningData = collectLearningDataDefaultValue, DType dtype = dTypeDefaultValue, RegularizationType? regularizationType, Vector? initialCoefficients, int? randomSeed})
Parameters:
factory
LogisticRegressor.BGD(DataFrame trainingData, String targetName, {required LearningRateType learningRateType, int iterationsLimit = iterationLimitDefaultValue, double initialLearningRate = initialLearningRateDefaultValue, double decay = decayDefaultValue, int dropRate = dropRateDefaultValue, double minCoefficientsUpdate = minCoefficientsUpdateDefaultValue, double probabilityThreshold = probabilityThresholdDefaultValue, double lambda = lambdaDefaultValue, bool fitIntercept = fitInterceptDefaultValue, double interceptScale = interceptScaleDefaultValue, InitialCoefficientsType initialCoefficientsType = initialCoefficientsTypeDefaultValue, num positiveLabel = positiveLabelDefaultValue, num negativeLabel = negativeLabelDefaultValue, bool collectLearningData = collectLearningDataDefaultValue, DType dtype = dTypeDefaultValue, Vector? initialCoefficients})
Creates a LogisticRegressor instance based on Batch Gradient Descent algorithm
factory
LogisticRegressor.fromJson(String json)
Restores previously fitted classifier instance from the json
factory
LogisticRegressor.newton(DataFrame trainingData, String targetName, {int iterationsLimit = iterationLimitDefaultValue, double minCoefficientsUpdate = minCoefficientsUpdateDefaultValue, double probabilityThreshold = probabilityThresholdDefaultValue, double lambda = lambdaDefaultValue, bool fitIntercept = fitInterceptDefaultValue, double interceptScale = interceptScaleDefaultValue, num positiveLabel = positiveLabelDefaultValue, num negativeLabel = negativeLabelDefaultValue, bool collectLearningData = collectLearningDataDefaultValue, DType dtype = dTypeDefaultValue, Vector? initialCoefficients})
Creates a LogisticRegressor instance based on Newton-Raphson method
factory
LogisticRegressor.SGD(DataFrame trainingData, String targetName, {required LearningRateType learningRateType, int iterationsLimit = iterationLimitDefaultValue, double initialLearningRate = initialLearningRateDefaultValue, double decay = decayDefaultValue, int dropRate = dropRateDefaultValue, double minCoefficientsUpdate = minCoefficientsUpdateDefaultValue, double probabilityThreshold = probabilityThresholdDefaultValue, double lambda = lambdaDefaultValue, bool fitIntercept = fitInterceptDefaultValue, double interceptScale = interceptScaleDefaultValue, InitialCoefficientsType initialCoefficientsType = initialCoefficientsTypeDefaultValue, num positiveLabel = positiveLabelDefaultValue, num negativeLabel = negativeLabelDefaultValue, bool collectLearningData = collectLearningDataDefaultValue, DType dtype = dTypeDefaultValue, Vector? initialCoefficients, int? seed})
Creates a LogisticRegressor instance based on Stochastic Gradient Descent algorithm
factory

Properties

batchSize int
A size of data (in rows) that was used in a single iteration of coefficients learning process.
no setter
coefficientsByClasses → Matrix
A matrix, where each column is a vector of coefficients, associated with the specific class
no setterinherited
costPerIteration List<num>?
Returns a list of cost values per each learning iteration. Returns null if the parameter collectLearningData of the default constructor is false
no setter
decay double
A value that was used for the learning rate decay
no setter
dropRate int
A value that was used for the learning rate drop rate
no setter
dtype DType
A type for all numeric values using by the Predictor
no setterinherited
fitIntercept bool
A flag denoting whether the intercept term is considered during learning of the classifier or not
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
initialCoefficients → Vector?
Coefficients which were used at the very first model's coefficients learning algorithm iteration.
no setter
initialCoefficientsType InitialCoefficientsType
A coefficient set type that was used by the chosen optimizer at the very first iteration of coefficients learning algorithm.
no setter
initialLearningRate double
Initial learning rate value of chosen optimization algorithm
no setter
interceptScale num
A value defining a size of the intercept if fitIntercept is true
no setterinherited
isFittingDataNormalized bool
Whether the fitting data was normalized or not prior to the model's coefficients learning
no setter
iterationsLimit int
A number of fitting iterations that was used to learn the model's coefficients.
no setter
lambda double
A coefficient of regularization
no setter
learningRateType LearningRateType
A type of a learning rate behaviour update strategy.
no setter
linkFunction → LinkFunction
A function that is used for converting learned coefficients into probabilities
no setterinherited
minCoefficientsUpdate double
A minimum distance between coefficient vectors in two contiguous iterations which was used to learn the model's coefficients.
no setter
negativeLabel num
A value using to encode negative class.
no setterinherited
optimizerType LinearOptimizerType
An algorithm of linear optimization that was used to find the best coefficients of log-likelihood cost function. Also shows which regularization type (L1 or L2) was used to learn the model's coefficients.
no setter
positiveLabel num
A value using to encode positive class.
no setterinherited
probabilityThreshold num
A probability, on the basis of which it is decided, whether an observation relates to a positive class label (see positiveLabel parameter) or to a negative class label (see negativeLabel parameter)
no setter
randomSeed int?
A seed that was passed to a random value generator used by a stochastic optimizer.
no setter
regularizationType RegularizationType?
A way the coefficients of the classification were regularized during the model's coefficients learning process to prevent model overfitting.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
schemaVersion int?
Contains a version of the current json schema
no setterinherited
targetNames Iterable<String>
A collection of target column names of a dataset which was used to learn the ML model
no setterinherited

Methods

assess(DataFrame observations, MetricType metricType) double
Assesses model performance according to provided metricType
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
predict(DataFrame testFeatures) → DataFrame
Returns prediction, based on the learned coefficients
inherited
predictProbabilities(DataFrame testFeatures) → DataFrame
Returns predicted distribution of probabilities for each observation in the passed testFeatures
inherited
retrain(DataFrame data) LogisticRegressor
Re-runs the learning process on the new training data. The features, model algorithm, and hyperparameters remain the same.
inherited
saveAsJson(String filePath) Future<File>
Saves a json-serializable map into a newly created file with the path filePath
inherited
toJson() Map<String, dynamic>
Returns a json-serializable map
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited