Turi Create
4.0
|
#include <toolkits/supervised_learning/logistic_regression_opt_interface.hpp>
Public Member Functions | |
logistic_regression_opt_interface (const ml_data &_data, const ml_data &_valid_data, logistic_regression &_model) | |
~logistic_regression_opt_interface () | |
void | init_feature_rescaling () |
void | rescale_solution (DenseVector &coefs) |
void | set_threads (size_t _n_threads) |
void | set_class_weights (const flexible_type &class_weights) |
size_t | num_examples () const |
size_t | num_validation_examples () const |
size_t | num_variables () const |
size_t | num_classes () 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) |
Protected Attributes | |
bool | feature_rescaling = false |
bool | is_dense = false |
Solver interface for logistic regression.
Let J denote the number of classes, K the number of features, and N the number of examples.
coefs = [coef_1 ... coef_{J-1}] := (K * (J-1)) x 1 column vector where each coef_j for j = 1 .. J-1 is a K x 1 column vector representing coefficients for the class j.
Definition at line 43 of file logistic_regression_opt_interface.hpp.
turi::supervised::logistic_regression_opt_interface::logistic_regression_opt_interface | ( | const ml_data & | _data, |
const ml_data & | _valid_data, | ||
logistic_regression & | _model | ||
) |
Is the data dense? Default constructor
[in] | _data | ML Data containing everything |
turi::supervised::logistic_regression_opt_interface::~logistic_regression_opt_interface | ( | ) |
Default destructor
|
virtual |
Compute first order statistics at the given point. (Gradient & Function value)
[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.
|
virtualinherited |
Compute the function value at a given point.
[in] | point | Point at which we are computing the gradient. |
[in] | mbStart | Minibatch start index |
[in] | mbSize | Minibatch size (-1 implies all) |
|
virtualinherited |
Compute a gradient at the given point.
[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) |
|
virtualinherited |
Compute the hessian at the given point
[in] | point | Point at which we are computing the function value. |
[out] | hessian | Returns a dense hessian matrix. |
|
virtual |
Compute second order statistics at the given point. (Gradient & Function value)
[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.
void turi::supervised::logistic_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)
[in] | point | Point at which we are computing the stats. |
[out] | gradient | Dense gradient |
[out] | function_value | Function value |
|
virtual |
Get strings needed to print a row of the progress table.
[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.
|
virtual |
Get strings needed to print the header for the progress table.
[in] | a | vector of strings to print at the beginning of the header. |
Reimplemented from turi::optimization::first_order_opt_interface.
void turi::supervised::logistic_regression_opt_interface::init_feature_rescaling | ( | ) |
Set feature scaling
size_t turi::supervised::logistic_regression_opt_interface::num_classes | ( | ) | const |
Get the number of classes in the model
|
virtual |
Get the number of examples for the model
Implements turi::optimization::first_order_opt_interface.
size_t turi::supervised::logistic_regression_opt_interface::num_validation_examples | ( | ) | const |
Get the number of validation-set examples for the model
|
virtual |
Get the number of variables in the model
Implements turi::optimization::first_order_opt_interface.
void turi::supervised::logistic_regression_opt_interface::rescale_solution | ( | DenseVector & | coefs | ) |
Transform the final solution back to the original scale.
[in,out] | coefs | Solution vector |
|
virtualinherited |
Reset the state of the model's "randomness" source.
[in] | seed | Seed that is the source of randomness. |
void turi::supervised::logistic_regression_opt_interface::set_class_weights | ( | const flexible_type & | class_weights | ) |
Set the class weights (as a flex_dict which is already validated)
[in] | class_weights | Validated flex_dict Key : Index of the class in the target_metadata Value : Weights on the class |
void turi::supervised::logistic_regression_opt_interface::set_threads | ( | size_t | _n_threads | ) |
Set the number of threads
[in] | _n_threads | Number of threads |
|
protected |
<Scale features
Definition at line 62 of file logistic_regression_opt_interface.hpp.
|
protected |
Feature rescaling
Definition at line 63 of file logistic_regression_opt_interface.hpp.