LinearRegressor class abstract
Linear regression
A typical linear regressor uses the equation of a line for multidimensional
space to make a prediction. Each x
in the equation has its own dedicated
coefficient (weight) and the combination of these x
-es and its dedicated
coefficients gives the y
term (outcome). The latter is the value that the
regressor should predict, and since all the x
values are known (they
are the input for the algorithm), the regressor should find the best
coefficients (weights) for each x
-es to make a best prediction of y
term.
Constructors
- LinearRegressor(DataFrame fittingData, String targetName, {LinearOptimizerType optimizerType = LinearOptimizerType.closedForm, int iterationsLimit = iterationLimitDefaultValue, LearningRateType learningRateType = learningRateTypeDefaultValue, InitialCoefficientsType initialCoefficientsType = initialCoefficientsTypeDefaultValue, double initialLearningRate = initialLearningRateDefaultValue, double decay = decayDefaultValue, int dropRate = dropRateDefaultValue, double minCoefficientsUpdate = minCoefficientsUpdateDefaultValue, double lambda = lambdaDefaultValue, bool fitIntercept = fitInterceptDefaultValue, double interceptScale = interceptScaleDefaultValue, int batchSize = batchSizeDefaultValue, bool isFittingDataNormalized = isFittingDataNormalizedDefaultValue, bool collectLearningData = collectLearningDataDefaultValue, DType dtype = dTypeDefaultValue, RegularizationType? regularizationType, int? randomSeed, Matrix? initialCoefficients})
-
Parameters:
factory
- LinearRegressor.fromJson(String json)
-
Restores previously fitted LinearRegressor instance from the
json
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})
-
Lasso regression
factory
- LinearRegressor.newton(DataFrame trainData, String targetName, {double lambda = lambdaDefaultValue, bool fitIntercept = fitInterceptDefaultValue, double interceptScale = interceptScaleDefaultValue, bool collectLearningData = collectLearningDataDefaultValue, DType dtype = dTypeDefaultValue, Matrix? initialCoefficients})
-
Linear regression with Newton-Raphson optimization and L2 regularization
factory
- LinearRegressor.SGD(DataFrame trainData, String targetName, {int iterationLimit = iterationLimitDefaultValue, LearningRateType learningRateType = learningRateTypeDefaultValue, InitialCoefficientsType initialCoefficientType = initialCoefficientsTypeDefaultValue, double initialLearningRate = initialLearningRateDefaultValue, double decay = decayDefaultValue, int dropRate = dropRateDefaultValue, double minCoefficientUpdate = minCoefficientsUpdateDefaultValue, double lambda = lambdaDefaultValue, bool fitIntercept = fitInterceptDefaultValue, double interceptScale = interceptScaleDefaultValue, bool collectLearningData = collectLearningDataDefaultValue, DType dtype = dTypeDefaultValue, int? randomSeed, Matrix? initialCoefficients})
-
Linear regression with Stochastic Gradient Descent optimization and L2
regularization
factory
Properties
- batchSize → int
-
A size of a batch of data that was used in a single iteration of the
optimization algorithm
no setter
- coefficients → Vector
-
Learned coefficients (or weights) for given features
no setter
-
costPerIteration
→ List<
num> ? -
Returns a list of cost values per each learning iteration. Returns null
if the parameter
collectLearningData
of the default constructor is falseno setter - decay → num
-
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 regressor or not
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- initialCoefficients → Matrix?
-
Coefficients that were used at the very first optimization iteration
during the model's coefficients learning stage
no setter
- initialCoefficientsType → InitialCoefficientsType
-
Coefficients generator type that was used at the very first optimization
iteration during the model's coefficients learning
no setter
- initialLearningRate → num
-
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 setter - isFittingDataNormalized → bool
-
Was the train data normalized or not prior to the model's coefficients
learning stage
no setter
- iterationsLimit → int
-
A maximum number of optimization iterations that was used
during model's coefficients learning
no setter
- lambda → num
-
A regularization value that was used to prevent overfitting of the model
no setter
- learningRateType → LearningRateType
-
Learning rate update strategy that was used to learn the model's
coefficients
no setter
- minCoefficientsUpdate → num
-
A coefficients update value that was used as a stop criteria during the
model's coefficients learning process
no setter
- optimizerType → LinearOptimizerType
-
Optimization algorithm that was used to learn the model's coefficients
no setter
- randomSeed → int?
-
A value that was used during the model's coefficients learning stage to
init the randomizer for a stochastic optimizer (if the latter was chosen
to learn the model's coefficients)
no setter
- regularizationType → RegularizationType?
-
A regularization strategy that was used to prevent overfitting of the
model
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
- targetName → String
-
A string that serves as a name of the target column containing
observation labels. Uses in a predicted dataframe returning from predict
method
no setter
-
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
-
retrain(
DataFrame data) → LinearRegressor -
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