Visible to Intel only — GUID: GUID-5BCBEBDB-022E-4485-8BCD-CE31BFD80FFC
Visible to Intel only — GUID: GUID-5BCBEBDB-022E-4485-8BCD-CE31BFD80FFC
Logistic Regression
The Logistic Regression algorithm solves the classification problem and predicts class labels and probabilities of objects belonging to each class.
Operation |
Computational methods |
Programming Interface |
||
Mathematical formulation
Refer to Developer Guide: Logistic Regression.
Programming Interface
All types and functions are declared in the oneapi::dal::logistic_regression namespace and available via the inclusion of the oneapi/dal/algo/logistic_regression.hpp header file.
Result Options
classresult_option_id
Public Methods
constexprresult_option_id()=default
constexprresult_option_id(constresult_option_id_base&base)
Descriptor
template<typenameFloat=float,typenameMethod=method::by_default,typenameTask=task::by_default,typenameOptimizer=oneapi::dal::newton_cg::descriptor<Float>>classdescriptor
- Template Parameters
-
Float – The floating-point type that the algorithm uses for intermediate computations. Can be float or double.
Method – Tag-type that specifies an implementation of algorithm. Can be method::dense_batch or method::sparse.
Task – Tag-type that specifies type of the problem to solve. Can be task::classification.
Optimizer – The descriptor of the optimizer used for minimization. Can be newton_cg::descriptor.
Constructors
descriptor(boolcompute_intercept=true, doubleC=1.0)
Creates a new instance of the class with the given compute_intercept and C.
descriptor(boolcompute_intercept, doubleC, constoptimizer_t&optimizer)
Creates a new instance of the class with the given compute_intercept, C and optimizer.
Properties
std::int64_tclass_count
Defines number of classes.
- Getter & Setter
-
std::int64_t get_class_count() const
auto & set_class_count(std::int64_t class_count) const
result_option_idresult_options
Choose which results should be computed and returned.
- Getter & Setter
-
result_option_id get_result_options() const
auto & set_result_options(const result_option_id &value)
doubleinverse_regularization
Defines inverse regularization factor.
- Getter & Setter
-
double get_inverse_regularization() const
auto & set_inverse_regularization(double C) const
constoptimizer_t&optimizer
- Getter & Setter
-
const optimizer_t & get_optimizer() const
auto & set_optimizer(const optimizer_t &opt)
boolcompute_intercept
Defines should intercept be taken into consideration.
- Getter & Setter
-
bool get_compute_intercept() const
auto & set_compute_intercept(bool compute_intercept) const
Method Tags
structdense_batch
Tag-type that denotes dense_batch computational method.
structsparse
Tag-type that denotes sparse computational method.
usingby_default=dense_batch
Alias tag-type for the method.
Task Tags
structclassification
Tag-type that parameterizes entities used for solving classification problem.
usingby_default=classification
Alias tag-type for classification task.
Model
template<typenameTask=task::by_default>classmodel
- Template Parameters
-
Task – Tag-type that specifies type of the problem to solve.
Constructors
model()
Creates a new instance of the class with the default property values.
Properties
consttable&packed_coefficients
- Getter & Setter
-
const table & get_packed_coefficients() const
model & set_packed_coefficients(const table &t)
Training train(...)
Input
template<typenameTask=task::by_default>classtrain_input
- Template Parameters
-
Task – Tag-type that specifies type of the problem to solve. Can be task::classification.
Constructors
train_input(consttable&data, consttable&responses)
Creates a new instance of the class with the given data and responses property values.
Properties
consttable&data
The training set X. Default value: table{}.
- Getter & Setter
-
const table & get_data() const
auto & set_data(const table &data)
consttable&responses
Vector of responses y for the training set X. Default value: table{}.
- Getter & Setter
-
const table & get_responses() const
auto & set_responses(const table &responses)
Result
template<typenameTask=task::by_default>classtrain_result
- Template Parameters
-
Task – Tag-type that specifies type of the problem to solve. Can be task::classification.
Constructors
train_result()
Creates a new instance of the class with the default property values.
Properties
std::int64_titerations_count
Actual number of optimizer iterations.
- Getter & Setter
-
std::int64_t get_iterations_count() const
auto & set_iterations_count(std::int64_t value)
constresult_option_id&result_options
Result options that indicates availability of the properties.
- Getter & Setter
-
const result_option_id & get_result_options() const
auto & set_result_options(const result_option_id &value)
consttable&coefficients
Table of Logistic Regression coefficients.
- Getter & Setter
-
const table & get_coefficients() const
auto & set_coefficients(const table &value)
std::int64_tinner_iterations_count
Number of optimizer subiterations.
- Getter & Setter
-
std::int64_t get_inner_iterations_count() const
auto & set_inner_iterations_count(std::int64_t value)
consttable&packed_coefficients
Table of Logistic Regression coefficients and intercept.
- Getter & Setter
-
const table & get_packed_coefficients() const
auto & set_packed_coefficients(const table &value)
constmodel<Task>&model
The trained Logistic Regression model. Default value: model<Task>{}.
- Getter & Setter
-
const model< Task > & get_model() const
auto & set_model(const model< Task > &value)
consttable&intercept
Table with Logistic Regression intercept.
- Getter & Setter
-
const table & get_intercept() const
auto & set_intercept(const table &value)
Operation
template<typenameDescriptor>logistic_regression::train_resulttrain(constDescriptor&desc, constlogistic_regression::train_input&input)
- Parameters
-
desc – Logistic Regression algorithm descriptor logistic_regression::descriptor
input – Input data for the training operation
- Preconditions
-
input.data.has_data == true
input.responses.data.has_data == true
input.data.row_count == input.responses.row_count
input.responses.column_count == 1
desc.inverse_regularization > 0.0
desc.class_count == 2
- Postconditions
-
result.coefficients.row_count = 1
result.coefficients.column_count = input.data.column_count
result.intercept.row_count = 1
result.intercept.column_count = 1
result.packed_coefficients.row_count = 1
result.packed_coefficients.column_count = input.data.column_count + 1
Inference infer(...)
Input
template<typenameTask=task::by_default>classinfer_input
- Template Parameters
-
Task – Tag-type that specifies type of the problem to solve. Can be task::classification.
Constructors
infer_input(consttable&data, constmodel<Task>&model)
Creates a new instance of the class with the given data and model property values.
Properties
constmodel<Task>&model
The trained Logistic Regression model. Default value: model<Task>{}.
- Getter & Setter
-
const model< Task > & get_model() const
auto & set_model(const model< Task > &m)
consttable&data
The dataset for inference . Default value: table{}.
- Getter & Setter
-
const table & get_data() const
auto & set_data(const table &data)
Result
template<typenameTask=task::by_default>classinfer_result
- Template Parameters
-
Task – Tag-type that specifies type of the problem to solve. Can be task::classification.
Constructors
infer_result()
Creates a new instance of the class with the default property values.
Properties
consttable&probabilities
The predicted probabilities. Default value: table{}.
- Getter & Setter
-
const table & get_probabilities() const
auto & set_probabilities(const table &value)
consttable&responses
The predicted responses. Default value: table{}.
- Getter & Setter
-
const table & get_responses() const
auto & set_responses(const table &value)
Operation
template<typenameDescriptor>logistic_regression::infer_resultinfer(constDescriptor&desc, constlogistic_regression::infer_input&input)
- Parameters
-
desc – Logistic Regression algorithm descriptor logistic_regression::descriptor
input – Input data for the inference operation