Objective function

Some classification algorithms are designed to minimize the selected objective function. On each iteration its’ gradient and sometimes hessian is calculated and model weights are updated using this information.

Operation

Computational methods

Programming Interface

dense_batch

dense_batch

compute(…)

compute_input

compute_result

Mathematical formulation

Refer to Developer Guide: Objective function.

Programming Interface

All types and functions in this section are declared in the oneapi::dal::objective_function namespace and be available via inclusion of the oneapi/dal/algo/objective_function.hpp header file.

Result options

class result_option_id

Public Methods

constexpr result_option_id() = default
constexpr result_option_id(const result_option_id_base &base)

Descriptor

template<typename Float = float, typename Method = method::by_default, typename Task = task::by_default, typename Objective = logloss_objective::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.

  • Task – Tag-type that specifies the type of the problem to solve. Can be task::compute.

  • Objective – The descriptor of the objective function to computate. Can be logloss_objective::descriptor.

Constructors

descriptor()

Creates a new instance of the class with the default property values.

descriptor(const objective_t &obj)

Creates a new instance of the class with the given obj property value.

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)
const objective_t &objective

Choose objective function for calculations.

Getter & Setter
const objective_t & get_objective()
auto & set_objective(const objective_t &obj)

Method tags

struct dense_batch

Tag-type that denotes computational method.

using by_default = dense_batch

Alias tag-type for the computational method.

Task tags

struct compute

Tag-type that parameterizes entities that are used to compute statistics.

using by_default = compute

Alias tag-type for compute task.

Compute compute(...)

Input

template<typename Task = task::by_default>
class compute_input
Template Parameters

Task – Tag-type that specifies the type of the problem to solve. Can be task::compute.

Constructors

compute_input(const table &data, const table &parameters, const table &responses)

Creates a new instance of the class with the given data, parameters and responses property valuea.

Properties

const table &parameters

An \(p+1 \times 1\) table with the model weights. Default value: table{}.

Getter & Setter
const table & get_parameters() const
auto & set_parameters(const table &value)
const table &data

An \(n \times p\) table with the training data, where each row stores one feature vector. Default value: table{}.

Getter & Setter
const table & get_data() const
auto & set_data(const table &value)
const table &responses

An \(n \times 1\) table with the correct class labels. Default value: table{}.

Getter & Setter
const table & get_responses() const
auto & set_responses(const table &value)

Result

template<typename Task = task::by_default>
class compute_result
Template Parameters

Task – Tag-type that specifies the type of the problem to solve. Can be task::compute.

Constructors

compute_result()

Creates a new instance of the class with the default property values.

Properties

const table &value

The matrix of size \(1 \times 1\) with the objective function value. Default value: table{}.

Getter & Setter
const table & get_value() const
auto & set_value(const table &value)
const table &hessian

The matrix of size \(p + 1 \times p + 1\) with the objective function hessian. Default value: table{}.

Getter & Setter
const table & get_hessian() const
auto & set_hessian(const table &value)
const result_option_id &result_options

Result options that indicates availability of the properties. Default value: default_result_options<Task>.

Getter & Setter
const result_option_id & get_result_options() const
auto & set_result_options(const result_option_id &value)
const table &gradient

The matrix of size \(p + 1 \times 1\) with the objective function gradient. Default value: table{}.

Getter & Setter
const table & get_gradient() const
auto & set_gradient(const table &value)

Operation

template<typename Descriptor>
objective_function::compute_result compute(const Descriptor &desc, const objective_function::compute_input &input)
Parameters
  • desc – objective_function algorithm descriptor objective_function::descriptor

  • input – Input for objective_function computation. Contains data, parameters and responses

Preconditions
input.data.has_data == true
input.parameters.has_data == true
input.responses.has_data == true
input.data.row_count == input.responses.row_count
input.data.column_count + 1 == input.parameters.row_count
input.responses.column_count == 1
input.parameters.column_count == 1
Postconditions
result.value.row_count == 1
result.value.column_count == 1
result.gradient.row_count == input.data.column_count + 1
result.gradient.column_count == 1
result.hessian.row_count == input.data.column_count + 1
result.hessian.column_count == input.data.column_count + 1