#include <toolkits/supervised_learning/linear_regression_opt_interface.hpp>
|
| linear_regression_opt_interface (const ml_data &_data, const ml_data &_valid_data, linear_regression &_model, bool _feature_rescaling=true) |
|
| ~linear_regression_opt_interface () |
|
void | set_threads (size_t _n_threads) |
|
void | init_feature_rescaling () |
|
void | rescale_solution (DenseVector &coefs) |
|
size_t | num_examples () const |
|
size_t | num_variables () const |
|
size_t | num_validation_examples () const |
|
std::vector< std::pair< std::string, size_t > > | get_status_header (const std::vector< std::string > &stat_names) |
|
std::vector< std::string > | get_status (const DenseVector &coefs, const std::vector< std::string > &stats) |
|
void | compute_first_order_statistics (const DenseVector &point, DenseVector &gradient, double &function_value, const size_t mbStart=0, const size_t mbSize=-1) |
|
void | compute_second_order_statistics (const DenseVector &point, DenseMatrix &hessian, DenseVector &gradient, double &function_value) |
|
void | compute_validation_first_order_statistics (const DenseVector &point, DenseVector &gradient, double &function_value) |
|
virtual void | compute_hessian (const DenseVector &point, DenseMatrix &hessian) |
|
virtual double | compute_function_value (const DenseVector &point, const size_t mbStart=0, const size_t mbSize=-1) |
|
virtual void | compute_gradient (const DenseVector &point, DenseVector &gradient, const size_t mbStart=0, const size_t mbSize=-1) |
|
virtual void | reset (int seed) |
|
Solver interface for the linear regression problem.
Definition at line 37 of file linear_regression_opt_interface.hpp.
◆ linear_regression_opt_interface()
turi::supervised::linear_regression_opt_interface::linear_regression_opt_interface |
( |
const ml_data & |
_data, |
|
|
const ml_data & |
_valid_data, |
|
|
linear_regression & |
_model, |
|
|
bool |
_feature_rescaling = true |
|
) |
| |
Is the data sparse Default constructor.
- Parameters
-
[in] | _ml_data | ML Data containing everything! |
[in] | feature_rescaling | Feature Rescaling |
- Note
- Default options are to be used when the interface is called from the linear_regression class.
◆ ~linear_regression_opt_interface()
turi::supervised::linear_regression_opt_interface::~linear_regression_opt_interface |
( |
| ) |
|
◆ compute_first_order_statistics()
void turi::supervised::linear_regression_opt_interface::compute_first_order_statistics |
( |
const DenseVector & |
point, |
|
|
DenseVector & |
gradient, |
|
|
double & |
function_value, |
|
|
const size_t |
mbStart = 0 , |
|
|
const size_t |
mbSize = -1 |
|
) |
| |
|
virtual |
Compute first order statistics at the given point. (Gradient & Function value)
- Parameters
-
[in] | point | Point at which we are computing the stats. |
[out] | gradient | Dense gradient |
[out] | function_value | Function value |
[in] | mbStart | Minibatch start index |
[in] | mbSize | Minibatch size (-1 implies all) |
Implements turi::optimization::first_order_opt_interface.
◆ compute_function_value()
virtual double turi::optimization::first_order_opt_interface::compute_function_value |
( |
const DenseVector & |
point, |
|
|
const size_t |
mbStart = 0 , |
|
|
const size_t |
mbSize = -1 |
|
) |
| |
|
virtualinherited |
Optimizations for performance reasons.
Compute the function value at a given point.
- Parameters
-
[in] | point | Point at which we are computing the gradient. |
[in] | mbStart | Minibatch start index |
[in] | mbSize | Minibatch size (-1 implies all) |
- Returns
- Function value at "point"
◆ compute_gradient()
virtual void turi::optimization::first_order_opt_interface::compute_gradient |
( |
const DenseVector & |
point, |
|
|
DenseVector & |
gradient, |
|
|
const size_t |
mbStart = 0 , |
|
|
const size_t |
mbSize = -1 |
|
) |
| |
|
virtualinherited |
Compute a gradient at the given point.
- Parameters
-
[in] | point | Point at which we are computing the gradient. |
[out] | gradient | Dense gradient |
[in] | mbStart | Minibatch start index |
[in] | mbSize | Minibatch size (-1 implies all) |
- Warning
- See warning on "sparse" compute_gradient to see a potential danger of an infinite loop if you don't imeplement at least one of "dense" or "sparse" versions of compute_gradient.
-
DO NOT USE this if your model is truly sparse.
◆ compute_hessian()
virtual void turi::optimization::second_order_opt_interface::compute_hessian |
( |
const DenseVector & |
point, |
|
|
DenseMatrix & |
hessian |
|
) |
| |
|
virtualinherited |
Optimizations for performance reasons.
Compute the hessian at the given point
- Parameters
-
[in] | point | Point at which we are computing the function value. |
[out] | hessian | Returns a dense hessian matrix. |
- Note
- Hessians are always dense matrices. Even if they are sparse, it is still really hard to factorize them by make sure the factors stay sparse.
◆ compute_second_order_statistics()
void turi::supervised::linear_regression_opt_interface::compute_second_order_statistics |
( |
const DenseVector & |
point, |
|
|
DenseMatrix & |
hessian, |
|
|
DenseVector & |
gradient, |
|
|
double & |
function_value |
|
) |
| |
|
virtual |
Compute second order statistics at the given point. (Gradient & Function value)
- Parameters
-
[in] | point | Point at which we are computing the stats. |
[out] | hessian | Hessian (Dense) |
[out] | gradient | Dense gradient |
[out] | function_value | Function value |
Implements turi::optimization::second_order_opt_interface.
◆ compute_validation_first_order_statistics()
void turi::supervised::linear_regression_opt_interface::compute_validation_first_order_statistics |
( |
const DenseVector & |
point, |
|
|
DenseVector & |
gradient, |
|
|
double & |
function_value |
|
) |
| |
Compute first order statistics at the given point with respect to the validation data. (Gradient & Function value)
- Parameters
-
[in] | point | Point at which we are computing the stats. |
[out] | gradient | Dense gradient |
[out] | function_value | Function value |
◆ get_status()
std::vector<std::string> turi::supervised::linear_regression_opt_interface::get_status |
( |
const DenseVector & |
coefs, |
|
|
const std::vector< std::string > & |
stats |
|
) |
| |
|
virtual |
Get strings needed to print a row of the progress table.
- Parameters
-
[in] | a | vector of model coefficients. |
[in] | a | vector of stats to print at the beginning of each row |
Reimplemented from turi::optimization::first_order_opt_interface.
◆ get_status_header()
std::vector<std::pair<std::string, size_t> > turi::supervised::linear_regression_opt_interface::get_status_header |
( |
const std::vector< std::string > & |
stat_names | ) |
|
|
virtual |
◆ init_feature_rescaling()
void turi::supervised::linear_regression_opt_interface::init_feature_rescaling |
( |
| ) |
|
◆ num_examples()
size_t turi::supervised::linear_regression_opt_interface::num_examples |
( |
| ) |
const |
|
virtual |
◆ num_validation_examples()
size_t turi::supervised::linear_regression_opt_interface::num_validation_examples |
( |
| ) |
const |
Get the number of validation-set examples in the model
- Returns
- Number of examples
◆ num_variables()
size_t turi::supervised::linear_regression_opt_interface::num_variables |
( |
| ) |
const |
|
virtual |
◆ rescale_solution()
void turi::supervised::linear_regression_opt_interface::rescale_solution |
( |
DenseVector & |
coefs | ) |
|
Transform the final solution back to the original scale.
- Parameters
-
[in,out] | coefs | Solution vector |
◆ reset()
virtual void turi::optimization::first_order_opt_interface::reset |
( |
int |
seed | ) |
|
|
virtualinherited |
Reset the state of the model's "randomness" source.
- Parameters
-
[in] | seed | Seed that is the source of randomness. |
◆ set_threads()
void turi::supervised::linear_regression_opt_interface::set_threads |
( |
size_t |
_n_threads | ) |
|
Set the number of threads.
- Parameters
-
[in] | _n_threads | Set the number of threads. |
◆ examples
size_t turi::supervised::linear_regression_opt_interface::examples = 0 |
|
protected |
◆ feature_rescaling
bool turi::supervised::linear_regression_opt_interface::feature_rescaling = false |
|
protected |
◆ features
size_t turi::supervised::linear_regression_opt_interface::features = 0 |
|
protected |
◆ is_dense
bool turi::supervised::linear_regression_opt_interface::is_dense = false |
|
protected |
◆ scaler
std::shared_ptr<l2_rescaling> turi::supervised::linear_regression_opt_interface::scaler |
|
protected |
◆ variables
size_t turi::supervised::linear_regression_opt_interface::variables = 0 |
|
protected |
The documentation for this class was generated from the following file: