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¶
Descriptor¶
-
template<typename Float = float, typename Method = method::by_default, typename Task = task::by_default, typename Optimizer = oneapi::dal::newton_cg::descriptor<Float>>
class descriptor¶ - 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(bool compute_intercept = true, double C = 1.0)¶
Creates a new instance of the class with the given
compute_intercept
andC
.
-
descriptor(bool compute_intercept, double C, const optimizer_t &optimizer)¶
Creates a new instance of the class with the given
compute_intercept
,C
andoptimizer
.
Properties
-
double inverse_regularization¶
Defines inverse regularization factor.
- Getter & Setter
double get_inverse_regularization() const
auto & set_inverse_regularization(double C) const
-
std::int64_t class_count¶
Defines number of classes.
- Getter & Setter
std::int64_t get_class_count() const
auto & set_class_count(std::int64_t class_count) const
-
const optimizer_t &optimizer¶
- Getter & Setter
const optimizer_t & get_optimizer() const
auto & set_optimizer(const optimizer_t &opt)
-
bool compute_intercept¶
Defines should intercept be taken into consideration.
- Getter & Setter
bool get_compute_intercept() const
auto & set_compute_intercept(bool compute_intercept) const
-
result_option_id result_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)
Model¶
-
template<typename Task = task::by_default>
class model¶ - 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
Training train(...)¶
Input¶
-
template<typename Task = task::by_default>
class train_input¶ - Template Parameters
Task – Tag-type that specifies type of the problem to solve. Can be task::classification.
Constructors
-
train_input(const table &data, const table &responses)¶
Creates a new instance of the class with the given
data
andresponses
property values.
Properties
Result¶
-
template<typename Task = task::by_default>
class train_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_t iterations_count¶
Actual number of optimizer iterations.
- Getter & Setter
std::int64_t get_iterations_count() const
auto & set_iterations_count(std::int64_t value)
-
const table &intercept¶
Table with Logistic Regression intercept.
- Getter & Setter
const table & get_intercept() const
auto & set_intercept(const table &value)
-
const table &packed_coefficients¶
Table of Logistic Regression coefficients and intercept.
- Getter & Setter
const table & get_packed_coefficients() const
auto & set_packed_coefficients(const table &value)
-
const model<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)
-
const result_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)
-
const table &coefficients¶
Table of Logistic Regression coefficients.
- Getter & Setter
const table & get_coefficients() const
auto & set_coefficients(const table &value)
-
std::int64_t inner_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)
Operation¶
-
template<typename Descriptor>
logistic_regression::train_result train(const Descriptor &desc, const logistic_regression::train_input &input)¶ - Parameters
desc – Logistic Regression algorithm descriptor logistic_regression::descriptor
input – Input data for the training operation
- Preconditions
- Postconditions
Inference infer(...)¶
Input¶
-
template<typename Task = task::by_default>
class infer_input¶ - Template Parameters
Task – Tag-type that specifies type of the problem to solve. Can be task::classification.
Constructors
-
infer_input(const table &data, const model<Task> &model)¶
Creates a new instance of the class with the given
data
andmodel
property values.
Properties
Result¶
-
template<typename Task = task::by_default>
class infer_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
Operation¶
-
template<typename Descriptor>
logistic_regression::infer_result infer(const Descriptor &desc, const logistic_regression::infer_input &input)¶ - Parameters
desc – Logistic Regression algorithm descriptor logistic_regression::descriptor
input – Input data for the inference operation
Examples¶
oneAPI DPC++¶
- Batch Processing: