Linear Regression¶
Linear regression is a method to model the connection between a dependent variable, which can be a vector, and one or more explanatory variables. This is done by fitting the linear equations to the observed data.
Operation |
Computational methods |
Programming Interface |
||
Mathematical Formulation¶
Refer to Developer Guide: Linear Regression.
Programming Interface¶
All types and functions from this section are declared in the
oneapi::dal::linear_regression
namespace and available by including the
oneapi/dal/algo/linear_regression.hpp
header file.
Descriptor¶
-
template<typename Float = float, typename Method = method::by_default, typename Task = task::by_default>
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::norm_eq.
Task – Tag-type that specifies type of the problem to solve. Can be task::regression.
Constructors
-
descriptor(bool compute_intercept)¶
Creates a new instance of the class with the given
compute_intercept
.
-
descriptor()¶
Creates a new instance of the class with default parameters.
-
descriptor(bool compute_intercept, double alpha)¶
-
descriptor(double alpha)¶
Properties
-
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)
-
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
-
double alpha¶
Defines regularization term alpha used in Ridge Regression.
- Getter & Setter
double get_alpha() const
auto & set_alpha(double value)
Training¶
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::regression.
Constructors
-
train_input()¶
-
train_input(const table &data, const table &responses)¶
Creates a new instance of the class with the given
data
andresponses
property values.
Properties
Result and Finalize 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 or task::search.
Constructors
-
train_result()¶
Creates a new instance of the class with the default property values.
Properties
-
const table &intercept¶
Table of Linear regression intercept.
- Getter & Setter
const table & get_intercept() const
auto & set_intercept(const table &value)
-
const table &packed_coefficients¶
Table of Linear regression coefficients with intercept.
- Getter & Setter
const table & get_packed_coefficients() const
auto & set_packed_coefficients(const table &value)
-
const model<Task> &model¶
The trained Linear 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)
Partial Training¶
Partial Input¶
-
template<typename Task = task::by_default>
class partial_train_input¶ Constructors
-
partial_train_input()¶
-
partial_train_input(const partial_train_result<Task> &prev, const table &data)¶
-
partial_train_input(const partial_train_result<Task> &prev, const table &data, const table &responses)¶
-
partial_train_input(const partial_train_result<Task> &prev, const partial_train_input<Task> &input)¶
Properties
-
const table &data¶
- Getter & Setter
const table & get_data() const
auto & set_data(const table &value)
-
const table &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)
-
const partial_train_result<Task> &prev¶
- Getter & Setter
const partial_train_result< Task > & get_prev() const
auto & set_prev(const partial_train_result< Task > &value)
-
partial_train_input()¶
Partial Result and Finalize Input¶
-
template<typename Task = task::by_default>
class partial_train_result¶ Constructors
-
partial_train_result()¶
Properties
-
partial_train_result()¶
Finalize Training¶
Inference¶
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 or task::search.
Constructors
-
infer_input(const table &data, const model<Task> &model)¶
Creates a new instance of the class with the given
model
anddata
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::regression.
Constructors
-
infer_result()¶
Creates a new instance of the class with the default property values.
Properties