LinearLearner | R Documentation |
For input, you give the model labeled examples (x, y). x is a high-dimensional vector and y is a numeric label. For binary classification problems, the label must be either 0 or 1. For multiclass classification problems, the labels must be from 0 to num_classes - 1. For regression problems, y is a real number. The algorithm learns a linear function, or, for classification problems, a linear threshold function, and maps a vector x to an approximation of the label y
sagemaker.mlcore::EstimatorBase
-> sagemaker.mlcore::AmazonAlgorithmEstimatorBase
-> LinearLearner
repo_name
sagemaker repo name for framework
repo_version
version of framework
DEFAULT_MINI_BATCH_SIZE
The size of each mini-batch to use when training.
.module
mimic python module
predictor_type
The type of predictor to learn. Either "binary_classifier" or "multiclass_classifier" or "regressor".
binary_classifier_model_selection_criteria
One of 'accuracy', 'f1', 'f_beta', 'precision_at_target_recall', 'recall_at_target_precision', 'cross_entropy_loss', 'loss_function'
target_recall
Only applicable if binary_classifier_model_selection_criteria is precision_at_target_recall
target_precision
Only applicable if binary_classifier_model_selection_criteria is recall_at_target_precision.
positive_example_weight_mult
The importance weight of positive examples is multiplied by this constant.
epochs
The maximum number of passes to make over the training data.
use_bias
Whether to include a bias field
num_models
Number of models to train in parallel
num_calibration_samples
Number of observations to use from validation dataset for doing model calibration
init_method
Function to use to set the initial model weights.
init_scale
For "uniform" init, the range of values.
init_sigma
For "normal" init, the standard-deviation.
init_bias
Initial weight for bias term
optimizer
One of 'sgd', 'adam', 'rmsprop' or 'auto'
loss
One of 'logistic', 'squared_loss', 'absolute_loss', 'hinge_loss', 'eps_insensitive_squared_loss', 'eps_insensitive_absolute_loss', 'quantile_loss', 'huber_loss' or 'softmax_loss' or 'auto'.
wd
L2 regularization parameter
l1
L1 regularization parameter.
momentum
Momentum parameter of sgd optimizer.
learning_rate
The SGD learning rate
beta_1
Exponential decay rate for first moment estimates.
beta_2
Exponential decay rate for second moment estimates.
bias_lr_mult
Allows different learning rate for the bias term.
bias_wd_mult
Allows different regularization for the bias term.
use_lr_scheduler
If true, we use a scheduler for the learning rate.
lr_scheduler_step
The number of steps between decreases of the learning rate
lr_scheduler_factor
Every lr_scheduler_step the learning rate will decrease by this quantity.
lr_scheduler_minimum_lr
Every lr_scheduler_step the learning rate will decrease by this quantity.
normalize_data
Normalizes the features before training to have standard deviation of 1.0.
normalize_label
Normalizes the regression label to have a standard deviation of 1.0.
unbias_data
If true, features are modified to have mean 0.0.
unbias_label
If true, labels are modified to have mean 0.0.
num_point_for_scaler
The number of data points to use for calculating the normalizing and unbiasing terms.
margin
The margin for hinge_loss.
quantile
Quantile for quantile loss.
loss_insensitivity
Parameter for epsilon insensitive loss type.
huber_delta
Parameter for Huber loss.
early_stopping_patience
The number of epochs to wait before ending training if no improvement is made.
early_stopping_tolerance
Relative tolerance to measure an improvement in loss.
num_classes
The number of classes for the response variable.
accuracy_top_k
The value of k when computing the Top K
f_beta
The value of beta to use when calculating F score metrics for binary or multiclass classification.
balance_multiclass_weights
Whether to use class weights which give each class equal importance in the loss function.
sagemaker.mlcore::EstimatorBase$latest_job_debugger_artifacts_path()
sagemaker.mlcore::EstimatorBase$latest_job_profiler_artifacts_path()
sagemaker.mlcore::EstimatorBase$latest_job_tensorboard_artifacts_path()
sagemaker.mlcore::AmazonAlgorithmEstimatorBase$hyperparameters()
sagemaker.mlcore::AmazonAlgorithmEstimatorBase$prepare_workflow_for_training()
sagemaker.mlcore::AmazonAlgorithmEstimatorBase$training_image_uri()
new()
An :class:'Estimator' for binary classification and regression. Amazon SageMaker Linear Learner provides a solution for both classification and regression problems, allowing for exploring different training objectives simultaneously and choosing the best solution from a validation set. It allows the user to explore a large number of models and choose the best, which optimizes either continuous objectives such as mean square error, cross entropy loss, absolute error, etc., or discrete objectives suited for classification such as F1 measure, precision@recall, accuracy. The implementation provides a significant speedup over naive hyperparameter optimization techniques and an added convenience, when compared with solutions providing a solution only to continuous objectives. This Estimator may be fit via calls to :meth:'~sagemaker.amazon.amazon_estimator.AmazonAlgorithmEstimatorBase.fit_ndarray' or :meth:'~sagemaker.amazon.amazon_estimator.AmazonAlgorithmEstimatorBase.fit'. The former allows a LinearLearner model to be fit on a 2-dimensional numpy array. The latter requires Amazon :class:'~sagemaker.amazon.record_pb2.Record' protobuf serialized data to be stored in S3. To learn more about the Amazon protobuf Record class and how to prepare bulk data in this format, please consult AWS technical documentation: https://docs.aws.amazon.com/sagemaker/latest/dg/cdf-training.html After this Estimator is fit, model data is stored in S3. The model may be deployed to an Amazon SageMaker Endpoint by invoking :meth:'~sagemaker.amazon.estimator.EstimatorBase.deploy'. As well as deploying an Endpoint, “deploy“ returns a :class:'~sagemaker.amazon.linear_learner.LinearLearnerPredictor' object that can be used to make class or regression predictions, using the trained model. LinearLearner Estimators can be configured by setting hyperparameters. The available hyperparameters for LinearLearner are documented below. For further information on the AWS LinearLearner algorithm, please consult AWS technical documentation: https://docs.aws.amazon.com/sagemaker/latest/dg/linear-learner.html
LinearLearner$new( role, instance_count, instance_type, predictor_type, binary_classifier_model_selection_criteria = NULL, target_recall = NULL, target_precision = NULL, positive_example_weight_mult = NULL, epochs = NULL, use_bias = NULL, num_models = NULL, num_calibration_samples = NULL, init_method = NULL, init_scale = NULL, init_sigma = NULL, init_bias = NULL, optimizer = NULL, loss = NULL, wd = NULL, l1 = NULL, momentum = NULL, learning_rate = NULL, beta_1 = NULL, beta_2 = NULL, bias_lr_mult = NULL, bias_wd_mult = NULL, use_lr_scheduler = NULL, lr_scheduler_step = NULL, lr_scheduler_factor = NULL, lr_scheduler_minimum_lr = NULL, normalize_data = NULL, normalize_label = NULL, unbias_data = NULL, unbias_label = NULL, num_point_for_scaler = NULL, margin = NULL, quantile = NULL, loss_insensitivity = NULL, huber_delta = NULL, early_stopping_patience = NULL, early_stopping_tolerance = NULL, num_classes = NULL, accuracy_top_k = NULL, f_beta = NULL, balance_multiclass_weights = NULL, ... )
role
(str): An AWS IAM role (either name or full ARN). The Amazon SageMaker training jobs and APIs that create Amazon SageMaker endpoints use this role to access training data and model artifacts. After the endpoint is created, the inference code might use the IAM role, if accessing AWS resource.
instance_count
(int): Number of Amazon EC2 instances to use for training.
instance_type
(str): Type of EC2 instance to use for training, for example, 'ml.c4.xlarge'.
predictor_type
(str): The type of predictor to learn. Either "binary_classifier" or "multiclass_classifier" or "regressor".
binary_classifier_model_selection_criteria
(str): One of 'accuracy', 'f1', 'f_beta', 'precision_at_target_recall', 'recall_at_target_precision', 'cross_entropy_loss', 'loss_function'
target_recall
(float): Target recall. Only applicable if binary_classifier_model_selection_criteria is precision_at_target_recall.
target_precision
(float): Target precision. Only applicable if binary_classifier_model_selection_criteria is recall_at_target_precision.
positive_example_weight_mult
(float): The importance weight of positive examples is multiplied by this constant. Useful for skewed datasets. Only applies for classification tasks.
epochs
(int): The maximum number of passes to make over the training data.
use_bias
(bool): Whether to include a bias field
num_models
(int): Number of models to train in parallel. If not set, the number of parallel models to train will be decided by the algorithm itself. One model will be trained according to the given training parameter (regularization, optimizer, loss) and the rest by close by parameters.
num_calibration_samples
(int): Number of observations to use from validation dataset for doing model calibration (finding the best threshold).
init_method
(str): Function to use to set the initial model weights. One of "uniform" or "normal"
init_scale
(float): For "uniform" init, the range of values.
init_sigma
(float): For "normal" init, the standard-deviation.
init_bias
(float): Initial weight for bias term
optimizer
(str): One of 'sgd', 'adam', 'rmsprop' or 'auto'
loss
(str): One of 'logistic', 'squared_loss', 'absolute_loss', 'hinge_loss', 'eps_insensitive_squared_loss', 'eps_insensitive_absolute_loss', 'quantile_loss', 'huber_loss' or 'softmax_loss' or 'auto'.
wd
(float): L2 regularization parameter i.e. the weight decay parameter. Use 0 for no L2 regularization.
l1
(float): L1 regularization parameter. Use 0 for no L1 regularization.
momentum
(float): Momentum parameter of sgd optimizer.
learning_rate
(float): The SGD learning rate
beta_1
(float): Exponential decay rate for first moment estimates. Only applies for adam optimizer.
beta_2
(float): Exponential decay rate for second moment estimates. Only applies for adam optimizer.
bias_lr_mult
(float): Allows different learning rate for the bias term. The actual learning rate for the bias is learning rate times bias_lr_mult.
bias_wd_mult
(float): Allows different regularization for the bias term. The actual L2 regularization weight for the bias is wd times bias_wd_mult. By default there is no regularization on the bias term.
use_lr_scheduler
(bool): If true, we use a scheduler for the learning rate.
lr_scheduler_step
(int): The number of steps between decreases of the learning rate. Only applies to learning rate scheduler.
lr_scheduler_factor
(float): Every lr_scheduler_step the learning rate will decrease by this quantity. Only applies for learning rate scheduler.
lr_scheduler_minimum_lr
(float): The learning rate will never decrease to a value lower than this. Only applies for learning rate scheduler.
normalize_data
(bool): Normalizes the features before training to have standard deviation of 1.0.
normalize_label
(bool): Normalizes the regression label to have a standard deviation of 1.0. If set for classification, it will be ignored.
unbias_data
(bool): If true, features are modified to have mean 0.0.
unbias_label
(bool): If true, labels are modified to have mean 0.0.
num_point_for_scaler
(int): The number of data points to use for calculating the normalizing and unbiasing terms.
margin
(float): The margin for hinge_loss.
quantile
(float): Quantile for quantile loss. For quantile q, the model will attempt to produce predictions such that true_label < prediction with probability q.
loss_insensitivity
(float): Parameter for epsilon insensitive loss type. During training and metric evaluation, any error smaller than this is considered to be zero.
huber_delta
(float): Parameter for Huber loss. During training and metric evaluation, compute L2 loss for errors smaller than delta and L1 loss for errors larger than delta.
early_stopping_patience
(int): The number of epochs to wait before ending training if no improvement is made. The improvement is training loss if validation data is not provided, or else it is the validation loss or the binary classification model selection criteria like accuracy, f1-score etc. To disable early stopping, set early_stopping_patience to a value larger than epochs.
early_stopping_tolerance
(float): Relative tolerance to measure an improvement in loss. If the ratio of the improvement in loss divided by the previous best loss is smaller than this value, early stopping will consider the improvement to be zero.
num_classes
(int): The number of classes for the response variable. Required when predictor_type is multiclass_classifier and ignored otherwise. The classes are assumed to be labeled 0, ..., num_classes - 1.
accuracy_top_k
(int): The value of k when computing the Top K Accuracy metric for multiclass classification. An example is scored as correct if the model assigns one of the top k scores to the true label.
f_beta
(float): The value of beta to use when calculating F score metrics for binary or multiclass classification. Also used if binary_classifier_model_selection_criteria is f_beta.
balance_multiclass_weights
(bool): Whether to use class weights which give each class equal importance in the loss function. Only used when predictor_type is multiclass_classifier.
...
: base class keyword argument values.
create_model()
Return a :class:'~sagemaker.amazon.LinearLearnerModel' referencing the latest s3 model data produced by this Estimator.
LinearLearner$create_model(vpc_config_override = "VPC_CONFIG_DEFAULT", ...)
vpc_config_override
(dict[str, list[str]]): Optional override for VpcConfig set on the model. Default: use subnets and security groups from this Estimator. * 'Subnets' (list[str]): List of subnet ids. * 'SecurityGroupIds' (list[str]): List of security group ids.
...
: Additional kwargs passed to the LinearLearnerModel constructor.
.prepare_for_training()
Set hyperparameters needed for training. This method will also validate “source_dir“.
LinearLearner$.prepare_for_training( records, mini_batch_size = NULL, job_name = NULL )
records
(RecordSet) – The records to train this Estimator on.
mini_batch_size
(int or None) – The size of each mini-batch to use when training. If None, a default value will be used.
job_name
(str): Name of the training job to be created. If not specified, one is generated, using the base name given to the constructor if applicable.
clone()
The objects of this class are cloneable with this method.
LinearLearner$clone(deep = FALSE)
deep
Whether to make a deep clone.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.